getVarianceExplained {scater}R Documentation

Estimate the percentage of variance explained for each gene.

Description

Estimate the percentage of variance explained for each gene.

Usage

getVarianceExplained(object, exprs_values = "logcounts",
  variables = NULL, chunk = 1000)

Arguments

object

A SingleCellExperiment object containing expression values and per-cell experimental information.

exprs_values

String specifying the expression values for which to compute the variance.

variables

Character vector specifying the explanatory factors in colData(object) to use. Default is NULL, in which case all variables in colData(object) are considered.

chunk

Integer scalar specifying the chunk size for chunk-wise processing. Only affects the speed/memory usage trade-off.

Details

This function computes the percentage of variance in gene expression that is explained by variables in the sample-level metadata. It allows problematic factors to be quickly identified, as well as the genes that are most affected.

Value

A matrix containing the percentage of variance explained by each factor (column) and for each gene (row).

Author(s)

Aaron Lun

See Also

plotExplanatoryVariables

Examples

data("sc_example_counts")
data("sc_example_cell_info")
example_sce <- SingleCellExperiment(
    assays = list(counts = sc_example_counts), 
    colData = sc_example_cell_info)
example_sce <- normalize(example_sce)

r2mat <- getVarianceExplained(example_sce)

[Package scater version 1.10.1 Index]