Simple visualization of spatial coordinates. See example code for how to have information preset in the object. Arguments to the liger object method are passed down to ligerDataset method.
plotSpatial2D(object, ...)# S3 method for liger
plotSpatial2D(object, dataset, useCluster = NULL, legendColorTitle = NULL, ...)
# S3 method for ligerSpatialDataset
plotSpatial2D(
object,
useCluster = NULL,
legendColorTitle = NULL,
useDims = c(1, 2),
xlab = NULL,
ylab = NULL,
labelText = FALSE,
panelBorder = TRUE,
...
)
A ggplot object
Either a liger object containing a spatial dataset or a ligerSpatialDataset object.
Arguments passed on to .ggScatter
, .ggplotLigerTheme
dotOrder
Controls the order that each dot is added to the plot. Choose
from "shuffle"
, "ascending"
, or "descending"
. Default
"shuffle"
, useful when coloring by categories that overlaps (e.g.
"dataset"), "ascending"
can be useful when coloring by a continuous
variable (e.g. gene expression) where high values needs more
highlight. NULL
use default order.
dotSize,dotAlpha
Numeric, controls the size or transparency of all
dots. Default getOption("ligerDotSize")
(1) and 0.9
.
raster
Logical, whether to rasterize the plot. Default NULL
automatically rasterize the plot when number of total dots to be plotted
exceeds 100,000.
labelTextSize
Numeric, controls the size of label size when
labelText = TRUE
. Default 4
.
seed
Random seed for reproducibility. Default 1
.
showLegend
Whether to show the legend. Default TRUE
.
legendPosition
Text indicating where to place the legend. Choose from
"top"
, "bottom"
, "left"
or "right"
. Default
"right"
.
baseSize
One-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,legendTitleSize
Size of main title,
axis titles and legend title. Default NULL
controls by
baseSize + 2
.
subtitleSize,xTextSize,yTextSize,legendTextSize
Size of subtitle text,
axis texts and legend text. Default NULL
controls by baseSize
.
legendDotSize
Allow dots in legend region to be large enough to see
the colors/shapes clearly. Default 4
.
colorLabels
Character vector for modifying category names in a
color legend. Passed to ggplot2::scale_color_manual(labels)
. Default
NULL
uses original levels of the factor.
colorValues
Character vector of colors for modifying category colors
in a color legend. Passed to ggplot2::scale_color_manual(values)
.
Default NULL
uses internal selected palette when <= 26 categories are
presented, otherwise ggplot hues.
legendNRow,legendNCol
Integer, when too many categories in one
variable, arranges number of rows or columns. Default NULL
,
automatically split to ceiling(levels(variable)/15)
columns.
naColor
The color code for NA
values. Default "#DEDEDE"
.
scale_colour_gradient2
. Default NULL
.
Name of one spatial dataset.
Either the name of one variable in cellMeta(object)
or a factor object with annotation that matches with all cells in the
specified dataset. Default NULL
uses default clusters.
Alternative title text in the legend. Default
NULL
uses the variable name set by useCluster
, or
"Annotation"
is useCluster
is a customized factor object.
Numeric vector of two, choosing the coordinates to be drawn
on 2D space. (STARmap data could have 3 dimensions.) Default c(1, 2)
.
Text label on x-/y-axis. Default NULL
does not show
it.
Logical, whether to label annotation onto the scatter plot.
Default FALSE
.
Whether to show rectangle border of the panel instead of
using ggplot classic bottom and left axis lines. Default TRUE
.
ctrl.fake.spatial <- as.ligerDataset(dataset(pbmc, "ctrl"), modal = "spatial")
fake.coords <- matrix(rnorm(2 * ncol(ctrl.fake.spatial)), ncol = 2)
coordinate(ctrl.fake.spatial) <- fake.coords
dataset(pbmc, "ctrl") <- ctrl.fake.spatial
defaultCluster(pbmc) <- pbmcPlot$leiden_cluster
plotSpatial2D(pbmc, dataset = "ctrl")
Run the code above in your browser using DataLab