plotDots: Create a dot plot of expression values

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/plotDots.R

Description

Create a dot plot of expression values for a grouping of cells, where the size and color of each dot represents the proportion of detected expression values and the average expression, respectively, for each feature in each group of cells.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
plotDots(
  object,
  features,
  group = NULL,
  block = NULL,
  exprs_values = "logcounts",
  detection_limit = 0,
  low_color = "white",
  high_color = "red",
  max_ave = NULL,
  max_detected = NULL,
  other_fields = list(),
  by_exprs_values = exprs_values,
  swap_rownames = NULL
)

Arguments

object

A SingleCellExperiment object.

features

A character vector of feature names to show as rows of the dot plot.

group

Specification of a column metadata field to show as columns. Alternatively, an AsIs vector, see ?retrieveCellInfo for details.

block

Specification of a column metadata field containing the blocking factors, e.g., batch of origin for each cell. Alternatively, an AsIs vector, see ?retrieveCellInfo for details.

exprs_values

A string or integer scalar specifying which assay in assays(object) to obtain expression values from.

detection_limit

Numeric scalar providing the value above which observations are deemed to be expressed. This is also used as the

low_color

String specifying the color to use for low expression. This is also used as the background color, see Details.

high_color

String specifying the color to use for high expression.

max_ave

Numeric value specifying the cap on the average expression.

max_detected

Numeric value specifying the cap on the proportion of detected expression values.

other_fields

Additional feature-based fields to include in the data.frame, see ?"scater-plot-args" for details. Note that any AsIs vectors or data.frames must be of length equal to nrow(object), not features.

by_exprs_values

A string or integer scalar specifying which assay to obtain expression values from, to use when extracting values according to each entry of other_fields.

swap_rownames

Column name of rowData(object) to be used to identify features instead of rownames(object) when labelling plot elements.

Details

This implements a Seurat-style “dot plot” that creates a dot for each feature (row) in each group of cells (column). The proportion of detected expression values and the average expression for each feature in each group of cells is visualized efficiently using the size and colour, respectively, of each dot. If block is specified, batch-corrected averages for each group are computed with batchCorrectedAverages.

We impose two restrictions - the low end of the color scale must correspond to the detection limit, and the color at this end of the scale must be the same as the background color. These ensure that the visual cues from low average expression or low detected proportions are consistent, as both will result in a stronger low_color. (In the latter case, the reduced size of the dot means that the background color dominates.)

If these restrictions are violated, visualization can be misleading due to the difficulty of simultaneously interpreting both size and color. For example, if we colored by z-score on a conventional blue-white-red color axis, a gene that is downregulated in a group of cells would show up as a small blue dot. If the background color was also white, this might be mistaken for a gene that is not downregulated at all. On the other hand, any other background color would effectively require consideration of two color axes as expression decreases.

We can also cap the color and size scales at max_ave and max_detected, respectively. This aims to preserve resolution for low-abundance genes by preventing domination of the scales by high-abundance features.

Value

A ggplot object containing a dot plot.

Author(s)

Aaron Lun

See Also

plotExpression and plotHeatmap, for alternatives to visualizing group-level expression values.

Examples

1
2
3
4
5
6
sce <- mockSCE()
sce <- logNormCounts(sce)

plotDots(sce, features=rownames(sce)[1:10], group="Cell_Cycle")

plotDots(sce, features=rownames(sce)[1:10], group="Treatment", block="Cell_Cycle")

scater documentation built on Feb. 28, 2021, 2:01 a.m.