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.
Arguments passed on to .ggplotLigerTheme
title,subtitle,xlab,ylabMain title, subtitle or X/Y axis title text.
By default, no main title or subtitle will be set, and X/Y axis title will be
the names of variables used for plotting. Use NULL to hide elements.
TRUE for xlab or ylab shows default values.
showLegendWhether to show the legend. Default TRUE.
legendPositionText indicating where to place the legend. Choose from
"top", "bottom", "left" or "right". Default
"right".
baseSizeOne-parameter control of all text sizes. Individual text element sizes can be controlled by other size arguments. "Title" sizes are 2 points larger than "text" sizes when being controlled by this.
titleSize,xTitleSize,yTitleSize,legendTitleSizeSize of main title,
axis titles and legend title. Default NULL controls by
baseSize + 2.
subtitleSize,xTextSize,yTextSize,legendTextSizeSize of subtitle text,
axis texts and legend text. Default NULL controls by baseSize.
panelBorderWhether to show rectangle border of the panel instead of
using ggplot classic bottom and left axis lines. Default FALSE.
plotlyWhether to use plotly to enable web based interactive browsing
for the plot. Requires installation of package "plotly". Default
FALSE.
# Example dataset has small number of cells, thus cutoff adjusted.
plotDensityDimRed(pbmcPlot, minDensity = 1)
Run the code above in your browser using DataLab