get_residual_var: Return variance of residuals of regularized models

View source: R/utils.R

get_residual_varR Documentation

Return variance of residuals of regularized models

Description

This never creates the full residual matrix and can be used to determine highly variable genes.

Usage

get_residual_var(
  vst_out,
  umi,
  residual_type = "pearson",
  res_clip_range = c(-sqrt(ncol(umi)), sqrt(ncol(umi))),
  min_variance = vst_out$arguments$min_variance,
  cell_attr = vst_out$cell_attr,
  bin_size = 256,
  verbosity = vst_out$arguments$verbosity,
  verbose = NULL,
  show_progress = NULL
)

Arguments

vst_out

The output of a vst run

umi

The UMI count matrix that will be used

residual_type

What type of residuals to return; can be 'pearson' or 'deviance'; default is 'pearson'

res_clip_range

Numeric of length two specifying the min and max values the residuals will be clipped to; default is c(-sqrt(ncol(umi)), sqrt(ncol(umi)))

min_variance

Lower bound for the estimated variance for any gene in any cell when calculating pearson residual; default is vst_out$arguments$min_variance

cell_attr

Data frame of cell meta data

bin_size

Number of genes to put in each bin (to show progress)

verbosity

An integer specifying whether to show only messages (1), messages and progress bars (2) or nothing (0) while the function is running; default is 2

verbose

Deprecated; use verbosity instead

show_progress

Deprecated; use verbosity instead

Value

A vector of residual variances (after clipping)

Examples


vst_out <- vst(pbmc, return_cell_attr = TRUE)
res_var <- get_residual_var(vst_out, pbmc)



ChristophH/sctransform documentation built on Oct. 22, 2023, 3:28 p.m.