APOTCPlot {APackOfTheClones} | R Documentation |
Various variations of visualizations of clonal expansion post-RunAPOTC
Description
Given a seurat object with an 'apotc' (APackOfTheClones) object from running RunAPOTC, this function will read the information and return a customizable ggplot2 object of the clonal expansion with a circle size legend. If the user is unhappy about certain aspects of the plot, many parameters can be adjusted with the AdjustAPOTC function.
The specific APackOfTheClones run to be plotted can be identified in two
ways: either by inputting the run_id
associated with the run that was
either defined / auto-generated during RunAPOTC, or by inputting the
reduction_base
, clonecall
, extra_filter
and any other keyword arguments
that corresponded to the run. Its heavily recommended to use the run_id
.
If none of these parameters are inputted, the function defaults to returning
the plot of the latest run.
Usage
APOTCPlot(
seurat_obj,
reduction_base = NULL,
clonecall = NULL,
...,
extra_filter = NULL,
run_id = NULL,
show_shared = NULL,
only_link = NULL,
clone_link_width = "auto",
clone_link_color = "black",
clone_link_alpha = 0.5,
res = 360L,
linetype = "blank",
use_default_theme = TRUE,
retain_axis_scales = FALSE,
alpha = 1,
show_labels = FALSE,
label_size = 5,
add_size_legend = TRUE,
legend_sizes = "auto",
legend_position = "auto",
legend_buffer = 0.2,
legend_color = "#808080",
legend_spacing = "auto",
legend_label = "Clone sizes",
legend_text_size = 5,
add_legend_background = TRUE,
add_legend_centerspace = 0,
detail = TRUE,
verbose = TRUE
)
Arguments
seurat_obj |
A seurat object that has been integrated with clonotype data and has had a valid run of RunAPOTC. |
reduction_base |
character. The seurat reduction to base the clonal
expansion plotting on. Defaults to |
clonecall |
character. The column name in the seurat object metadata to
use. See |
... |
additional "subsetting" keyword arguments indicating the rows
corresponding to elements in the seurat object metadata that should be
filtered by. E.g., |
extra_filter |
character. An additional string that should be formatted
exactly like a statement one would pass into dplyr::filter that does
additional filtering to cells in the seurat object - on top of the other
keyword arguments - based on the metadata. This means that it will be
logically AND'ed with any keyword argument filters. This is a more flexible
alternative / addition to the filtering keyword arguments. For example, if
one wanted to filter by the length of the amino acid sequence of TCRs, one
could pass in something like |
run_id |
character. This will be the ID associated with the data of a
run, and will be used by other important functions like APOTCPlot and
AdjustAPOTC. Defaults to
where if keyword arguments and extra_filter are underscore characters if
there was no input for the |
show_shared |
The output of getSharedClones can be inputted here,
and the resulting plot will overlay lines between clone circles if that
clonotype is common between clusters. Note that the input must be
generated from data in the correct |
only_link |
Optional integer indicating to only display clone links originating from this cluster if showing shared clones. |
clone_link_width |
numeric. The width of the lines that connect shared
clones. Defaults to |
clone_link_color |
character. The color of the lines that connect shared
clones. Defaults to |
clone_link_alpha |
numeric. The alpha of the lines that connect shared clones. |
res |
The number of points on the generated path per full circle. From
plot viewers, if circles seem slightly too pixelated, it is recommended to
first try to export the plot as an |
linetype |
The type of outline each circle should have. defaults to
|
use_default_theme |
logical that defaults to |
retain_axis_scales |
If |
alpha |
numeric. The alpha of the circles in (0, 1]. Defaults to 1. |
show_labels |
If |
label_size |
The text size of labels if shown. Defaults to 5. |
add_size_legend |
If |
legend_sizes |
numeric vector. Indicates the circle sizes to be
displayed on the legend, and will always be sorted from smallest to greatest.
Defaults to |
legend_position |
character or numeric. Can be set to either
|
legend_buffer |
numeric. Indicates how much to "push" the legend towards the center of the plot from the selected corner. If negative, will push away |
legend_color |
character. Indicates the hex color of the circles displayed on the legend. Defaults to the hex code for a gray tone |
legend_spacing |
numeric. Indicates the horizontal distance between each
stacked circle on the size legend. Defaults to |
legend_label |
character. The title of the legend, which defaults to
|
legend_text_size |
numeric. The text size of the letters and numbers on the legend |
add_legend_background |
logical. If |
add_legend_centerspace |
numeric. An additional amount of distance changed between the circle sizes on the left side of the legend and the numbers on the right. Useful to set to around 0.5 (or more / less) when there are particularly large clone sizes that may cover the numbers. |
detail |
logical. If |
verbose |
logical. Decides if visual cues are displayed to the R console of the progress. |
Value
A ggplot object of the APackOfTheClones clonal expansion plot of the
seurat object. There is an additional 10th element in the object named
"APackOfTheClones"
used by other functions in this package and shouldn't
interfere with any other ggplot functionality. (As far as currently known)
See Also
Examples
data("combined_pbmc")
combined_pbmc <- RunAPOTC(
combined_pbmc, run_id = "run1", verbose = FALSE
)
# plotting with default arguments will plot the latest "run1"
clonal_packing_plot <- APOTCPlot(combined_pbmc)