reverse_lognorm: Title

View source: R/reverse_lognorm.R

reverse_lognormR Documentation

Title

Description

Title

Usage

reverse_lognorm(
  SO,
  assay = c("RNA", "SCT"),
  nCount_RNA = Seurat::Misc(SO, slot = "RNA_count_colSums"),
  scale.factor = 10000,
  return.SO = T
)

Arguments

colsSums

Examples

## Not run: 
#### for RNA assay:
# Default LogNormalize from Seurat does this:
nCount_RNA <- Matrix::colSums(GetAssayData(SO, slot = "counts", assay = "RNA"))
# devide each column by corresponding index in nCount_RNA
norm_UMI <- sweep(Seurat::GetAssayData(SO, slot = "counts", assay = "RNA"), 2, nCount_RNA, FUN = `/`) ## test if backticks works
norm_UMI <- norm_UMI*10000
lognorm_UMI <- log1p(norm_UMI)

# to reverse (data --> Counts) one needs original nCount_RNA (colSums)
# this must be saved (e.g. Misc slot) before deleting the Count slot
# if not provided one could assume that the lowest norm_UMI
# per column equals to 1 UMI originally
norm_UMI <- expm1(GetAssayData(SO, slot = "data", assay = "RNA")) #lognorm_UMI
norm_UMI <- norm_UMI/10000
UMI_count <- sweep(norm_UMI, 2, nCount_RNA, FUN = '*')

#### for SCT assay:
# simply expm1 from data slot, see ?Seurat::SCTransform

## End(Not run)

Close-your-eyes/scexpr documentation built on April 21, 2023, 10:27 a.m.