Perform principal component analysis (PCA). These functions are wrappers
for scater::calculatePCA.
getPCA(x, ...)
addPCA(x, ...)
# S4 method for class 'SingleCellExperiment'
addPCA(x, name = "PCA", ...)
# S4 method for class 'SingleCellExperiment'
getPCA(x, assay.type = "counts", ...)a SummarizedExperiment object.
additional arguments passed to
scater::calculatePCA.
ntop: Numeric scalar. Number of the most variable
features used. (Default: Inf)
Character scalar. A name for the reducedDim()
where results will be stored. (Default: "PCA")
Character scalar. Specifies the name of assay
used in calculation. (Default: "counts")
getPCA returns PCA results.
addPCA returns x with PCA results added to its
reducedDim(x, name).
These functions are wrappers for
scater::calculatePCA and
scater::runPCA. While getPCA
returns the results, addPCA adds them to reducedDim(x).
Unlike scater::calculatePCA, which uses the 500 most variable
features by default, these functions use all features (ntop = Inf).
See scater::calculatePCA for details.
library(mia)
library(scater)
data(GlobalPatterns)
tse <- GlobalPatterns
# Calculate PCA from CLR-transformed abundances
tse <- transformAssay(tse, method = "clr", pseudocount = TRUE)
#> A pseudocount of 0.5 was applied.
tse <- addPCA(tse, assay.type = "clr")
#> Warning: more singular values/vectors requested than available
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
# Use only the 500 most variable features
tse <- addPCA(tse, assay.type = "clr", ntop = 500, name = "PCA_top500")
#> Warning: more singular values/vectors requested than available
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
plotReducedDim(tse, "PCA", colour_by = "SampleType")