showCloneHighlight {APackOfTheClones} | R Documentation |
Highlight specific clones on an APackOfTheClones ggplot
Description
This is an analogue for scRepertoire::highlightClones
that can highlight
certain clonotypes on an APackOfTheClones clonal expansion plot. For most
combinations of the arguments, there will be a ggplot fill legend on the
right side that correspond to each (existing) clonotype.
Usage
showCloneHighlight(
apotc_ggplot,
clonotype,
color_each = TRUE,
default_color = "#808080",
scale_bg = 1,
fill_legend = TRUE
)
Arguments
apotc_ggplot |
A ggplot object that is the output of APOTCPlot or vizAPOTC of an APackOfTheClones plot to be highlighted on. |
clonotype |
character vector of the sequence(s) to highlight. Note that it must be of the clonecall of the code that created the plot. A warning will be shown if any of the sequences are not present. |
color_each |
Either a logical of length 1, or a character(s). It is
|
default_color |
A character of length 1 or |
scale_bg |
A positive numeric. Scales the brightness value of each color
of the non-highlighted clones by itself as a scaling factor. Defaults to 1
which will not alter the current brightness. Note that if
|
fill_legend |
logical indicating whether a ggplot legend of the "fill" of each clonotype should be displayed. |
Details
Under the hood, this function simply mutates the plotting dataframe under
$data
in the ggplot object, and operates on a column named color
.
Note that if color_each = FALSE
and default_color = NULL
, this is
equivalent to simply not highlighting anything and a warning will be shown.
Value
A ggplot object with the data modified to the highlighted colors
Examples
library(magrittr)
data("combined_pbmc")
# piping the plot can be nice to read syntatically -
# By default, assigns unique colors to highlights and everything else is gray
vizAPOTC(combined_pbmc, clonecall = "aa", verbose = FALSE) %>%
showCloneHighlight("CASLSGSARQLTF_CASSSTVAGEQYF")
# one useful application is to highlight shared clones - beware that the
# clonotype sequences may get extremely long in the legend
shared_aa_clones <- names(getSharedClones(combined_pbmc, clonecall = "aa"))
vizAPOTC(combined_pbmc, clonecall = "aa", verbose = FALSE) %>%
showCloneHighlight(shared_aa_clones)