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", ...)

Arguments

x

a SummarizedExperiment object.

...

additional arguments passed to scater::calculatePCA.

  • ntop: Numeric scalar. Number of the most variable features used. (Default: Inf)

name

Character scalar. A name for the reducedDim() where results will be stored. (Default: "PCA")

assay.type

Character scalar. Specifies the name of assay used in calculation. (Default: "counts")

Value

getPCA returns PCA results. addPCA returns x with PCA results added to its reducedDim(x, name).

Details

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.

Examples

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")