对应原版教程第7章http://bioconductor.org/books/release/OSCA/overview.html 标准化是在剔除不合格细胞之后,尽可能消除细胞文库间大小的差异性,从而得到准确、有意义的分析结果。一起来学习吧~
笔记要点
sce.zeisel
# dim: 19839 2816
# assays(1): counts
(1)首先计算每个细胞文库的大小
lib.size=apply(counts(sce.zeisel), 2,sum)
head(lib.size)
#1772071015_C02 1772071017_G12 1772071017_A05 1772071014_B06 1772067065_H06 1772071017_E02
# 22354 22869 32594 33525 21694 25919
(2)计算所有细胞文库均值【参考标准】
mean(lib.size)
#15550.11
(3)计算每个细胞的细胞文库size.factor
lib.sf=lib.size/mean(lib.size)
head(lib.sf)
# 1772071015_C02 1772071017_G12 1772071017_A05 1772071014_B06 1772067065_H06 1772071017_E02
# 1.437546 1.470664 2.096062 2.155933 1.395102 1.666805
如上结果表示相对每个细胞文库相对于平均细胞文库大小的比例。
library(scater) #一步计算
lib.sf.zeisel <- librarySizeFactors(sce.zeisel)
summary(lib.sf.zeisel)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 0.1757 0.5680 0.8680 1.0000 1.2783 4.0839
#均值一定为0
#值大于1的需要缩小;小于1的需要放大
(4)然后根据每个细胞的细胞文库size factor对该细胞的所有基因表达进行归一化处理,即基因表达量除以细胞文库因子。这里的“一”就代表平均细胞文库大小。
#以第一个细胞为例
normalized <- counts(sce.zeisel[,1])/lib.sf[1]
#一般取log2
log_normalized=log2(normalized + 1)
如上就得到了最终标准化后的表达矩阵。
logNormCounts
一步完成sce.zeisel <- logNormCounts(sce.zeisel)
assays(sce.zeisel)
#List of length 2
#names(2): counts logcounts
counts(sce.zeisel)[1:4,1:4]
logcounts(sce.zeisel)[1:4,1:4]
如上结果,标准化后的结果保存在logcounts assay里面
(1)在使用文库标准化size factor时,有一个潜在的假设就是balanced differentially expressed genes,在某一细胞中若存在某些基因表达上调,那么一定会存在某些基因下调。
(2)但是单细胞测序中,往往会出现imbalanced DEG,即比较多的出现上调基因或者下调基因,从而使原本的non-DEG变成DEG。术语称之为composition bias
(3) 从对之后的分析影响来看,作者认为composition bias
对于单细胞之后的聚类分群、Top marker gene结影响不会很大。但如果想进行单基因水平的分析,还是最好消除这种误差。
(4) 如何最大化避免composition bias
DESeq2
包的estimateSizeFactorsFromMatrix()
函数、edgeR
包的calcNormFactors()
函数会考虑到这种误差。它们主要是假设大部分的基因均为non-DEG,所以当一个测序结果里的大部分基因出现相对于对照组的系统偏移时,会认为是composition bias
,计算合适的size factor予以去除。calculateSumFactors()
函数的cluster
参数。主要是假设每个cluster间为non-DE,先对cluster总体的pool-based size factor的标准化;再对每个cluster里的细胞分别进行cell-based size factor标准化。library(scran)
set.seed(100)
clust.zeisel <- quickCluster(sce.zeisel)
table(clust.zeisel)
deconv.sf.zeisel <- calculateSumFactors(sce.zeisel, cluster=clust.zeisel)
sce.zeisel <- computeSumFactors(sce.zeisel, cluster=clust.zeisel, min.mean=0.1)
sce.zeisel <- logNormCounts(sce.zeisel)
computeSpikeFactors()
,示例在原教程里有,这里就不多展开了。