Title: | Functions that Apply to Rows and Columns of 'DelayedMatrix' Objects |
---|---|
Description: | A port of the 'matrixStats' API for use with DelayedMatrix objects from the 'DelayedArray' package. High-performing functions operating on rows and columns of DelayedMatrix objects, e.g. col / rowMedians(), col / rowRanks(), and col / rowSds(). Functions optimized per data type and for subsetted calculations such that both memory usage and processing time is minimized. |
Authors: | Peter Hickey [aut, cre] , Hervé Pagès [ctb], Aaron Lun [ctb] |
Maintainer: | Peter Hickey <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.29.0 |
Built: | 2024-10-30 05:28:20 UTC |
Source: | https://github.com/bioc/DelayedMatrixStats |
Check if all elements in a row (column) of a matrix-like object are equal to a value.
## S4 method for signature 'DelayedMatrix' colAlls( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colAnys( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowAlls( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowAnys( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colAlls( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colAnys( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowAlls( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowAnys( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
value |
The value to search for. |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowAlls
/
matrixStats::colAlls
.
Returns a logical
vector
of length N (K).
Peter Hickey
matrixStats::rowAlls()
and
matrixStats::colAlls()
which are
used when the input is a matrix
or numeric
vector.
For checks if any element is equal to a value, see
rowAnys()
.
base::all()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colAlls(dm_matrix, value = 1) colAnys(dm_matrix, value = 2) rowAlls(dm_Rle, value = 1) rowAnys(dm_Rle, value = 2)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colAlls(dm_matrix, value = 1) colAnys(dm_matrix, value = 2) rowAlls(dm_Rle, value = 1) rowAnys(dm_Rle, value = 2)
Check if any elements in a row (column) of a matrix-like object is missing.
## S4 method for signature 'DelayedMatrix' colAnyNAs( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowAnyNAs( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colAnyNAs( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowAnyNAs( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowAnyNAs
/
matrixStats::colAnyNAs
.
Returns a logical
vector
of length N (K).
Peter Hickey
matrixStats::rowAnyNAs()
and
matrixStats::colAnyNAs()
which are
used when the input is a matrix
or numeric
vector.
For checks if any element is equal to a value, see
rowAnys()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) dm_matrix[dm_matrix > 3] <- NA colAnyNAs(dm_matrix) dm_HDF5[dm_HDF5 > 3] <- NA rowAnyNAs(dm_HDF5)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) dm_matrix[dm_matrix > 3] <- NA colAnyNAs(dm_matrix) dm_HDF5[dm_HDF5 > 3] <- NA rowAnyNAs(dm_HDF5)
Calculates for each row (column) a summary statistic for equally sized subsets of columns (rows).
## 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 )
## 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 )
X |
A NxM DelayedMatrix. |
W |
An optional numeric |
S |
An integer |
FUN |
A row-by-row (column-by-column) summary statistic function. It is
applied to to each column (row) subset of |
... |
Additional arguments passed to specific methods. |
force_block_processing |
|
na.rm |
(logical) Argument passed to |
tFUN |
If |
rows , cols
|
A |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowAvgsPerColSet
/
matrixStats::colAvgsPerRowSet
.
Returns a numeric JxN
(MxJ
) matrix.
Peter Hickey
matrixStats::rowAvgsPerColSet()
and matrixStats::colAvgsPerRowSet()
which are used when the input is a matrix
or numeric
vector.
# 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))
# 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))
Extract one cell from each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colCollapse( x, idxs, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCollapse( x, idxs, rows = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colCollapse( x, idxs, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCollapse( x, idxs, rows = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
idxs |
An index |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
rows , cols
|
A |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCollapse
/
matrixStats::colCollapse
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowCollapse()
and matrixStats::colCollapse()
which are used when the input is a matrix
or numeric
vector.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) # Extract the 4th row as a vector # NOTE: An ordinary vector is returned regardless of the backend of # the DelayedMatrix object colCollapse(dm_matrix, 4) colCollapse(dm_HDF5, 4) # Extract the 2nd column as a vector # NOTE: An ordinary vector is returned regardless of the backend of # the DelayedMatrix object rowCollapse(dm_matrix, 2) rowCollapse(dm_HDF5, 2)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) # Extract the 4th row as a vector # NOTE: An ordinary vector is returned regardless of the backend of # the DelayedMatrix object colCollapse(dm_matrix, 4) colCollapse(dm_HDF5, 4) # Extract the 2nd column as a vector # NOTE: An ordinary vector is returned regardless of the backend of # the DelayedMatrix object rowCollapse(dm_matrix, 2) rowCollapse(dm_HDF5, 2)
Count how often an element in a row (column) of a matrix-like object is equal to a value.
## S4 method for signature 'DelayedMatrix' colCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
value |
The value to search for. |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCounts
/
matrixStats::colCounts
.
Returns a integer
vector
of length N (K).
Peter Hickey
matrixStats::rowCounts()
and
matrixStats::colCounts()
which are
used when the input is a matrix
or numeric
vector.
For checks if any element is equal to a value, see
rowAnys()
. To check if all elements are equal, see
rowAlls()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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))) colCounts(dm_matrix, value = 1) # Only count those in the first 4 rows colCounts(dm_matrix, rows = 1:4, value = 1) rowCounts(dm_DF, value = 5) # Only count those in the odd-numbered rows of the 2nd column rowCounts(dm_DF, rows = seq(1, nrow(dm_DF), 2), cols = 2, value = 5)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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))) colCounts(dm_matrix, value = 1) # Only count those in the first 4 rows colCounts(dm_matrix, rows = 1:4, value = 1) rowCounts(dm_DF, value = 5) # Only count those in the odd-numbered rows of the 2nd column rowCounts(dm_DF, rows = seq(1, nrow(dm_DF), 2), cols = 2, value = 5)
Calculates the cumulative maxima for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colCummaxs( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colCummins( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colCumprods( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colCumsums( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCummaxs( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCummins( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCumprods( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCumsums( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colCummaxs( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colCummins( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colCumprods( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colCumsums( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCummaxs( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCummins( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCumprods( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowCumsums( x, rows = NULL, cols = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowCummaxs
/
matrixStats::colCummaxs
.
Returns a numeric
matrix
with the same
dimensions as x
.
Peter Hickey
matrixStats::rowCummaxs()
and
matrixStats::colCummaxs()
which are
used when the input is a matrix
or numeric
vector.
For single maximum estimates, see rowMaxs()
.
base::cummax()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colCummaxs(dm_matrix) colCummins(dm_matrix) colCumprods(dm_matrix) colCumsums(dm_matrix) # Only use rows 2-4 rowCummaxs(dm_Matrix, rows = 2:4) # Only use rows 2-4 rowCummins(dm_Matrix, rows = 2:4) # Only use rows 2-4 rowCumprods(dm_Matrix, rows = 2:4) # Only use rows 2-4 rowCumsums(dm_Matrix, rows = 2:4)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colCummaxs(dm_matrix) colCummins(dm_matrix) colCumprods(dm_matrix) colCumsums(dm_matrix) # Only use rows 2-4 rowCummaxs(dm_Matrix, rows = 2:4) # Only use rows 2-4 rowCummins(dm_Matrix, rows = 2:4) # Only use rows 2-4 rowCumprods(dm_Matrix, rows = 2:4) # Only use rows 2-4 rowCumsums(dm_Matrix, rows = 2:4)
Calculates the difference between each element of a row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colDiffs( x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowDiffs( x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colDiffs( x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowDiffs( x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
lag |
An integer specifying the lag. |
differences |
An integer specifying the order of difference. |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowDiffs
/
matrixStats::colDiffs
.
Returns a numeric
matrix
with one column
(row) less than x: or
.
Peter Hickey
matrixStats::rowDiffs()
and
matrixStats::colDiffs()
which are used
when the input is a matrix
or numeric
vector.
base::diff()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colDiffs(dm_matrix) rowDiffs(dm_HDF5) # In reverse column order rowDiffs(dm_HDF5, cols = seq(ncol(dm_HDF5), 1, -1))
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colDiffs(dm_matrix) rowDiffs(dm_HDF5) # In reverse column order rowDiffs(dm_HDF5, cols = seq(ncol(dm_HDF5), 1, -1))
Calculates the interquartile range of the difference between each element of a row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colIQRDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colMadDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colSdDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colVarDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowIQRDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowMadDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowSdDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowVarDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colIQRDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colMadDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colSdDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colVarDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowIQRDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowMadDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowSdDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowVarDiffs( x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
na.rm |
If |
diff |
An integer specifying the order of difference. |
trim |
A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation. |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowIQRDiffs
/
matrixStats::colIQRDiffs
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowIQRDiffs()
and
matrixStats::colIQRDiffs()
which
are used when the input is a matrix
or numeric
vector.
For the direct interquartile range see also rowIQRs.
# 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)) # A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colIQRDiffs(dm_Matrix) colMadDiffs(dm_Matrix) colSdDiffs(dm_Matrix) colVarDiffs(dm_Matrix) # Only using rows 2-4 rowIQRDiffs(dm_Rle, rows = 2:4) # Only using rows 2-4 rowMadDiffs(dm_Rle, rows = 2:4) # Only using rows 2-4 rowSdDiffs(dm_Rle, rows = 2:4) # Only using rows 2-4 rowVarDiffs(dm_Rle, rows = 2:4)
# 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)) # A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colIQRDiffs(dm_Matrix) colMadDiffs(dm_Matrix) colSdDiffs(dm_Matrix) colVarDiffs(dm_Matrix) # Only using rows 2-4 rowIQRDiffs(dm_Rle, rows = 2:4) # Only using rows 2-4 rowMadDiffs(dm_Rle, rows = 2:4) # Only using rows 2-4 rowSdDiffs(dm_Rle, rows = 2:4) # Only using rows 2-4 rowVarDiffs(dm_Rle, rows = 2:4)
Calculates the interquartile range for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colIQRs( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowIQRs( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colIQRs( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowIQRs( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowIQRs
/
matrixStats::colIQRs
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowIQRs()
and
matrixStats::colIQRs()
which are used
when the input is a matrix
or numeric
vector.
For a non-robust analog, see rowSds()
. For a more
robust version see rowMads()
stats::IQR()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colIQRs(dm_matrix) # Only using rows 2-4 rowIQRs(dm_matrix, rows = 2:4)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colIQRs(dm_matrix) # Only using rows 2-4 rowIQRs(dm_matrix, rows = 2:4)
Accurately calculates the logarithm of the sum of exponentials for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colLogSumExps( lx, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowLogSumExps( lx, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colLogSumExps( lx, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowLogSumExps( lx, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
lx |
A NxK DelayedMatrix. Typically, |
rows , cols
|
A |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowLogSumExps
/
matrixStats::colLogSumExps
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowLogSumExps()
and
matrixStats::colLogSumExps()
which are used when the input is a matrix
or numeric
vector.
x <- DelayedArray(matrix(runif(10), ncol = 2)) colLogSumExps(log(x)) rowLogSumExps(log(x))
x <- DelayedArray(matrix(runif(10), ncol = 2)) colLogSumExps(log(x)) rowLogSumExps(log(x))
Calculates the median absolute deviation for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colMads( x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colSds( x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowMads( x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowSds( x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colMads( x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colSds( x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowMads( x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowSds( x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
center |
(optional) the center, defaults to the row means |
constant |
A scale factor. See |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMads
/
matrixStats::colMads
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowMads()
and
matrixStats::colMads()
which are used
when the input is a matrix
or numeric
vector.
For non-robust standard deviation estimates, see
rowSds()
.
# A DelayedMatrix with a 'data.frame' seed dm_df <- DelayedArray(data.frame(C1 = rep(1L, 5), C2 = as.integer((0:4) ^ 2), C3 = seq(-5L, -1L, 1L))) # 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))) colMads(dm_df) colSds(dm_df) rowMads(dm_DF) rowSds(dm_DF)
# A DelayedMatrix with a 'data.frame' seed dm_df <- DelayedArray(data.frame(C1 = rep(1L, 5), C2 = as.integer((0:4) ^ 2), C3 = seq(-5L, -1L, 1L))) # 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))) colMads(dm_df) colSds(dm_df) rowMads(dm_DF) rowSds(dm_DF)
Calculates the mean for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colMeans2( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'Matrix' colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'SolidRleArraySeed' colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'DelayedMatrix' rowMeans2( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'Matrix' rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
## S4 method for signature 'DelayedMatrix' colMeans2( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'Matrix' colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'SolidRleArraySeed' colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'DelayedMatrix' rowMeans2( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'Matrix' rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMeans2
/
matrixStats::colMeans2
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowMeans2()
and
matrixStats::colMeans2()
which are
used when the input is a matrix
or numeric
vector.
See also rowMeans()
for the
corresponding function in base R.
For variance estimates, see rowVars()
.
See also the base R version base::rowMeans()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colMeans2(dm_matrix) # NOTE: Temporarily use verbose output to demonstrate which method is # which method is being used options(DelayedMatrixStats.verbose = TRUE) # By default, this uses a seed-aware method for a DelayedMatrix with a # 'SolidRleArraySeed' seed rowMeans2(dm_Rle) # Alternatively, can use the block-processing strategy rowMeans2(dm_Rle, force_block_processing = TRUE) options(DelayedMatrixStats.verbose = FALSE)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colMeans2(dm_matrix) # NOTE: Temporarily use verbose output to demonstrate which method is # which method is being used options(DelayedMatrixStats.verbose = TRUE) # By default, this uses a seed-aware method for a DelayedMatrix with a # 'SolidRleArraySeed' seed rowMeans2(dm_Rle) # Alternatively, can use the block-processing strategy rowMeans2(dm_Rle, force_block_processing = TRUE) options(DelayedMatrixStats.verbose = FALSE)
Calculates the median for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colMedians( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowMedians( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colMedians( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowMedians( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowMedians
/
matrixStats::colMedians
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowMedians()
and
matrixStats::colMedians()
which are
used when the input is a matrix
or numeric
vector.
# 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)) colMedians(dm_Matrix) rowMedians(dm_Matrix)
# 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)) colMedians(dm_Matrix) rowMedians(dm_Matrix)
Calculates an order statistic for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colOrderStats( x, rows = NULL, cols = NULL, which, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowOrderStats( x, rows = NULL, cols = NULL, which, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colOrderStats( x, rows = NULL, cols = NULL, which, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowOrderStats( x, rows = NULL, cols = NULL, which, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
which |
An integer index in [1,K] ([1,N]) indicating which order statistic to be returned |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowOrderStats
/
matrixStats::colOrderStats
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowOrderStats()
and
matrixStats::colOrderStats()
which are used when the input is a matrix
or numeric
vector.
# 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)) # Only using columns 2-3 colOrderStats(dm_Matrix, cols = 2:3, which = 1) # Different algorithms, specified by `which`, may give different results rowOrderStats(dm_Matrix, which = 1) rowOrderStats(dm_Matrix, which = 2)
# 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)) # Only using columns 2-3 colOrderStats(dm_Matrix, cols = 2:3, which = 1) # Different algorithms, specified by `which`, may give different results rowOrderStats(dm_Matrix, which = 1) rowOrderStats(dm_Matrix, which = 2)
Calculates the product for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colProds( x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'SolidRleArraySeed' colProds( x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowProds( x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colProds( x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'SolidRleArraySeed' colProds( x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowProds( x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
na.rm |
If |
method |
A character vector of length one that specifies the how the product is calculated. Note, that this is not a generic argument and not all implementation have to provide it. |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowProds
/
matrixStats::colProds
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowProds()
and
matrixStats::colProds()
which are used
when the input is a matrix
or numeric
vector.
For sums across rows (columns), see
rowSums2()
(colSums2()
)
base::prod()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colProds(dm_matrix) rowProds(dm_matrix)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colProds(dm_matrix) rowProds(dm_matrix)
Calculates quantiles for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colQuantiles( x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, force_block_processing = FALSE, ..., useNames = TRUE, drop = TRUE ) ## S4 method for signature 'DelayedMatrix' rowQuantiles( x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, force_block_processing = FALSE, ..., useNames = TRUE, drop = TRUE )
## S4 method for signature 'DelayedMatrix' colQuantiles( x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, force_block_processing = FALSE, ..., useNames = TRUE, drop = TRUE ) ## S4 method for signature 'DelayedMatrix' rowQuantiles( x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, force_block_processing = FALSE, ..., useNames = TRUE, drop = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
probs |
A numeric vector of J probabilities in [0, 1]. |
na.rm |
If |
type |
An integer specifying the type of estimator. See
|
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
drop |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowQuantiles
/
matrixStats::colQuantiles
.
a numeric
NxJ
(KxJ
)
matrix
, where N (K) is the number of rows (columns) for
which the J values are calculated.
Peter Hickey
matrixStats::rowQuantiles()
and
matrixStats::colQuantiles()
which
are used when the input is a matrix
or numeric
vector.
# A DelayedMatrix with a 'data.frame' seed dm_df <- DelayedArray(data.frame(C1 = rep(1L, 5), C2 = as.integer((0:4) ^ 2), C3 = seq(-5L, -1L, 1L))) # colnames, if present, are preserved as rownames on output colQuantiles(dm_df) # Input has no rownames so output has no rownames rowQuantiles(dm_df)
# A DelayedMatrix with a 'data.frame' seed dm_df <- DelayedArray(data.frame(C1 = rep(1L, 5), C2 = as.integer((0:4) ^ 2), C3 = seq(-5L, -1L, 1L))) # colnames, if present, are preserved as rownames on output colQuantiles(dm_df) # Input has no rownames so output has no rownames rowQuantiles(dm_df)
Calculates the rank of the elements for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colRanks( x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), preserveShape = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowRanks( x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colRanks( x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), preserveShape = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowRanks( x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
ties.method |
A character string specifying how ties are treated. Note that the default specifies fewer options than the original matrixStats package. |
preserveShape |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowRanks
/
matrixStats::colRanks
.
The matrixStats::rowRanks()
function can handle a lot of different
values for the ties.method
argument. Users of the generic function
should however only rely on max
and average
because the other ones
are not guaranteed to be implemented:
max
for values with identical values the maximum rank is returned
average
for values with identical values the average of the
ranks they cover is returned. Note, that in this case the return
value is of type numeric
.
a matrix of type integer
is returned unless
ties.method = "average"
. Ithas dimensions' NxJ
(KxJ
)
matrix
, where N (K) is the number of rows (columns) of the
input x.
Peter Hickey
matrixStats::rowRanks()
and
matrixStats::colRanks()
which are used
when the input is a matrix
or numeric
vector.
# 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)) colRanks(dm_Matrix) rowRanks(dm_Matrix)
# 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)) colRanks(dm_Matrix) rowRanks(dm_Matrix)
Calculates the sum for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colSums2( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'Matrix' colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'SolidRleArraySeed' colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'DelayedMatrix' rowSums2( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'Matrix' rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
## S4 method for signature 'DelayedMatrix' colSums2( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'Matrix' colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'SolidRleArraySeed' colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) ## S4 method for signature 'DelayedMatrix' rowSums2( x, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'Matrix' rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE)
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowSums2
/
matrixStats::colSums2
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowSums2()
and
matrixStats::colSums2()
which are used
when the input is a matrix
or numeric
vector.
base::sum()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colSums2(dm_matrix) # NOTE: Temporarily use verbose output to demonstrate which method is # which method is being used options(DelayedMatrixStats.verbose = TRUE) # By default, this uses a seed-aware method for a DelayedMatrix with a # 'SolidRleArraySeed' seed rowSums2(dm_Matrix) # Alternatively, can use the block-processing strategy rowSums2(dm_Matrix, force_block_processing = TRUE) options(DelayedMatrixStats.verbose = FALSE)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colSums2(dm_matrix) # NOTE: Temporarily use verbose output to demonstrate which method is # which method is being used options(DelayedMatrixStats.verbose = TRUE) # By default, this uses a seed-aware method for a DelayedMatrix with a # 'SolidRleArraySeed' seed rowSums2(dm_Matrix) # Alternatively, can use the block-processing strategy rowSums2(dm_Matrix, force_block_processing = TRUE) options(DelayedMatrixStats.verbose = FALSE)
Tabulates the values in a matrix-like object by row (column).
## S4 method for signature 'DelayedMatrix' colTabulates( x, rows = NULL, cols = NULL, values = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowTabulates( x, rows = NULL, cols = NULL, values = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colTabulates( x, rows = NULL, cols = NULL, values = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowTabulates( x, rows = NULL, cols = NULL, values = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
values |
the values to search for. |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowTabulates
/
matrixStats::colTabulates
.
a numeric
NxJ
(KxJ
)
matrix
, where N (K) is the number of rows (columns) for
which the J values are calculated.
Peter Hickey
matrixStats::rowTabulates()
and
matrixStats::colTabulates()
which
are used when the input is a matrix
or numeric
vector.
base::table()
# 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))) colTabulates(dm_DF) rowTabulates(dm_DF)
# 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))) colTabulates(dm_DF) rowTabulates(dm_DF)
Calculates the variance for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colVars( x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowVars( x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colVars( x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowVars( x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
rows , cols
|
A |
na.rm |
If |
center |
(optional) the center, defaults to the row means. |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowVars
/
matrixStats::colVars
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowVars()
and
matrixStats::colVars()
which are used
when the input is a matrix
or numeric
vector.
For standard deviation estimates, see rowSds()
.
stats::var()
.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colVars(dm_matrix) rowVars(dm_matrix)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) # 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)) colVars(dm_matrix) rowVars(dm_matrix)
Calculates the weighted median absolute deviation for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colWeightedMads( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedMads( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colWeightedMads( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedMads( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
w |
A |
rows , cols
|
A |
na.rm |
If |
constant |
A scale factor. See |
center |
(optional) the center, defaults to the row means |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedMads
/
matrixStats::colWeightedMads
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowWeightedMads()
and
matrixStats::colWeightedMads()
which are used when the input is a matrix
or numeric
vector.
See also rowMads for the corresponding unweighted function.
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) colWeightedMads(dm_matrix, w = 1:5) rowWeightedMads(dm_matrix, w = 3:1)
# A DelayedMatrix with a 'matrix' seed dm_matrix <- DelayedArray(matrix(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L)), ncol = 3)) colWeightedMads(dm_matrix, w = 1:5) rowWeightedMads(dm_matrix, w = 3:1)
Calculates the weighted mean for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colWeightedMeans( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedMeans( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colWeightedMeans( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedMeans( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
w |
A |
rows , cols
|
A |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedMeans
/
matrixStats::colWeightedMeans
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowWeightedMeans()
and
matrixStats::colWeightedMeans()
which are used when the input is a matrix
or numeric
vector.
See also rowMeans2 for the corresponding unweighted function.
# 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)) colWeightedMeans(dm_Matrix) # Specifying weights inversely proportional to rowwise variances colWeightedMeans(dm_Matrix, w = 1 / rowVars(dm_Matrix)) rowWeightedMeans(dm_Matrix, w = 1:3)
# 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)) colWeightedMeans(dm_Matrix) # Specifying weights inversely proportional to rowwise variances colWeightedMeans(dm_Matrix, w = 1 / rowVars(dm_Matrix)) rowWeightedMeans(dm_Matrix, w = 1:3)
Calculates the weighted median for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colWeightedMedians( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedMedians( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colWeightedMedians( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedMedians( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
w |
A |
rows , cols
|
A |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedMedians
/
matrixStats::colWeightedMedians
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowWeightedMedians()
and
matrixStats::colWeightedMedians()
which are used when the input is a matrix
or numeric
vector.
See also rowMedians for the corresponding unweighted function.
# A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) # Specifying weights inversely proportional to rowwise MADs colWeightedMedians(dm_Rle, w = 1 / rowMads(dm_Rle))
# A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) # Specifying weights inversely proportional to rowwise MADs colWeightedMedians(dm_Rle, w = 1 / rowMads(dm_Rle))
Calculates the weighted standard deviation for each row (column) of a matrix-like object.
## S4 method for signature 'DelayedMatrix' colWeightedSds( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colWeightedVars( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedSds( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedVars( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
## S4 method for signature 'DelayedMatrix' colWeightedSds( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' colWeightedVars( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedSds( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE ) ## S4 method for signature 'DelayedMatrix' rowWeightedVars( x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ..., useNames = TRUE )
x |
A NxK DelayedMatrix. |
w |
A |
rows , cols
|
A |
na.rm |
If |
force_block_processing |
|
... |
Additional arguments passed to specific methods. |
useNames |
If |
The S4 methods for x
of type matrix
,
array
, table
, or numeric
call
matrixStats::rowWeightedSds
/
matrixStats::colWeightedSds
.
Returns a numeric
vector
of length N (K).
Peter Hickey
matrixStats::rowWeightedSds()
and
matrixStats::colWeightedSds()
which are used when the input is a matrix
or numeric
vector.
See also rowSds for the corresponding unweighted function.
# A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colWeightedSds(dm_Rle, w = 1 / rowMeans2(dm_Rle)) # Specifying weights inversely proportional to rowwise means colWeightedVars(dm_Rle, w = 1 / rowMeans2(dm_Rle)) # Specifying weights inversely proportional to columnwise means rowWeightedSds(dm_Rle, w = 1 / colMeans2(dm_Rle)) # Specifying weights inversely proportional to columnwise means rowWeightedVars(dm_Rle, w = 1 / colMeans2(dm_Rle))
# A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colWeightedSds(dm_Rle, w = 1 / rowMeans2(dm_Rle)) # Specifying weights inversely proportional to rowwise means colWeightedVars(dm_Rle, w = 1 / rowMeans2(dm_Rle)) # Specifying weights inversely proportional to columnwise means rowWeightedSds(dm_Rle, w = 1 / colMeans2(dm_Rle)) # Specifying weights inversely proportional to columnwise means rowWeightedVars(dm_Rle, w = 1 / colMeans2(dm_Rle))
subset_by_Nindex
subset_by_Nindex()
is an internal generic function not aimed to be used
directly by the user. It is basically an S4 generic for
DelayedArray:::subset_by_Nindex
.
subset_by_Nindex(x, Nindex)
subset_by_Nindex(x, Nindex)
x |
An array-like object. |
Nindex |
An unnamed list of subscripts as positive integer vectors, one
vector per dimension in |
subset_by_Nindex(x, Nindex)
conceptually performs the operation
x[Nindex[1], ..., Nindex[length(Nindex)])
. subset_by_Nindex()
methods need to support empty and missing subscripts, e.g.,
subset_by_Nindex(x, list(NULL, integer(0)))
must return an M x 0 object
of class class(x)
and subset_by_Nindex(x, list(integer(0), integer(0)))
a 0 x 0 object of class class(x)
.
Also, subscripts are allowed to contain duplicate indices so things like
subset_by_Nindex(x, list(c(1:3, 3:1), 2L))
need to be supported.
A object of class class(x)
of the appropriate type (e.g., integer,
double, etc.). For example, if x
is a data.frame representing an M x N
matrix of integers, subset_by_Nindex(x, list(NULL, 2L)
must return its 2nd
column as a data.frame with M rows and 1 column of type integer.