Visualize genes on a dot or violin plot.

plotCounts(object, ...)

plotDot(object, ...)

plotViolin(object, ...)

# S4 method for SingleCellExperiment
plotCounts(object, genes,
  geom = c("dot", "violin"), perSample = TRUE,
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for Seurat
plotCounts(object, genes, geom = c("dot", "violin"),
  perSample = TRUE, legend = getOption("acid.legend", default = TRUE),
  title = NULL)

# S4 method for SingleCellExperiment
plotDot(object, genes, perSample = TRUE,
  colMin = -2.5, colMax = 2.5, dotMin = 0L, dotScale = 6L,
  color = getOption("acid.continuous.color", default =
  ggplot2::scale_colour_gradient2(low = "orange", mid = "gray75", high =
  "purple", midpoint = 0L)), legend = getOption("acid.legend", default =
  TRUE), title = NULL)

# S4 method for Seurat
plotDot(object, genes, perSample = TRUE,
  colMin = -2.5, colMax = 2.5, dotMin = 0L, dotScale = 6L,
  color = getOption("acid.continuous.color", default =
  ggplot2::scale_colour_gradient2(low = "orange", mid = "gray75", high =
  "purple", midpoint = 0L)), legend = getOption("acid.legend", default =
  TRUE), title = NULL)

# S4 method for SingleCellExperiment
plotViolin(object, genes,
  perSample = TRUE, scale = c("count", "width", "area"),
  color = getOption("acid.discrete.color", default = NULL),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

# S4 method for Seurat
plotViolin(object, genes, perSample = TRUE,
  scale = c("count", "width", "area"),
  color = getOption("acid.discrete.color", default = NULL),
  legend = getOption("acid.legend", default = TRUE), title = NULL)

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.

geom

character(1). Plot type. Uses match.arg() to pick the type. Currently supports "dot" and "violin".

perSample

logical(1). Visualize the distributions per sample.

legend

logical(1). Show plot legend.

title

character(1). Plot title.

colMin

numeric(1). Minimum scaled average expression threshold. Everything smaller will be set to this.

colMax

numeric(1). Maximum scaled average expression threshold. Everything larger will be set to this.

dotMin

numeric(1). The fraction of cells at which to draw the smallest dot. All cell groups with less than this expressing the given gene will have no dot drawn.

dotScale

numeric(1). Scale the size of the points, similar to cex.

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())
scale

character(1). Whether the values should be centered and scaled in either the row or column direction ("row", "column"), or remain unscaled ("none").

...

Additional arguments.

Value

ggplot.

See also

Examples

data(seurat) object <- seurat ## Plotting with either gene IDs or gene names (symbols) works. geneIDs <- head(rownames(object), n = 4L) print(geneIDs)
#> [1] "MS4A1" "CD79B" "CD79A" "HLA-DRA"
geneNames <- head(as.character(rowRanges(object)$geneName), n = 4L) print(geneNames)
#> [1] "MS4A1" "CD79B" "CD79A" "HLA-DRA"
## Per sample mode enabled. plotDot(object, genes = geneNames, perSample = TRUE)
plotViolin(object, genes = geneNames, perSample = TRUE)
## Per sample mode disabled. plotDot(object, genes = geneIDs, perSample = FALSE)
plotViolin(object, genes = geneIDs, perSample = FALSE)