Plot cell-level dimensionality reduction.

plotReducedDim(object, ...)

plotPCA(object, ...)

plotTSNE(object, ...)

plotUMAP(object, ...)

# S4 method for SingleCellExperiment
plotReducedDim(object,
  reduction = "UMAP", dims = 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, reduction = "UMAP",
  dims = 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 cell_data_set
plotReducedDim(object, reduction = "UMAP",
  dims = 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, dims = 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, dims = 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 cell_data_set
plotTSNE(object, dims = 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, dims = 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, dims = 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 cell_data_set
plotUMAP(object, dims = 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, dims = 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, dims = 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 cell_data_set
plotPCA(object, dims = 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.

reduction

vector(1). Dimension reduction name or index position.

dims

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 to use for visualization. Corresponds to factors describing the columns of the object.

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. In the range of 1-3 is generally recommended.

pointAlpha

numeric(1) (0-1). Alpha transparency level.

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 acid_theme_light() ggplot2 theme.

legend

logical(1). Include plot legend.

title

character(1). Title.

...

Additional arguments.

Value

ggplot.

Details

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

Note

Updated 2019-08-02.

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. The UMAP module can be loaded in R using reticulate.

See also

Examples

data( Seurat, cell_data_set, package = "acidtest" ) ## Seurat ==== object <- Seurat plotReducedDim(object, reduction = "UMAP")
## cell_data_set ==== object <- cell_data_set plotReducedDim(object, reduction = "UMAP")