This function allows for using available cell metadata to build
the x-/y-axis. Available per-cell data can be used to form the color/shape
annotation, including cell metadata, raw or processed gene expression, and
unnormalized or aligned factor loading. Multiple coloring variable is allowed
from the same specification of slot
, and this returns a list of plots
with different coloring values. Users can further split the plot(s) by
grouping on cells (e.g. datasets).
some text
Usage
plotDimRed(
object,
colorBy = NULL,
useDimRed = NULL,
slot = c("cellMeta", "rawData", "normData", "scaleData", "H.norm", "H", "normPeak",
"rawPeak"),
colorByFunc = NULL,
cellIdx = NULL,
splitBy = NULL,
shapeBy = NULL,
titles = NULL,
...
)
plotClusterDimRed(object, useCluster = NULL, useDimRed = NULL, ...)
plotDatasetDimRed(object, useDimRed = NULL, ...)
plotByDatasetAndCluster(
object,
useDimRed = NULL,
useCluster = NULL,
combinePlots = TRUE,
...
)
plotGeneDimRed(
object,
features,
useDimRed = NULL,
log = TRUE,
scaleFactor = 10000,
zeroAsNA = TRUE,
colorPalette = "C",
...
)
plotPeakDimRed(
object,
features,
useDimRed = NULL,
log = TRUE,
scaleFactor = 10000,
zeroAsNA = TRUE,
colorPalette = "C",
...
)
plotFactorDimRed(
object,
factors,
useDimRed = NULL,
trimHigh = 0.03,
zeroAsNA = TRUE,
colorPalette = "D",
...
)
Arguments
- object
A liger object.
- colorBy
Available variable name in specified
slot
to look for color annotation information. See details. DefaultNULL
generates all-black dots.- useDimRed
Name of the variable storing dimensionality reduction result in the
cellMeta(object)
. DefaultNULL
use default dimRed.- slot
Choose the slot to find the
colorBy
variable. See details. Default"cellMeta"
.- colorByFunc
Default
NULL
. A function object that expects a vector/factor/data.frame retrieved bycolorBy
as the only input, and returns an object of the same size, so that the all color "aes" are replaced by this output. Useful when, for example, users need to scale the gene expression shown on plot.- cellIdx
Character, logical or numeric index that can subscribe cells. Missing or
NULL
for all cells.- splitBy
Character vector of categorical variable names in
cellMeta
slot. Split all cells by groupings on this/these variable(s) to produce a scatter plot containing only the cells in each group. DefaultNULL
.- shapeBy
Available variable name in
cellMeta
slot to look for categorical annotation to be reflected by dot shapes. DefaultNULL
.- titles
Title text. A character scalar or a character vector with as many elements as multiple plots are supposed to be generated. Default
NULL
.- ...
More plot setting arguments. See
.ggScatter
and.ggplotLigerTheme
.- useCluster
Name of variable in
cellMeta(object)
. DefaultNULL
uses default cluster.- combinePlots
Logical, whether to utilize
plot_grid
to combine multiple plots into one. DefaultTRUE
returns combined ggplot.FALSE
returns a list of ggplot.- features, factors
Name of genes or index of factors that need to be visualized.
- log
Logical. Whether to log transform the normalized expression of genes. Default
TRUE
.- scaleFactor
Number to be multiplied with the normalized expression of genes before log transformation. Default
1e4
.NULL
for not scaling.- zeroAsNA
Logical, whether to swap all zero values to
NA
sonaColor
will be used to represent non-expressing features. DefaultTRUE
.- colorPalette
Name of viridis palette. See
viridis
for options. Default"C"
("plasma") for gene expression and"D"
("viridis") for factor loading.- trimHigh
Number for highest cut-off to limit the outliers. Factor loading above this value will all be trimmed to this value. Default
0.03
.
Value
A ggplot object when a single plot is intended. A list of ggplot
objects, when multiple colorBy
variables and/or splitBy
are
set. When plotly = TRUE
, all ggplot objects become plotly (htmlwidget)
objects.
ggplot object when only one feature (e.g. cluster variable, gene, factor) is set. List object when multiple of those are specified.
Details
Available option for slot
include: "cellMeta"
,
"rawData"
, "normData"
, "scaleData"
, "H.norm"
and "H"
. When "rawData"
, "normData"
or
"scaleData"
, colorBy
has to be a character vector of feature
names. When "H.norm"
or "H"
, colorBy
can be any valid
index to select one factor of interests. Note that character index follows
"Factor_[k]"
format, with replacing [k]
with an integer.
When "cellMeta"
, colorBy
has to be an available column name in
the table. Note that, for colorBy
as well as x
, y
,
shapeBy
and splitBy
, since a matrix object is feasible in
cellMeta
table, using a column (e.g. named as "column1"
in a
certain matrix (e.g. named as "matrixVar"
) should follow the syntax of
"matrixVar.column1"
. When the matrix does not have a "colname"
attribute, the subscription goes with "matrixVar.V1"
,
"matrixVar.V2"
and etc. Use "UMAP.1"
, "UMAP.2"
,
"TSNE.1"
or "TSNE.2"
for the 2D embeddings generated with
rliger package. These are based on the nature of as.data.frame
method
on a DataFrame
object.
See also
Please refer to plotDimRed
,
.ggScatter
, .ggplotLigerTheme
for additional
graphic setting
Examples
plotDimRed(pbmcPlot, colorBy = "dataset", slot = "cellMeta",
labelText = FALSE)
#> ℹ Plotting feature "dataset" on 600 cells
#> ✔ Plotting feature "dataset" on 600 cells ... done
#>
plotDimRed(pbmcPlot, colorBy = "S100A8", slot = "normData",
dotOrder = "ascending", dotSize = 2)
#> ℹ Plotting feature "S100A8" on 600 cells
#> ✔ Plotting feature "S100A8" on 600 cells ... done
#>
plotDimRed(pbmcPlot, colorBy = 2, slot = "H.norm",
dotOrder = "ascending", dotSize = 2, colorPalette = "viridis")
#> ℹ Plotting feature "Factor_2" on 600 cells
#> ✔ Plotting feature "Factor_2" on 600 cells ... done
#>
plotClusterDimRed(pbmcPlot)
#> ℹ Plotting feature "leiden_cluster" on 600 cells
#> ✔ Plotting feature "leiden_cluster" on 600 cells ... done
#>
plotDatasetDimRed(pbmcPlot)
#> ℹ Plotting feature "dataset" on 600 cells
#> ✔ Plotting feature "dataset" on 600 cells ... done
#>
plotByDatasetAndCluster(pbmcPlot)
#> ℹ Plotting feature "dataset" on 600 cells
#> ✔ Plotting feature "dataset" on 600 cells ... done
#>
#> ℹ Plotting feature "leiden_cluster" on 600 cells
#> ✔ Plotting feature "leiden_cluster" on 600 cells ... done
#>
plotGeneDimRed(pbmcPlot, varFeatures(pbmcPlot)[1])
#> ℹ Plotting feature "ISG15" on 600 cells
#> ✔ Plotting feature "ISG15" on 600 cells ... done
#>
plotFactorDimRed(pbmcPlot, 2)
#> ℹ Plotting feature "Factor_2" on 600 cells
#> ✔ Plotting feature "Factor_2" on 600 cells ... done
#>