Skip to contents

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)
#> The presumed scale factor: 3474, 3090, 3614, 3433, 3314, 3235, 2901, 3432, 3267, 3157
#> Warning: Scale factor is not unique. No changes to be made.
identical(raw_counts, pancreas_sub@assays$RNA$counts)
#> [1] FALSE