colsum,HDF5Matrix-method {DelayedMatrixStats} | R Documentation |
Compute column and row sums across rows or columns of a numeric HDF5Array::HDF5Matrix object for each level of a grouping variable.
## S4 method for signature 'HDF5Matrix' colsum(x, group, reorder = TRUE, na.rm = FALSE, filepath = NULL, name = NULL, chunkdim = NULL, level = NULL, type = c("double", "integer"), BPPARAM = bpparam()) ## S4 method for signature 'HDF5Matrix' rowsum(x, group, reorder = TRUE, na.rm = FALSE, filepath = NULL, name = NULL, chunkdim = NULL, level = NULL, type = c("double", "integer"), BPPARAM = bpparam())
x |
An HDF5Array::HDF5Matrix object. |
group |
A vector or factor giving the grouping, with one element per
row of |
reorder |
If |
na.rm |
logical ( |
filepath |
|
name |
|
chunkdim |
The dimensions of the chunks to use for writing the data to
disk. By default,
|
level |
The compression level to use for writing the data to disk. By
default, |
type |
The type of the data that will be written to the
HDF5Array object to create the result. If the
result is known a priori to be |
BPPARAM |
An optional BiocParallel instance determining the parallel back-end to be used during evaluation, or a list of BiocParallel instances, to be applied in sequence for nested calls to BiocParallel functions. |
NOTE: Unlike base::rowsum()
, the result is a
base::double
unless type = "integer"
is specified. Notably, compared
to base::rowsum()
, this means that there are not the same issues with
over/underflow in forming the sum results for integer arguments.
# A DelayedMatrix with a 'HDF5ArraySeed' seed # NOTE: Requires that the HDF5Array package is installed library(HDF5Array) dm_HDF5 <- writeHDF5Array(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) group <- c(1, 1, 2) # Compute the sums and store them in an HDF5-backed DelayedMatrix. xsum <- colsum(dm_HDF5, group) class(seed(xsum))