RecoverCounts: Attempt to recover raw counts from the normalized matrix.

View source: R/SCP-workflow.R

RecoverCountsR Documentation

Attempt to recover raw counts from the normalized matrix.

Description

Attempt to recover raw counts from the normalized matrix.

Usage

RecoverCounts(
  srt,
  assay = NULL,
  trans = c("expm1", "exp", "none"),
  min_count = c(1, 2, 3),
  tolerance = 0.1,
  sf = NULL,
  verbose = TRUE
)

Arguments

srt

A Seurat object.

assay

Name of assay to recover counts.

trans

The transformation function to applied when data is presumed to be log-normalized.

min_count

Minimum UMI count of genes.

tolerance

When recovering the raw counts, the nCount of each cell is theoretically calculated as an integer. However, due to decimal point preservation during normalization, the calculated nCount is usually a floating point number close to the integer. The tolerance is its difference from the integer. Default is 0.1

sf

Set the scaling factor manually.

verbose

Whether to show messages.

Examples

data("pancreas_sub")
raw_counts <- pancreas_sub@assays$RNA@counts

# Normalized the data
pancreas_sub <- Seurat::NormalizeData(pancreas_sub)

# Now replace counts with the log-normalized data matrix
pancreas_sub@assays$RNA@counts <- pancreas_sub@assays$RNA@data

# Recover the counts and compare with the raw counts matrix
pancreas_sub <- RecoverCounts(pancreas_sub)
identical(raw_counts, pancreas_sub@assays$RNA@counts)

zh542370159/SCP documentation built on Nov. 22, 2023, 2:34 a.m.