View source: R/reduceFeatures-functions.R
reducePCA | R Documentation |
Performs PCA on a matrix-like object where rows represent features and columns represents samples.
reducePCA(x, ncomp = 2, center = TRUE, scale = FALSE, ...)
x |
A matrix-like object. |
ncomp |
An integer specifying the number of components to extract. |
center |
A logical specifying whether |
scale |
A logical specifying whether the unit variance scaling needs to
be performed on |
... |
Additional arguments passed to pcaMethods::nipalsPca. Ignored
if |
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.
A reduced.pca object with the same number of rows as ncol(x)
containing the dimension reduction result.
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 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.
data(faahko_se)
m <- assay(faahko_se, "knn_vsn")
res <- reducePCA(m, ncomp = 3)
summary(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.