View source: R/S3_decompositions.R
| prcomp.HDF5Matrix | R Documentation |
Block-wise PCA entirely on disk, equivalent to prcomp().
Implements the same interface as stats::prcomp() but operates on
data stored in an HDF5 file without loading it into RAM.
## S3 method for class 'HDF5Matrix'
prcomp(
x,
retx = TRUE,
center = TRUE,
scale. = FALSE,
tol = NULL,
rank. = NULL,
ncomponents = 0L,
k = 2L,
q = 1L,
method = "auto",
rankthreshold = 0,
svdgroup = "SVD/",
overwrite = FALSE,
threads = -1L,
...
)
x |
An |
retx |
Logical. If |
center |
Logical. Subtract column means before PCA (default |
scale. |
Logical. Divide by column SDs before PCA (default |
tol |
Ignored (present for interface compatibility with |
rank. |
Ignored. Present for compatibility with |
ncomponents |
Integer. Number of PCs to compute (0 = all, default). |
k |
Number of local SVDs per incremental level (default 2). |
q |
Number of incremental levels (default 1). |
method |
Computation method: |
rankthreshold |
Numeric in |
svdgroup |
HDF5 group for intermediate SVD storage (default |
overwrite |
Logical. Recompute even if PCA results exist (default |
threads |
Integer. OpenMP threads ( |
... |
Ignored (S3 compatibility). |
An object of class c("HDF5PCA", "list") with elements:
sdevNumeric vector. Standard deviations of the PCs.
rotationHDF5Matrix. Variable loadings (rotation matrix).
xHDF5Matrix or NULL. Individual coordinates.
centerLogical. Whether columns were centered.
scaleLogical. Whether columns were scaled.
cumvarNumeric vector. Cumulative variance explained (percent).
lambdaNumeric vector. Eigenvalues.
var.cos2HDF5Matrix. Squared cosines for variables.
ind.cos2HDF5Matrix. Squared cosines for individuals.
ind.contribHDF5Matrix. Contributions of individuals to PCs.
fileCharacter. Path to the HDF5 file with all results.
tmp <- tempfile(fileext = ".h5")
X <- hdf5_create_matrix(tmp, "data/M", data = matrix(rnorm(1000), 100, 10))
pca <- prcomp(X, center = TRUE, scale. = FALSE)
cat("Variance explained (PC1-3):", pca$cumvar[1:3], "\n")
dim(pca$rotation) # 10 x nPC
dim(pca$x) # 100 x nPC
hdf5_close_all()
unlink(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.