Learn R Programming

sctransform (version 0.4.3)

get_residuals: Return Pearson or deviance residuals of regularized models

Description

Return Pearson or deviance residuals of regularized models

Usage

get_residuals(
  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
)

Value

A matrix of residuals

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 results 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 the verbosity level: 0 (silent, no messages), 1 (show messages only), or 2 (show messages and progress bars); default is 2

Examples

Run this code
# \donttest{
vst_out <- vst(pbmc, return_cell_attr = TRUE)
pearson_res <- get_residuals(vst_out, pbmc)
deviance_res <- get_residuals(vst_out, pbmc, residual_type = 'deviance')
# }

Run the code above in your browser using DataLab