getExplanatoryPCs {scater}R Documentation

Estimate the percentage of variance explained for each gene.

Description

Estimate the percentage of variance explained for each gene.

Usage

getExplanatoryPCs(object, variables = NULL, use_dimred = "PCA",
  chunk = 1000, ...)

Arguments

object

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

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.

use_dimred

String specifying the field in reducedDims(object) that contains the PCA results.

chunk

Argument passed to getVarianceExplained.

...

Arguments passed to runPCA.

Details

This function computes the percentage of variance in PC scores that is explained by variables in the sample-level metadata. It allows identification of important PCs that are driven by known experimental conditions, e.g., treatment, disease. PCs correlated with echnical factors (e.g., batch effects, library size) can also be detected and removed prior to further analysis.

The function will attempt to extract existing PCA results in object via the use_dimred argument. If these are not available, it will rerun the PCA using runPCA.

Value

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

Author(s)

Aaron Lun

See Also

plotExplanatoryPCs, getVarianceExplained

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 <- getExplanatoryPCs(example_sce)

[Package scater version 1.10.1 Index]