File: runPCA.Rd

package info (click to toggle)
r-bioc-biocsingular 1.6.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 364 kB
  • sloc: cpp: 57; sh: 13; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 2,670 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
\name{runPCA}
\alias{runPCA}
\alias{runPCA,ANY-method}

\title{Principal components analysis}
\description{Perform a principal components analysis (PCA) on a target matrix with a specified SVD algorithm.}

\usage{
runPCA(x, ...)

\S4method{runPCA}{ANY}(x, rank, center=TRUE, scale=FALSE, get.rotation=TRUE,
    get.pcs=TRUE, ...) 
}

\arguments{
\item{x}{A numeric matrix-like object with samples as rows and variables as columns.}
\item{rank}{Integer scalar specifying the number of principal components to retain.}
\item{center}{A logical scalar indicating whether columns of \code{x} should be centered before the PCA is performed.
Alternatively, a numeric vector of length \code{ncol(x)} containing the value to subtract from each column of \code{x}.}
\item{scale}{A logical scalar indicating whether columns of \code{x} should be scaled to unit variance before the PCA is performed.
Alternatively, a numeric vector of length \code{ncol(x)} containing the scaling factor for each column of \code{x}.}
\item{get.rotation}{A logical scalar indicating whether rotation vectors should be returned.}
\item{get.pcs}{A logical scalar indicating whether the principal component scores should be returned.}
\item{...}{
For the generic, this contains arguments to pass to methods upon dispatch.

For the \code{ANY} method, this contains further arguments to pass to \code{\link{runSVD}}.
This includes \code{BSPARAM} to specify the algorithm that should be used, and \code{BPPARAM} to control parallelization.
}
}

\details{
This function simply calls \code{\link{runSVD}} and converts the results into a format similar to that returned by \code{\link{prcomp}}.

The generic is exported to allow other packages to implement their own \code{runPCA} methods for other \code{x} objects, e.g., \pkg{scater} for SingleCellExperiment inputs.
}

\value{
A list is returned containing:
\itemize{
\item{\code{sdev}, a numeric vector of length \code{rank} containing the standard deviations of the first \code{rank} principal components.}
\item{\code{rotation}, a numeric matrix with \code{rank} columns and \code{nrow(x)} rows, containing the first \code{rank} rotation vectors.
This is only returned if \code{get.rotation=TRUE}.}
\item{\code{x}, a numeric matrix with \code{rank} columns and \code{ncol(x)} rows, containing the scores for the first \code{rank} principal components.
This is only returned if \code{get.pcs=TRUE}.}
}
}

\author{
Aaron Lun
}

\seealso{
\code{\link{runSVD}} for the underlying SVD function.

\code{?\linkS4class{BiocSingularParam}} for details on the algorithm choices.
}

\examples{
a <- matrix(rnorm(100000), ncol=20)
str(out <- runPCA(a, rank=10))
}