tatami-utils: Tatami utilities

tatami-utilsR Documentation

Tatami utilities

Description

Utility functions that directly operate on the pointers produced by initializeCpp. Some of these are used internally by initializeCpp methods operating on DelayedArray classes.

Usage

tatami.bind(xs, by.row)

tatami.transpose(x)

tatami.subset(x, subset, by.row)

tatami.arith(x, op, val, by.row, right)

tatami.compare(x, op, val, by.row, right)

tatami.logic(x, op, val, by.row)

tatami.round(x)

tatami.log(x, base)

tatami.math(x, op)

tatami.not(x)

tatami.binary(x, y, op)

tatami.dim(x)

tatami.row(x, i)

tatami.column(x, i)

tatami.row.sums(x, num.threads)

tatami.column.sums(x, num.threads)

tatami.is.sparse(x)

tatami.prefer.rows(x)

tatami.realize(x, num.threads)

tatami.multiply(x, val, right, num.threads)

Arguments

xs

A list of pointers produced by initializeCpp. All matrices should have the same number of rows (if by.row=FALSE) or columns (otherwise).

by.row

Logical scalar indicating whether to apply the operation on the rows.

  • For tatami.bind, this will combine the matrices by rows, i.e., the output matrix has a number of rows equal to the sum of the number of rows in xs.

  • For tatami.subset, this will subset the matrix by row.

  • For tatami.arith, tatami.compare and tatami.logic with a vector val, the vector should have length equal to the number of rows.k

x

A pointer produced by initializeCpp.

subset

Integer vector containing the subset of interest. These should be 1-based row or column indices depending on by.row.

op

String specifying the operation to perform.

  • For tatami.arith, this should be one of the operations in Arith.

  • For tatami.compare, this should be one of the operations in Compare.

  • For tatami.logic, this should be one of the operations in Logic.

  • For tatami.math, this should be one of the operations in Math.

  • For tatami.binary, this may be any operation in Arith, Compare or Logic.

val

For tatami.arith, tatami.compare and tatami.logic, the value to be used in the operation specified by op. This may be a:

  • Numeric scalar, which is used in the operation for all entries of the matrix.

  • Numeric vector of length equal to the number of rows, where each value is used in the operation with the corresponding row when by.row=TRUE.

  • Numeric vector of length equal to the number of column, where each value is used with the corresponding column when by.row=FALSE.

For tatami.multiply, the value to be used in the matrix multiplication. This may be a:

  • Numeric vector of length equal to the number of columns of x (if right=FALSE) or rows (otherwise).

  • Numeric matrix with number of rows equal to the number of columns of x (if right=FALSE) or rows (otherwise).

  • Pointer produced by initializeCpp, referencing a matrix with number of rows equal to the number of columns of x (if right=FALSE) or rows (otherwise).

right

For tatami.arith and tatami.compare, a logical scalar indicating that val is on the right-hand side of the operation.

For tatami.multiply, a logical scalar indicating that val is on the right-hand side of the multiplication.

base

Numeric scalar specifying the base of the log-transformation.

y

A pointer produced by initializeCpp, referencing a matrix of the same dimensions as x.

i

Integer scalar containing the 1-based index of the row (for tatami.row) or column (for tatami.column) of interest.

num.threads

Integer scalar specifying the number of threads to use.

Value

For tatami.dim, an integer vector containing the dimensions of the matrix.

For tatami.is.sparse, a logical scalar indicating whether the matrix is sparse.

For tatami.prefer.rows, a logical scalar indicating whether the matrix prefers iteration by row.

For tatami.row or tatami.column, a numeric vector containing the contents of row or column i, respectively.

For tatami.row.sums or tatami.column.sums, a numeric vector containing the row or column sums, respectively.

For tatami.realize, a numeric matrix or dgCMatrix with the matrix contents. The exact class depends on whether x refers to a sparse matrix.

For tatami.multiply, a numeric matrix containing the matrix product of x and other.

For all other functions, a new pointer to a matrix with the requested operations applied to x or xs.

Author(s)

Aaron Lun

Examples

x <- Matrix::rsparsematrix(1000, 100, 0.1)
ptr <- initializeCpp(x)
tatami.dim(ptr)
tatami.row(ptr, 1)

rounded <- tatami.round(ptr)
tatami.row(rounded, 1)


LTLA/beachmat documentation built on Nov. 15, 2024, 10:19 p.m.