Skip to contents

Calculate pearson residuals of a negative binomial sctransform model. Normalized values are calculated as (X - mu) / sqrt(mu + mu^2/theta). mu is calculated as cell_read_counts * gene_beta.

Usage

sctransform_pearson(
  mat,
  gene_theta,
  gene_beta,
  cell_read_counts,
  min_var = -Inf,
  clip_range = c(-10, 10),
  columns_are_cells = TRUE,
  slow = FALSE
)

Arguments

mat

IterableMatrix (raw counts)

gene_theta

Vector of per-gene thetas (overdispersion values)

gene_beta

Vector of per-gene betas (expression level values)

cell_read_counts

Vector of total reads per (umi count for RNA)

min_var

Minimum value for clipping variance

clip_range

Length 2 vector of min and max clipping range

columns_are_cells

Whether the columns of the matrix correspond to cells (default) or genes

slow

If TRUE, use a 10x slower but more precise implementation (default FALSE)

Value

IterableMatrix

Details

The parameterization used is somewhat simplified compared to the original SCTransform paper, in particular it uses a linear-scale rather than log-scale to represent the cell_read_counts and gene_beta variables. It also does not support the addition of arbitrary cell metadata (e.g. batch) to add to the negative binomial regression.