Scatterplot of the dimensionality reduction and fitted GAM smoothers for each cell
Source:R/dimSmoothers.R
dimSmoothers.RdThis function generates a scatterplot of the log-transformed counts, and displays on top the average fitted GAM smoother curves, computed using fitGAM, along pseudotime, and is a reworked version of plotSmoothers, it allows for the plotting of multiple genes simultaneously, as well as selected lineages and conditions. Additionally, the scatterplot is rasterized to reduce the size of the output file and branching points may be displayed on each curve. Finally, the log-transformed counts and average fitted GAM smoother curves are rescaled to the same range between genes to allow for a better comparison.
Usage
dimSmoothers(
sds,
models = NULL,
sds.conditions = NULL,
genes = NULL,
lineages = NULL,
clusters = NULL,
conditions = NULL,
knots = NULL,
show.knots.labels = FALSE,
rescale = FALSE,
rescale.range = c(0, 3),
pseudotime.type = "relative",
points.size = 1,
lineages.width = 1,
lineages.arrow = arrow(),
knots.size = lineages.width * 3,
cells.colors = if (is.character(genes)) "turbo" else if (any(clusters == "pseudotime"))
"viridis" else NULL,
na.color = "lightgrey",
show.na = TRUE,
lineages.colors = "grey50",
knots.colors = lineages.colors,
knots.labels.text.colors = "white",
knots.labels.fill.colors = lineages.colors,
axis.text.size = 9,
axis.title.size = 11,
plot.title.size = 16,
lineages.legend.names = NULL,
legend.text.size = 9,
raster = FALSE
)Arguments
- sds
A SingleCellExperiment object containing the pseudotime values of one or several lineages, computed using
slingshot(usually, the input object tofitGAM).- models
A SingleCellExperiment object containing the fitted GAM smoothers, computed using
fitGAM, with or withoutconditionsprovided.- sds.conditions
A list of SingleCellExperiment objects obtained using
slingshot_conditions. The conditions used to compute the pseudotime values must be the same as those used to fit the GAM smoothers in themodelsobject, if provided.- genes
Character. The names of one or several genes to plot the fitted GAM smoothers for each cell from. If the
modelsobject is not provided, the function will plot the log-transformed counts.- lineages
Numeric. The indices of the lineages (for example, c(1, 5), 2:4 etc) to plot the pseudotime values from. Set to
NAto remove all lineages.- clusters
Character or Factor. Either the name of a metadata present in the
sdsobject (for example, 'annotations', 'seurat_clusters', etc) to color the cells, or the identities, as character or factor, of length equal to the number of cells in thesdsobject. Set to 'pseudotime' to color the cells by their pseudotime values.- conditions
Character. The names of one or several
conditionsidentities to select. IfNULL, all identities are used, and each unique condition will be plotted, for each of thelineagesprovided (for example, if you have four lineages and three conditions, twelve curves will be plotted). Ignored if themodelsobject was computed usingfitGAMwithoutconditions. Please note that if themodelsobject was computed usingfitGAMwithconditions, it is not possible to plot global lineages (withoutconditions), you would need to compute a newmodelsobject usingfitGAMwithoutconditions. This is due to a limitation in howpredictSmoothreturns average fitted GAM smoothers (if themodelsobject was computed withconditions, the function will always mean the fitted GAM smoothers for each lineage and each condition independently).- knots
Numeric. The indices of the knots to display on the
lineages. Set toNAto remove all knots. Ignored if themodelsobject is not provided.- show.knots.labels
Logical. If
TRUE, the knot numbers will be displayed usinggeom_label_repel. Ignored if themodelsobject is not provided.- rescale
Logical. If
TRUE, fitted GAM smoothers will be adjusted usingrescalebetween the first numerical value ofrescale.range(lowest value) and the second numerical value (highest value). This is different thanscaleas this doesn't compare values to any mean or standard deviation and is therefore not a Z-score, it only refits each value (independently for each gene) in order to visualize allgenesin the same dimension regardless of their differences in fitted GAM smoothers.- rescale.range
Numeric. The minimum and maximum values to resize the fitted GAM smoothers and internally passed to
rescale. These values are arbitrary and will not change the visualization, only the values in the legend. Ignored ifrescale=FALSE.- pseudotime.type
Character. Determines the
cells.colorsrange scale whenclusters= 'pseudotime' and not alllineagesare displayed: either 'absolute', where thecells.colorsrange is based on the highest pseudotime value among the displayedlineages, or 'relative', where thecells.colorsrange is based on the highest pseudotime value of all thelineages, including the non-displayed ones.- points.size
Numeric. The size of the cells.
- lineages.width
Numeric. The width of the lineage curves.
- lineages.arrow
An
arrowobject added at the end of the lineage curves. Use the function's parameters to modify its appearance. Set toNULLto remove the arrow.- knots.size
Numeric. The size of the knots on the lineage curves. Ignored if the
modelsobject is not provided.- cells.colors
Character. If
genesis provided, either two color names to use for the cells, corresponding to the lowest and highest values in the fitted GAM smoothers and internally passed toscale_color_gradient, or the name of a palette and internally passed toscale_color_viridis_c(such as 'turbo', 'inferno', 'magma', 'viridis' etc, check the function for all palettes available). Ifclustersis provided, the color names for each identity inclusters. IfNULL, uses Seurat's default colors. Ifclusters= 'pseudotime', the name of a palette and internally passed toscale_color_viridis_c. If neithergenesnorclustersare provided, the name of a color to use for all cells. IfNULL, defaults to 'lightgrey'.- na.color
Character. The name of a color to use for cells not participating in the
lineages(for example, if you have four lineages and you only plot lineages 1 and 3, the cells participating in lineages 2 and 4 will be colored withna.color). Set to 'transparent' to not display these cells.- show.na
Logical. If
FALSE, ignoresna.colorand colors all cells withcells.colors, even those not participating in thelineages.- lineages.colors
Character. either a single color name to use for all lineages, or the color names for each of the
lineagesdisplayed, or for the number oflineagestimes the number ofconditionsif themodelsobject was computed withconditions.- knots.colors
Character. either a single color name to use for all knots, or a vector of color names of length equal to the number of
lineages. Ignored if themodelsobject is not provided.- knots.labels.text.colors
Character. either a single color name to use for all knot labels, or a vector of color names of length equal to the number of
lineages. Ignored if themodelsobject is not provided or ifshow.knots.labels=FALSE.- knots.labels.fill.colors
Character. either a single color name to use for all knot label backgrounds, or a vector of color names of length equal to the number of
lineages. Ignored if themodelsobject is not provided or ifshow.knots.labels=FALSE.- axis.text.size
Numeric. The font size of the dimensionality reduction values.
- axis.title.size
Numeric. The font size of the axis title.
- plot.title.size
Numeric. The font size of the plot title.
- lineages.legend.names
Character. You may provide custom names for the lineages displayed in the legend. Ignored if
lineages.colorsis a single color.- legend.text.size
Numeric. The font size of the legend text.
- raster
Logical. If
TRUE, the cells will be rasterized usingrasterizeto reduce the size of the output file. The points may appear slightly blurry.