getVarianceExplained {scater} | R 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, chunk = 1000)

    ## 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.
`chunk` | Integer scalar specifying the chunk size for chunk-wise processing. Only affects the speed/memory usage trade-off.
`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

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

    r2mat <- getVarianceExplained(example_sce)

[Package scater version 1.16.2 Index]