runPCA | R Documentation |
Perform a principal components analysis (PCA) on a target matrix with a specified SVD algorithm.
runPCA(x, ...)
## S4 method for signature 'ANY'
runPCA(x, rank, center=TRUE, scale=FALSE, get.rotation=TRUE,
get.pcs=TRUE, ...)
x |
A numeric matrix-like object with samples as rows and variables as columns. |
rank |
Integer scalar specifying the number of principal components to retain. |
center |
A logical scalar indicating whether columns of |
scale |
A logical scalar indicating whether columns of |
get.rotation |
A logical scalar indicating whether rotation vectors should be returned. |
get.pcs |
A logical scalar indicating whether the principal component scores should be returned. |
... |
For the generic, this contains arguments to pass to methods upon dispatch. For the |
This function simply calls runSVD
and converts the results into a format similar to that returned by prcomp
.
The generic is exported to allow other packages to implement their own runPCA
methods for other x
objects, e.g., scater for SingleCellExperiment inputs.
A list is returned containing:
sdev
, a numeric vector of length rank
containing the standard deviations of the first rank
principal components.
rotation
, a numeric matrix with rank
columns and nrow(x)
rows, containing the first rank
rotation vectors.
This is only returned if get.rotation=TRUE
.
x
, a numeric matrix with rank
columns and ncol(x)
rows, containing the scores for the first rank
principal components.
This is only returned if get.pcs=TRUE
.
Aaron Lun
runSVD
for the underlying SVD function.
?BiocSingularParam
for details on the algorithm choices.
a <- matrix(rnorm(100000), ncol=20)
str(out <- runPCA(a, rank=10))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.