Visualize how cells move between clusters across multiple Seurat clustering resolutions.
Usage
ClusterTreePlot(
srt,
cluster_cols = NULL,
prefix = NULL,
resolutions = NULL,
features = NULL,
assay = NULL,
layer = "data",
edge_threshold = 0,
node_palette = "Spectral",
node_palcolor = NULL,
edge_palette = "YlOrRd",
edge_palcolor = NULL,
node_size = c(3, 10),
edge_size = c(0.25, 1.8),
label = TRUE,
label.size = 3,
label.fg = "black",
title = "Cluster tree",
subtitle = NULL,
xlab = "Resolution",
ylab = "Cluster",
legend.position = "bottom",
theme_use = "theme_scop",
theme_args = list(),
combine = TRUE,
ncol = NULL,
return_data = FALSE,
verbose = TRUE
)Arguments
- srt
A
Seuratobject.- cluster_cols
Metadata columns containing clustering results at different resolutions. If
NULL, columns generated bySeurat::FindClusters(resolution = c(...))are detected automatically.- prefix
Optional prefix used to filter automatically detected clustering columns, for example
"RNA_snn".- resolutions
Optional numeric vector used to filter automatically detected resolutions.
- features
Features to plot: a character vector or a named list of assay gene names or numeric metadata columns.
- assay
Assay to use.
NULLuses the default assay.- layer
Assay layer to use.
- edge_threshold
Minimum incoming proportion required to draw an edge. Edges below this threshold are still available when
return_data = TRUE.- node_palette, node_palcolor
Palette used for node colors.
- edge_palette, edge_palcolor
Palette used for edge colors.
- node_size
Numeric range used for node sizes.
- edge_size
Numeric range used for edge widths.
- label
Label high-expressing cells.
- label.size
Group labels.
label_insitu = FALSEuses numbers instead of group names.- label.fg
Group labels.
label_insitu = FALSEuses numbers instead of group names.- title
Plot title.
NULLhides the title for merged/single panels. When multiple lineages are plotted andtitleisNULL, each panel is titled with its lineage column.- subtitle
Plot subtitle.
- xlab
Plot labels.
- ylab
Plot labels.
- legend.position
The position of the legend. The default is
"bottom"to keep the multiple cluster-tree guides compact.- theme_args
Theme name or function, plus extra theme arguments.
- combine
Combine plots with patchwork.
combine = FALSEreturns a list of ggplots.- ncol
Number of columns of the combined plot.
- return_data
Whether to return plot data along with the plot.
- verbose
Whether to print messages.
Value
A ggplot, patchwork, list of ggplot objects, or a list with
plot data when return_data = TRUE.
Examples
if (FALSE) { # \dontrun{
data(pancreas_sub)
pancreas_sub <- RunStandardWorkflow(pancreas_sub, verbose = FALSE)
pancreas_sub <- Seurat::FindNeighbors(
pancreas_sub,
dims = 1:20,
verbose = FALSE
)
pancreas_sub <- Seurat::FindClusters(
pancreas_sub,
resolution = seq(0.2, 1, by = 0.2),
verbose = FALSE
)
ClusterTreePlot(pancreas_sub)
ClusterTreePlot(
pancreas_sub,
features = c("Ins1", "Gcg")
)
} # }