getVarianceExplained: Per-gene variance explained by a variable

getVarianceExplainedR Documentation

Per-gene variance explained by a variable

Description

Compute, for each gene, the percentage of variance that is explained by one or more variables of interest.

Usage

getVarianceExplained(x, ...)

## S4 method for signature 'ANY'
getVarianceExplained(x, variables, subset_row = NULL, BPPARAM = SerialParam())

## S4 method for signature 'SummarizedExperiment'
getVarianceExplained(
  x,
  variables = NULL,
  ...,
  exprs_values = "logcounts",
  assay.type = exprs_values
)

Arguments

x

A numeric matrix of expression values, usually log-transformed and normalized.

Alternatively, a SummarizedExperiment containing such a matrix.

...

For the generic, arguments to be passed to specific methods. For the SummarizedExperiment method, arguments to be passed to the ANY method.

variables

A DataFrame or data.frame containing one or more variables of interest. This should have number of rows equal to the number of columns in x.

For the SummarizedExperiment method, this can also be a character vector specifying column names of colData(x) to use; or NULL, in which case all columns in colData(x) are used.

subset_row

A vector specifying the subset of rows of x for which to return a result.

BPPARAM

A BiocParallelParam object specifying whether the calculations should be parallelized.

exprs_values

Alias for assay.type.

assay.type

String or integer scalar specifying the expression values for which to compute the variance (also an alias exprs_value is accepted).

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 numeric matrix containing the percentage of variance explained by each factor (column) and for each gene (row).

Author(s)

Aaron Lun

See Also

getExplanatoryPCs, which calls this function.

plotExplanatoryVariables, to plot the results.

Examples

example_sce <- mockSCE()
example_sce <- logNormCounts(example_sce)

r2mat <- getVarianceExplained(example_sce)

Alanocallaghan/scater documentation built on July 18, 2024, 10:58 p.m.