getVarianceExplained: Per-gene variance explained by a variable

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

Description

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

Usage

1
2
3
4
5
6
7
getVarianceExplained(x, ...)

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

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

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.

exprs_values

String or integer scalar specifying the expression values for which to compute the variance.

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

1
2
3
4
example_sce <- mockSCE()
example_sce <- logNormCounts(example_sce)

r2mat <- getVarianceExplained(example_sce)

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