calculatePCA {scater} | R Documentation |
Perform a principal components analysis (PCA) on cells, based on the expression data in a SingleCellExperiment object.
calculatePCA(x, ...) ## S4 method for signature 'ANY' calculatePCA(x, ncomponents = 50, ntop = 500, subset_row = NULL, feature_set = NULL, scale = FALSE, scale_features = NULL, transposed = FALSE, BSPARAM = bsparam(), BPPARAM = SerialParam()) ## S4 method for signature 'SummarizedExperiment' calculatePCA(x, ..., exprs_values = "logcounts") ## S4 method for signature 'SingleCellExperiment' calculatePCA(x, ..., exprs_values = "logcounts", dimred = NULL, use_dimred = NULL, n_dimred = NULL) ## S4 method for signature 'SingleCellExperiment' runPCA(x, ..., use_coldata = FALSE, altexp = NULL, name = "PCA")
x |
For For |
... |
For the For |
ncomponents |
Numeric scalar indicating the number of principal components to obtain. |
ntop |
Numeric scalar specifying the number of features with the highest variances to use for PCA, see |
subset_row |
Vector specifying the subset of features to use for PCA, see |
feature_set |
Deprecated, same as |
scale |
Logical scalar, should the expression values be standardised? See |
scale_features |
Deprecated, same as |
transposed |
Logical scalar, is |
BSPARAM |
A BiocSingularParam object specifying which algorithm should be used to perform the PCA. |
BPPARAM |
A BiocParallelParam object specifying whether the PCA should be parallelized. |
exprs_values |
Integer scalar or string indicating which assay of |
dimred |
String or integer scalar specifying the existing dimensionality reduction results to use, see |
use_dimred |
Deprecated, same as |
n_dimred |
Integer scalar or vector specifying the dimensions to use if |
use_coldata |
Deprecated, use |
altexp |
String or integer scalar specifying an alternative experiment to use to compute the PCA, see |
name |
String specifying the name to be used to store the result in the |
Fast approximate SVD algorithms like BSPARAM=IrlbaParam()
or RandomParam()
use a random initialization, after which they converge towards the exact PCs.
This means that the result will change slightly across different runs.
For full reproducibility, users should call set.seed
prior to running runPCA
with such algorithms.
(Note that this includes BSPARAM=bsparam()
, which uses approximate algorithms by default.)
A SingleCellExperiment object containing the first ncomponents
principal coordinates for each cell.
By default, this is stored in the "PCA"
entry of the reducedDims
.
The proportion of variance explained by each PC is stored as a numeric vector in the "percentVar"
attribute of the reduced dimension matrix.
Aaron Lun, based on code by Davis McCarthy
runPCA
, for the underlying calculations.
plotPCA
, to conveniently visualize the results.
?"scater-red-dim-args"
, for a full description of various options.
example_sce <- mockSCE() example_sce <- logNormCounts(example_sce) example_sce <- runPCA(example_sce, scale_features=NULL) reducedDimNames(example_sce) head(reducedDim(example_sce))