plotVarianceVsMean: Plot logcounts variance against logcounts mean

View source: R/func_sc.R

plotVarianceVsMeanR Documentation

Plot logcounts variance against logcounts mean

Description

This function calculates the per-feature mean and variance using normalised counts (accessible via logcounts()) from a SingleCellExperiment object, and returns a logcounts mean-variance scatter plot.

Usage

plotVarianceVsMean(
  sce,
  top_n = 5,
  point_size = 2,
  point_alpha = 0.8,
  text_size = 4,
  text_color = "black",
  box.padding = 0.5,
  max.overlaps = Inf,
  seed = 12321,
  xlab = "Mean log-counts",
  ylab = "Variance of log-counts",
  title = NULL,
  theme_size = 18,
  ...
)

Arguments

sce

A SingleCellExperiment object containing the required QC metrics returned by addPerCellQC()/perFeatureQCMetrics().

top_n

An integer scalar indicating the first top_n genes with the highest calculated mean to label. Default is 5.

point_size

A numeric scalar indicating the size of the points. Default is 2.

point_alpha

A numeric scalar (between 0 and 1) indicating the transparency. Default is 0.8.

text_size

A numeric scalar indicating the size of the label. This is passed to geom_text_repel(). Default is 4.

text_color

A string indicating the colour of the label. This is passed to geom_text_repel(). Default is "black".

box.padding

A scalar indicating the amount of padding around bounding box, as unit or number. This is passed to geom_text_repel(). Default is 0.5.

max.overlaps

Exclude text labels that overlap too many things. This is passed to geom_text_repel(). Default is Inf.

seed

Random seed passed to set.seed(). This is passed to geom_text_repel(). Default is 12321.

xlab

The title of the x-axis. Default is "Mean log-counts".

ylab

The title of the y-axis. Default is "Variance of log-counts".

title

Plot title. Default is NULL.

theme_size

A numeric scalar indicating the base font size. Default is 18.

...

Other arguments passed on to geom_text_repel().

Details

When the rowData slot of the SingleCellExperiment input contains QC metrics for features that were returned by addPerCellQC() or perFeatureQCMetrics(), this function will use detected (percentage of expressed features above the detection limit) to calculate pct_dropout (percentage of dropouts) and colour the points accordingly.

Value

A ggplot object

Author(s)

I-Hsuan Lin

See Also

scater::plotRowData(), scuttle::logNormCounts(), scuttle::calculateCPM(), ggrepel::geom_text_repel()

Examples

library(SingleCellExperiment)

# Load demo dataset
data(sce)

plotVarianceVsMean(sce, title = "logcounts mean-variance plot")

ycl6/scRUtils documentation built on Feb. 18, 2025, 6:14 a.m.