This function shows the cell density presented in a 2D
dimensionality reduction coordinates. Density is shown with coloring and
contour lines. A scatter plot of the dimensionality reduction is added as
well. The density plot can be splitted by categorical variables (e.g.
"dataset"
), while the scatter plot will always be shown for all cells
in subplots as a reference of the global structure.
plotDensityDimRed(
object,
useDimRed = NULL,
splitBy = NULL,
combinePlot = TRUE,
minDensity = 8,
contour = TRUE,
contourLineWidth = 0.3,
contourBins = 5,
dot = TRUE,
dotColor = "grey",
dotSize = 0.6,
dotAlpha = 0.3,
dotRaster = NULL,
title = NULL,
legendFillTitle = "Density",
colorPalette = "magma",
colorDirection = -1,
...
)
A ggplot object when only one plot is generated, A ggplot object
combined with plot_grid
when multiple plots and
combinePlot = TRUE
. A list of ggplot when multiple plots and
combinePlot = FALSE
.
A liger object
Name of the variable storing dimensionality reduction result
in the cellMeta
slot. Default uses default dimension reduction.
Character vector of categorical variable names in
cellMeta
slot. Split all cells by groupings on this/these variable(s)
to produce a density plot containing only the cells in each group. Default
NULL
.
Logical, whether to utilize
plot_grid
to combine multiple plots into one. Default
TRUE
returns combined ggplot. FALSE
returns a list of ggplot
or a single ggplot when only one plot is requested.
A positive number to filter out low density region colored
on plot. Default 8
. Setting zero will show density on the whole panel.
Logical, whether to draw the contour line. Default
TRUE
.
Numeric, the width of the contour line. Default
0.3
.
Number of contour bins. Higher value generates more
contour lines. Default 5
.
Logical, whether to add scatter plot of all cells, even when
density plot is splitted with splitBy
. Default TRUE
.
Numeric, controls the appearance of all
dots. Default "grey"
, 0.6
and 0.3
, respectively.
Logical, whether to rasterize the scatter plot. Default
NULL
automatically rasterizes the dots when number of total cells to
be plotted exceeds 100,000.
Text of main title of the plots. Default NULL
. Length
of character vector input should match with number of plots generated.
Text of legend title. Default "Density"
.
Name of the option for
scale_fill_viridis_c
. Default "magma"
.
Color gradient direction for
scale_fill_viridis_c
. Default -1
.
More theme setting arguments passed to
.ggplotLigerTheme
.
# Example dataset has small number of cells, thus cutoff adjusted.
plotDensityDimRed(pbmcPlot, minDensity = 1)
Run the code above in your browser using DataLab