matrix-stats: Matrix Statistics Functions

matrix-statsR Documentation

Matrix Statistics Functions

Description

Matrix statistics implemented in C++ through beachmat and tatami. These functions support ordinary, sparse (S4 Matrix), and DelayedArray matrices without coercing them to a dense R matrix.

normalize.quantiles performs quantile normalization on a matrix, transforming the distributions of each column to match a common target distribution. Uses preprocessCore::normalize.quantiles if available, otherwise provides a pure R implementation.

Usage

rowMeans3(x, na.rm = FALSE, ...)

colMeans3(x, na.rm = FALSE, ...)

rowVars3(x, na.rm = FALSE, ...)

colVars3(x, na.rm = FALSE, ...)

rowSds3(x, na.rm = FALSE, ...)

colSds3(x, na.rm = FALSE, ...)

colQuantiles3(x, probs = seq(0L, 1L, 0.25), ...)

rowMaxs3(
  x,
  rows = NULL,
  cols = NULL,
  na.rm = FALSE,
  dim. = dim(x),
  ...,
  useNames = TRUE
)

colSums3(x, na.rm = FALSE, ...)

rowSums3(x, na.rm = FALSE, ...)

rowMedians3(
  x,
  rows = NULL,
  cols = NULL,
  na.rm = FALSE,
  dim. = dim(x),
  ...,
  useNames = TRUE
)

colMedians3(
  x,
  rows = NULL,
  cols = NULL,
  na.rm = FALSE,
  dim. = dim(x),
  ...,
  useNames = TRUE
)

normalize.quantiles(x, copy = TRUE, keep.names = FALSE, ...)

Arguments

x

A numeric matrix where columns represent samples and rows represent features.

na.rm

Logical indicating whether to remove missing values.

...

Additional arguments (currently not used).

probs

Numeric vector of probabilities with values between 0 and 1.

rows, cols

Indices specifying a subset of rows or columns.

dim.

Dimensions of the input matrix.

useNames

Logical indicating whether to preserve output names.

copy

Logical indicating whether to work on a copy of the matrix (TRUE) or modify in-place (FALSE).

keep.names

Logical indicating whether to preserve row and column names.

Value

A numeric vector containing the requested statistic.

A matrix of quantiles with ncol(x) rows and length(probs) columns.

A numeric vector containing row maxima.

A numeric vector containing column sums.

A numeric vector containing row sums.

A numeric vector containing row medians.

A numeric vector containing column medians.

A numeric matrix of the same dimensions as x with quantile-normalized data.

See Also

preprocessCore::normalize.quantiles() for the underlying implementation

Examples

mat <- matrix(rnorm(100), nrow = 10, ncol = 10)

# Perform quantile normalization
normalized_mat <- normalize.quantiles(mat)

# Preserve original names
rownames(mat) <- paste0("Gene", 1:10)
colnames(mat) <- paste0("Sample", 1:10)
normalized_with_names <- normalize.quantiles(mat, keep.names = TRUE)


SigBridgeRUtils documentation built on Sept. 29, 2026, 5:09 p.m.