Attempt to recover raw counts from the normalized matrix
Arguments
- srt
A Seurat object.
- assay
Which assay to use. If
NULL, the default assay of the Seurat object will be used. When the object also containsChromatinAssay, the default assay and additionalChromatinAssaywill be preprocessed sequentially.- 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 print the message. Default is
TRUE.
Examples
data(pancreas_sub)
pancreas_sub <- standard_scop(pancreas_sub)
#> ℹ [2026-04-26 01:52:58] Start standard processing workflow...
#> ℹ [2026-04-26 01:52:58] Checking a list of <Seurat>...
#> ! [2026-04-26 01:52:59] Data 1/1 of the `srt_list` is "unknown"
#> ℹ [2026-04-26 01:52:59] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on 1/1 of `srt_list`...
#> ℹ [2026-04-26 01:53:01] Perform `Seurat::FindVariableFeatures()` on 1/1 of `srt_list`...
#> ℹ [2026-04-26 01:53:01] Use the separate HVF from `srt_list`
#> ℹ [2026-04-26 01:53:01] Number of available HVF: 2000
#> ℹ [2026-04-26 01:53:02] Finished check
#> ℹ [2026-04-26 01:53:02] Perform `Seurat::ScaleData()`
#> ℹ [2026-04-26 01:53:02] Perform pca linear dimension reduction
#> ℹ [2026-04-26 01:53:03] Use stored estimated dimensions 1:20 for Standardpca
#> ℹ [2026-04-26 01:53:03] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#> ℹ [2026-04-26 01:53:03] Reorder clusters...
#> ℹ [2026-04-26 01:53:03] Skip `log1p()` because `layer = data` is not "counts"
#> ℹ [2026-04-26 01:53:04] Perform umap nonlinear dimension reduction
#> ℹ [2026-04-26 01:53:04] Perform umap nonlinear dimension reduction using Standardpca (1:20)
#> ℹ [2026-04-26 01:53:08] Perform umap nonlinear dimension reduction using Standardpca (1:20)
#> ✔ [2026-04-26 01:53:13] Standard processing workflow completed
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)
#> ℹ [2026-04-26 01:53:15] Data type is log-normalized
#> ℹ [2026-04-26 01:53:15] The data is presumed to be log-normalized
#> ℹ [2026-04-26 01:53:15] Perform "expm1" on the raw data
new_counts <- GetAssayData5(
pancreas_sub,
assay = "RNA",
layer = "counts"
)
identical(raw_counts, new_counts)
#> [1] TRUE