reducePCA: Principal component analysis (PCA)

View source: R/reduceFeatures-functions.R

reducePCAR Documentation

Principal component analysis (PCA)

Description

Performs PCA on a matrix-like object where rows represent features and columns represents samples.

Usage

reducePCA(x, ncomp = 2, center = TRUE, scale = FALSE, ...)

Arguments

x

A matrix-like object.

ncomp

An integer specifying the number of components to extract.

center

A logical specifying whether x needs to be mean-centered prior to PCA.

scale

A logical specifying whether the unit variance scaling needs to be performed on x prior to PCA.

...

Additional arguments passed to pcaMethods::nipalsPca. Ignored if x has no missing values.

Details

For the data without missing values, PCA is performed with the transpose of x via singular value decomposition. Otherwise, PCA is performed with the transpose of x using the non-linear iterative partial least squares (NIPALS) algorithm via the pcaMethods::nipalsPca. The function returns a reduced.pca object that is a matrix with custom attributes to summarize (via summary) and visualize (via plotReduced) the PCA result. The custom attributes include the following:

  • method: The method used to reduce the dimension of data.

  • ncomp: The number of components extracted.

  • R2: A vector indicating the amount of variance explained by each principal component.

  • R2cum: A vector of cumulative R2.

  • loadings: A matrix of variable loadings.

  • sdev: A vector indicating the standard deviations of the principal components.

  • centered: A logical indicating whether the data was mean-centered prior to PCA.

  • scaled: A logical indicating whether the data was scaled prior to PCA.

Value

A reduced.pca object with the same number of rows as ncol(x) containing the dimension reduction result.

References

Wold, H. (1966). Estimation of principal components and related models by iterative least squares. In P. R. Krishnajah (Ed.), Multivariate analysis (pp. 391-420). NewYork: Academic Press.

Stacklies, W., Redestig, H., Scholz, M., Walther, D. and Selbig, J. pcaMethods – a Bioconductor package providing PCA methods for incomplete data. Bioinformatics, 2007, 23, 1164-1167

See Also

See reduceFeatures that provides a SummarizedExperiment-friendly wrapper for this function.

See plotReduced for visualization.

See pcaMethods::nipalsPca for the underlying function that does the work.

Examples


data(faahko_se)

m <- assay(faahko_se, "knn_vsn")
res <- reducePCA(m, ncomp = 3)
summary(res)


HimesGroup/qmtools documentation built on April 16, 2023, 8 p.m.