View source: R/S3_correlation.R
| cor.HDF5Matrix | R Documentation |
Block-wise computation of Pearson or Spearman correlation, running
entirely on disk without loading the full matrix into RAM.
Supports both auto-correlation cor(X) and cross-correlation
cor(X, Y).
## S3 method for class 'HDF5Matrix'
cor(
x,
y = NULL,
use = "everything",
method = "pearson",
trans_x = FALSE,
trans_y = FALSE,
compute_pvalues = TRUE,
block_size = NULL,
threads = NULL,
result_path = NULL,
compression = NULL,
...
)
x |
An |
y |
An |
use |
Character string. Only |
method |
|
trans_x |
Logical. If |
trans_y |
Logical. Same for |
compute_pvalues |
Logical. Also compute and store p-values on disk.
Default |
block_size |
Integer or NULL. Block size for HDF5 reads (NULL = auto). |
threads |
Integer or NULL. Number of OpenMP threads (NULL = auto). |
result_path |
Output location:
|
compression |
Integer (0-9) or NULL. gzip compression level for the
result datasets. NULL uses the global option set by
|
... |
Ignored (for S3 compatibility). |
An HDF5Matrix pointing to the correlation matrix on disk.
Attributes attached to the result:
cor.methodThe correlation method used.
cor.type"single" or "cross".
cor.n.varsNumber of variables (columns/rows correlated).
cor.n.obsNumber of observations used.
cor.pvalues.pathHDF5 path to the p-values dataset
(present only when compute_pvalues = TRUE).
tmp <- tempfile(fileext = ".h5")
X <- hdf5_create_matrix(tmp, "data/X",
data = matrix(rnorm(500), 50, 10))
# Auto-correlation: cor(X) — 10 x 10 matrix
C <- cor(X)
dim(C)
cat("method:", attr(C, "cor.method"), "\n")
# Spearman
Cs <- cor(X, method = "spearman")
dim(Cs)
# Sample-sample correlation (rows)
Sr <- cor(X, trans_x = TRUE) # 50 x 50
dim(Sr)
X$close(); C$close(); Cs$close(); Sr$close()
unlink(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.