colAvgsPerRowSet: Calculates for each row (column) a summary statistic for...

colAvgsPerRowSet,DelayedMatrix-methodR Documentation

Calculates for each row (column) a summary statistic for equally sized subsets of columns (rows)

Description

Calculates for each row (column) a summary statistic for equally sized subsets of columns (rows).

Usage

## S4 method for signature 'DelayedMatrix'
colAvgsPerRowSet(
  X,
  W = NULL,
  cols = NULL,
  S,
  FUN = colMeans,
  ...,
  force_block_processing = FALSE,
  na.rm = NA,
  tFUN = FALSE
)

## S4 method for signature 'DelayedMatrix'
rowAvgsPerColSet(
  X,
  W = NULL,
  rows = NULL,
  S,
  FUN = rowMeans,
  ...,
  force_block_processing = FALSE,
  na.rm = NA,
  tFUN = FALSE
)

Arguments

X

A NxM DelayedMatrix.

W

An optional numeric NxM matrix of weights.

S

An integer KxJ matrix that specifying the J subsets. Each column hold K column (row) indices for the corresponding subset. The range of values is [1, M] ([1,N]).

FUN

A row-by-row (column-by-column) summary statistic function. It is applied to to each column (row) subset of X that is specified by S.

...

Additional arguments passed to specific methods.

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 ⁠\link[DelayedArray]{getAutoBlockSize}()⁠) columns (colFoo()) or rows (rowFoo()) into memory as an ordinary base::array.

na.rm

(logical) Argument passed to FUN() as na.rm = na.rm. If NA (default), then na.rm = TRUE is used if X or S holds missing values, otherwise na.rm = FALSE.

tFUN

If TRUE, X is transposed before it is passed to FUN.

rows, cols

A vector indicating the subset (and/or columns) to operate over. If NULL, no subsetting is done.

Details

The S4 methods for x of type matrix, array, table, or numeric call matrixStats::rowAvgsPerColSet / matrixStats::colAvgsPerRowSet.

Value

Returns a numeric JxN (MxJ) matrix.

Author(s)

Peter Hickey

See Also

  • matrixStats::rowAvgsPerColSet() and matrixStats::colAvgsPerRowSet() which are used when the input is a matrix or numeric vector.

Examples

# A DelayedMatrix with a 'DataFrame' seed
dm_DF <- DelayedArray(S4Vectors::DataFrame(C1 = rep(1L, 5),
                                           C2 = as.integer((0:4) ^ 2),
                                           C3 = seq(-5L, -1L, 1L)))
colAvgsPerRowSet(dm_DF, S = matrix(1:2, ncol = 2))

rowAvgsPerColSet(dm_DF, S = matrix(1:2, ncol = 1))

PeteHaitch/DelayedMatrixStats documentation built on May 6, 2024, 10:25 p.m.