Attempt to recover raw counts from the normalized matrix.
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 <- GetAssayData5(
pancreas_sub,
assay = "RNA",
layer = "counts"
)
# Normalized the data
pancreas_sub <- Seurat::NormalizeData(pancreas_sub)
#> Normalizing layer: counts
# Now replace counts with the log-normalized data matrix
data <- GetAssayData5(
pancreas_sub,
assay = "RNA",
layer = "data"
)
new_pancreas_sub <- SeuratObject::SetAssayData(
object = pancreas_sub,
layer = "counts",
new.data = data,
assay = "RNA"
)
# Recover the counts and compare with the raw counts matrix
pancreas_sub <- RecoverCounts(new_pancreas_sub)
#> ℹ [2025-07-02 02:54:30] The data is presumed to be log-normalized.
#> ℹ [2025-07-02 02:54:30] Perform expm1 on the raw data.
#> ℹ [2025-07-02 02:54:30] The presumed scale factor: 10000
new_counts <- GetAssayData5(
pancreas_sub,
assay = "RNA",
layer = "counts"
)
identical(raw_counts, new_counts)
#> [1] TRUE