rowsum,DelayedMatrix-method {DelayedMatrixStats}R Documentation

Give Column and Row Sums of an DelayedMatrix Based on a Grouping Variable

Description

Compute column and row sums across rows or columns of a numeric DelayedArray::DelayedMatrix object for each level of a grouping variable using block-processing.

Usage

## S4 method for signature 'DelayedMatrix'
rowsum(x, group, reorder = TRUE,
  na.rm = FALSE, force_block_processing = FALSE, ...)

Arguments

x

An DelayedArray::DelayedMatrix object.

group

A vector or factor giving the grouping, with one element per row of x for rowsum() or one element per column of x for colsum(). Missing values will be treated as another group and a warning will be given.

reorder

If TRUE, then the result will be in order of sort(unique(group)). If FALSE, it will be in the order that groups are encountered.

na.rm

logical (TRUE or FALSE). Should NA (including NaN) values be discarded?

force_block_processing

FALSE (the default) means that a seed-aware, optimised method is used (if available). This can be overridden to use the general block-processing strategy by setting this to TRUE (typically not advised). The block-processing strategy loads one or more (depending on getAutoBlockSize()) columns (colFoo()) or rows (rowFoo()) into memory as an ordinary base::array.

...

Additional arguments passed to specific methods.

Examples

# A DelayedMatrix with a 'Matrix' seed
dm_Matrix <- DelayedArray(Matrix::Matrix(c(rep(1L, 5),
                                           as.integer((0:4) ^ 2),
                                           seq(-5L, -1L, 1L)),
                                         ncol = 3))

rowsum(dm_Matrix, group = c(1, 1, 1, 2, 2))

[Package DelayedMatrixStats version 1.4.0 Index]