Visualize gene markers on a reduced dimension plot (e.g. t-SNE, UMAP).

plotMarker(object, ...)

# S4 method for SingleCellExperiment
plotMarker(object, genes,
  reducedDim = "TSNE", expression = c("mean", "sum"),
  color = getOption("acid.continuous.color", default =
  ggplot2::scale_colour_gradient(low = "gray75", high = "purple")),
  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 = TRUE)

# S4 method for Seurat
plotMarker(object, genes, reducedDim = "TSNE",
  expression = c("mean", "sum"),
  color = getOption("acid.continuous.color", default =
  ggplot2::scale_colour_gradient(low = "gray75", high = "purple")),
  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 = TRUE)

Arguments

object

Object.

genes

character. Gene identifiers. It is considered better practice to input the stable gene identifiers from Ensembl (e.g. "ENSG00000000003") and not the (HGNC) gene symbols (e.g. "TSPN6"), if possible.

reducedDim

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

expression

character(1). Calculation to apply. Uses match.arg() internally and defaults to the first argument in the character vector.

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

Show graphical output. Invisibly return a ggplot list.

Examples

data(seurat) object <- seurat title <- "most abundant genes" genes <- counts(object) %>% Matrix::rowSums(.) %>% sort(decreasing = TRUE) %>% head(n = 4L) %>% names() str(genes)
#> chr [1:4] "LYZ" "HLA-DRA" "CST3" "HLA-DPB1"
## Default appearance. plotMarker(object, genes = genes[[1L]])
## Dark mode with viridis palette. plotMarker( object = object, genes = genes, expression = "mean", pointsAsNumbers = TRUE, color = ggplot2::scale_color_viridis_c(), dark = TRUE, label = FALSE, title = title )