| chunkedApply | R Documentation |
Similar to apply, but designed for file-backed matrices. The
function brings chunks of an object into physical memory by taking subsets,
and applies a function on either the rows or the columns of the chunks
using an optimized version of apply. If nCores is greater
than 1, the function will be applied in parallel using mclapply. In
that case the subsets of the object are taken on the slaves.
chunkedApply(X, MARGIN, FUN, i = seq_len(nrow(X)),
j = seq_len(ncol(X)), chunkSize = 5000L,
nCores = getOption("mc.cores", 2L), verbose = FALSE, ...)
X |
A file-backed matrix, typically the genotypes of a |
MARGIN |
The subscripts which the function will be applied over. 1 indicates rows, 2 indicates columns. |
FUN |
The function to be applied. |
i |
Indicates which rows of |
j |
Indicates which columns of |
chunkSize |
The number of rows or columns of |
nCores |
The number of cores (passed to |
verbose |
Whether progress updates will be posted. Defaults to |
... |
Additional arguments to be passed to the |
file-backed-matrices for more information on file-backed
matrices. multi-level-parallelism for more information on
multi-level parallelism. BGData-class for more information on
the BGData class.
# Restrict number of cores to 1 on Windows
if (.Platform$OS.type == "windows") {
options(mc.cores = 1)
}
# Load example data
bg <- BGData:::loadExample()
# Compute standard deviation of columns
chunkedApply(X = geno(bg), MARGIN = 2, FUN = sd)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.