getExplanatoryPCs {scater} | R Documentation |
Estimate the percentage of variance explained for each PC.
getExplanatoryPCs(object, use_dimred = "PCA", ncomponents = 10, rerun = FALSE, run_args = list(), ...)
object |
A SingleCellExperiment object containing expression values and per-cell experimental information. |
use_dimred |
String specifying the field in |
ncomponents |
Integer scalar specifying the number of the top principal components to use. |
rerun |
Logical scalar indicating whether the PCA should be repeated, even if pre-computed results are already present. |
run_args |
A named list of arguments to pass to |
... |
Additional arguments passed to |
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 technical factors (e.g., batch effects, library size) can also be detected and removed prior to further analysis.
By default, the function will attempt to use pre-computed PCA results in object
.
This is done by taking the top ncomponents
PCs from the matrix identified by use_dimred
.
If these are not available or if rerun=TRUE
, the function will rerun the PCA using runPCA
.
A matrix containing the percentage of variance explained by each factor (column) and for each PC (row).
Aaron Lun
plotExplanatoryPCs
,
getVarianceExplained
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)