Plot reduced dimensions

plotReducedDim(object, ...)

plotPCA(object, ...)

plotTSNE(object, ...)

plotUMAP(object, ...)

# S4 method for SingleCellExperiment
plotReducedDim(object, reducedDim,
  dimsUse = c(1L, 2L), interestingGroups = NULL,
  color = getOption("acid.discrete.color", default = NULL),
  pointSize = getOption("acid.pointSize", default = 0.75),
  pointAlpha = getOption("acid.pointAlpha", default = 0.85),
  pointsAsNumbers = getOption("acid.pointsAsNumbers", default = FALSE),
  label = getOption("acid.label", default = TRUE),
  labelSize = getOption("acid.labelSize", default = 6L),
  dark = getOption("acid.dark", default = FALSE),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for Seurat
plotReducedDim(object, reducedDim, dimsUse = c(1L,
  2L), interestingGroups = NULL,
  color = getOption("acid.discrete.color", default = NULL),
  pointSize = getOption("acid.pointSize", default = 0.75),
  pointAlpha = getOption("acid.pointAlpha", default = 0.85),
  pointsAsNumbers = getOption("acid.pointsAsNumbers", default = FALSE),
  label = getOption("acid.label", default = TRUE),
  labelSize = getOption("acid.labelSize", default = 6L),
  dark = getOption("acid.dark", default = FALSE),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for SingleCellExperiment
plotTSNE(object, dimsUse = c(1L, 2L),
  interestingGroups = NULL, color = getOption("acid.discrete.color",
  default = NULL), pointSize = getOption("acid.pointSize", default =
  0.75), pointAlpha = getOption("acid.pointAlpha", default = 0.85),
  pointsAsNumbers = getOption("acid.pointsAsNumbers", default = FALSE),
  label = getOption("acid.label", default = TRUE),
  labelSize = getOption("acid.labelSize", default = 6L),
  dark = getOption("acid.dark", default = FALSE),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for Seurat
plotTSNE(object, dimsUse = c(1L, 2L),
  interestingGroups = NULL, color = getOption("acid.discrete.color",
  default = NULL), pointSize = getOption("acid.pointSize", default =
  0.75), pointAlpha = getOption("acid.pointAlpha", default = 0.85),
  pointsAsNumbers = getOption("acid.pointsAsNumbers", default = FALSE),
  label = getOption("acid.label", default = TRUE),
  labelSize = getOption("acid.labelSize", default = 6L),
  dark = getOption("acid.dark", default = FALSE),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for SingleCellExperiment
plotUMAP(object, dimsUse = c(1L, 2L),
  interestingGroups = NULL, color = getOption("acid.discrete.color",
  default = NULL), pointSize = getOption("acid.pointSize", default =
  0.75), pointAlpha = getOption("acid.pointAlpha", default = 0.85),
  pointsAsNumbers = getOption("acid.pointsAsNumbers", default = FALSE),
  label = getOption("acid.label", default = TRUE),
  labelSize = getOption("acid.labelSize", default = 6L),
  dark = getOption("acid.dark", default = FALSE),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for Seurat
plotUMAP(object, dimsUse = c(1L, 2L),
  interestingGroups = NULL, color = getOption("acid.discrete.color",
  default = NULL), pointSize = getOption("acid.pointSize", default =
  0.75), pointAlpha = getOption("acid.pointAlpha", default = 0.85),
  pointsAsNumbers = getOption("acid.pointsAsNumbers", default = FALSE),
  label = getOption("acid.label", default = TRUE),
  labelSize = getOption("acid.labelSize", default = 6L),
  dark = getOption("acid.dark", default = FALSE),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for SingleCellExperiment
plotPCA(object, dimsUse = c(1L, 2L),
  interestingGroups = NULL, color = getOption("acid.discrete.color",
  default = NULL), pointSize = getOption("acid.pointSize", default =
  0.75), pointAlpha = getOption("acid.pointAlpha", default = 0.85),
  pointsAsNumbers = getOption("acid.pointsAsNumbers", default = FALSE),
  label = getOption("acid.label", default = TRUE),
  labelSize = getOption("acid.labelSize", default = 6L),
  dark = getOption("acid.dark", default = FALSE),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for Seurat
plotPCA(object, dimsUse = c(1L, 2L),
  interestingGroups = NULL, color = getOption("acid.discrete.color",
  default = NULL), pointSize = getOption("acid.pointSize", default =
  0.75), pointAlpha = getOption("acid.pointAlpha", default = 0.85),
  pointsAsNumbers = getOption("acid.pointsAsNumbers", default = FALSE),
  label = getOption("acid.label", default = TRUE),
  labelSize = getOption("acid.labelSize", default = 6L),
  dark = getOption("acid.dark", default = FALSE),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

Arguments

object

Object.

reducedDim

character(1). Name of reduced dimension matrix slotted in reducedDims(). Includes TNSE, UMAP, PCA, for example.

dimsUse

integer. Vector of length 2 that denotes the columns from the reduced dimension matrix to use for centerX and centerY column calculations. Defaults the first and second dimensions.

interestingGroups

character. Groups of interest that define the samples. If left unset, defaults to sampleName.

color

ScaleDiscrete. Desired ggplot2 color scale. Must supply discrete values. When set NULL, the default ggplot2 color palette will be used. If manual color definitions are desired, we recommend using ggplot2::scale_color_manual().

To set the discrete color palette globally, use:

options(acid.color.discrete = ggplot2::scale_color_viridis_d())
pointSize

numeric(1). Point size for dots in the plot.

pointAlpha

numeric(1) (0-1). Alpha transparency level. Useful when there many points in the dataset (e.g. single-cell data), and some points can be masked.

pointsAsNumbers

logical(1). Plot the points as numbers (TRUE) or dots (FALSE).

label

logical(1). Superimpose sample text labels on the plot.

labelSize

integer(1). Size of the text label.

dark

logical(1). Plot against a dark background using the theme_midnight() ggplot2 theme.

legend

logical(1). Show plot legend.

title

character(1). Plot title.

...

Additional arguments.

Value

ggplot.

Details

Colors using ident column defined in colData() by default.

Reduction types

  • PCA: Principal Component Analysis.

  • t-SNE: t-distributed Stochastic Neighbor Embedding.

  • UMAP: Uniform Manifold Approximation and Projection.

UMAP calculation

UMAP calculation in R requires the Python module umap-learn.

We recommend installing this with conda:

conda install -c conda-forge umap-learn

The UMAP module can be loaded in R using reticulate. Reticulate works reliably when setting RETICULATE_PYTHON to point to your conda python binary. Export this variable in ~/.Renviron.

See Sys.getenv for details on the R system environment.

See also

Examples

data(seurat) object <- seurat ## t-SNE plotTSNE(object)
plotTSNE(object, pointsAsNumbers = TRUE, dark = TRUE, label = FALSE)
#> Increase pointSize to 4.
## UMAP plotUMAP(object)
## PCA plotPCA(object)