This function calls sctransform::get_residuals.

GetResidual(
  object,
  features,
  assay = NULL,
  umi.assay = NULL,
  clip.range = NULL,
  replace.value = FALSE,
  na.rm = TRUE,
  verbose = TRUE
)

Arguments

object

A seurat object

features

Name of features to add into the scale.data

assay

Name of the assay of the seurat object generated by SCTransform

umi.assay

Name of the assay of the seurat object containing UMI matrix and the default is RNA

clip.range

Numeric of length two specifying the min and max values the Pearson residual will be clipped to

replace.value

Recalculate residuals for all features, even if they are already present. Useful if you want to change the clip.range.

na.rm

For features where there is no feature model stored, return NA for residual value in scale.data when na.rm = FALSE. When na.rm is TRUE, only return residuals for features with a model stored for all cells.

verbose

Whether to print messages and progress bars

Value

Returns a Seurat object containing Pearson residuals of added features in its scale.data

See also

Examples

data("pbmc_small") pbmc_small <- SCTransform(object = pbmc_small, variable.features.n = 20)
#> Calculating cell attributes from input UMI matrix: log_umi
#> Variance stabilizing transformation of count matrix of size 220 by 80
#> Model formula is y ~ log_umi
#> Get Negative Binomial regression parameters per gene
#> Using 220 genes, 80 cells
#> | | | 0%
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: NaNs produced
#> Warning: iteration limit reached
#> Warning: NaNs produced
#> Warning: iteration limit reached
#> Warning: NaNs produced
#> Warning: iteration limit reached
#> Warning: NaNs produced
#> Warning: iteration limit reached
#> Warning: NaNs produced
#> Warning: iteration limit reached
#> Warning: NaNs produced
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> Warning: iteration limit reached
#> | |======================================================================| 100%
#> Second step: Get residuals using fitted parameters for 220 genes
#> | | | 0% | |======================================================================| 100%
#> Computing corrected count matrix for 220 genes
#> | | | 0% | |======================================================================| 100%
#> Calculating gene attributes
#> Wall clock passed: Time difference of 0.3981743 secs
#> Determine variable features
#> Place corrected count matrix in counts slot
#> Centering data matrix
#> Set default assay to SCT
pbmc_small <- GetResidual(object = pbmc_small, features = c('MS4A1', 'TCL1A'))
#> sct.model: model1
#> Calculating residuals of type pearson for 2 genes
#> | | | 0% | |======================================================================| 100%