1. 数据集的加载

# ### batchelor ##
# if (!require("BiocManager", quietly = TRUE))
#   install.packages("BiocManager")
#
# BiocManager::install("batchelor")library(batchelor)
library(scRNAseq)
sce1 <- ZeiselBrainData()
sce2 <- TasicBrainData()library(scuttle)
# 过滤,取子集
sce1 <- addPerCellQC(sce1, subsets=list(Mito=grep("mt-", rownames(sce1))))
qc1 <- quickPerCellQC(colData(sce1), sub.fields="subsets_Mito_percent")
sce1 <- sce1[,!qc1$discard]sce2 <- addPerCellQC(sce2, subsets=list(Mito=grep("mt_", rownames(sce2))))
qc2 <- quickPerCellQC(colData(sce2), sub.fields="subsets_Mito_percent")
sce2 <- sce2[,!qc2$discard]# 行:共同的基因,取子集
universe <- intersect(rownames(sce1), rownames(sce2))
sce1 <- sce1[universe,]
sce2 <- sce2[universe,]

2. 消除批间测序覆盖度(coverage)差异

# Per-batch scaling normalization
# to remove systematic differences in coverage across batches
# to simplify downstream comparisons.
out <- multiBatchNorm(sce1, sce2)
sce1 <- out[[1]]
sce2 <- out[[2]]

3. 差异表达基因分析

找出差异大的基因,用于下游的批间效应校正。

library(scran)
# modelGeneVar {scran}:Model the per-gene variance
dec1 <- modelGeneVar(sce1)
dec2 <- modelGeneVar(sce2)
combined.dec <- combineVar(dec1, dec2)
# 基因表达差异从大到小排序,选择前n个。
chosen.hvgs <- getTopHVGs(combined.dec, n=5000)

4. 批次差异校正

Usage

correctExperiments(...,batch = NULL,restrict = NULL,subset.row = NULL,correct.all = FALSE,assay.type = "logcounts",PARAM = FastMnnParam(),combine.assays = NULL,combine.coldata = NULL,include.rowdata = TRUE,add.single = TRUE
)
combined <- correctExperiments(A=sce1, B=sce2, PARAM=FastMnnParam ())
# 等同于
combined <- fastMNN(A=sce1, B=sce2)### 其他方法
# Using fewer genes as it is much, much slower.
fewer.hvgs <- head(order(combined.dec$bio, decreasing=TRUE), 100)
classic.out <- correctExperiments(A=sce1, B=sce2,subset.row=fewer.hvgs,PARAM=ClassicMnnParam ())
classic.out <- mnnCorrect(sce1, sce2, subset.row=fewer.hvgs)rescale.out <- correctExperiments(A=sce1, B=sce2, PARAM=RescaleParam ())
rescale.out <- rescaleBatches(sce1, sce2)regress.out <- correctExperiments(A=sce1, B=sce2, PARAM=RegressParam ())
regress.out <- regressBatches(sce1, sce2)
## assay(combined)[1:2,1:3] 不同于assay(sce1)[1:2,1:3]以及
# logcounts(sce1)[1:2,1:3],已经去除了批次效应# PARAM:A BatchelorParam object specifying the batch correction method
# to dispatch to, and the parameters with which it should be run.
# ClassicMnnParam will dispatch to mnnCorrect;
# FastMnnParam will dispatch to fastMNN;
# RescaleParam will dispatch to rescaleBatches;
# and RegressParam will dispatch to regressBatches.

5. 表达谱数据降维可视化

library(scater)
set.seed(100)# 没有去除批次效应的数据,可视化展示
combined <- runPCA(combined, subset_row=chosen.hvgs)
combined <- runTSNE(combined, dimred="PCA")
plotPCA(combined, colour_by="batch")
plotTSNE(combined, colour_by="batch")
# 去除批次效应后的数据可视化
# dim(reducedDim(combined, "corrected"))
combined <- runTSNE(combined, dimred="corrected")
plotTSNE(combined, colour_by="batch")set.seed(101)
f.out <- fastMNN(A=sce1, B=sce2, subset.row=chosen.hvgs)
f.out3 <- fastMNN(A=sce1, B=sce2)
str(reducedDim(f.out, "corrected")) # 命名rle(f.out$batch)
#table(f.out$batch)set.seed(103)
f.out <- runTSNE(f.out, dimred="corrected")
plotTSNE(f.out, colour_by="batch")

5. 查看消除批次效应后的表达量数据

# 查看校正后基因的表达量
cor.exp <- assay(f.out)[1,]
hist(cor.exp, xlab="Corrected expression for gene 1", col="grey80")assay(combined)# counts(combined)[2,1:2874] # 同 counts(sce1)[2,]
# logcounts(combined)[2,1:2874] # 同 logcounts(sce1)[2,]

batchelor包去除单细胞RNA-seq数据批次效应相关推荐

  1. splatter包生成单细胞RNA测序数据

    Splatter是一个模拟单细胞RNA测序计数数据的软件包.它提供了一个简单的界面,用于创建可复制且文档充分的复杂模拟.可以从真实数据估计参数,并提供用于比较真实数据集和模拟数据集的函数. # if ...

  2. 【R语言】Splatter,一个用于简单模拟单细胞RNA测序数据的R包

    Splatter是一个用于模拟单细胞RNA测序数据的R包,本文概述并介绍Splatter的功能 一.参数功能 名称 功能 说明 可以通过splatEstimate函数估计 备注 nGenes -> ...

  3. 基因表达数据批次效应去除方法的研究进展

    基因表达数据批次效应去除方法的研究进展 李飒 , 赵毅强 摘要:在组学和大数据时代,整合分析材料相同但时间.平台.方法.技术和实验室等不同批次的表达数据集将成为常态.但是,不同批次数据集由于非生物因素 ...

  4. BatchQC包可视化分析去除组学数据批次效应

    BatchQC优势:网页方式对数据操作并进行可视化展示,从而确定是否有批次效应以及去除后的数分布等.初步分析包括数据可视化.层次聚类.主成分分析(PCA)和显著性检验等. 1. 加载包 # 安装 if ...

  5. 去除RNA-seq数据批次效应

    整合不同的表达谱数据时,往往需要查看和去除批次效用.可以根据样本的信息:批次,建库方法.测序方法等,作图查看这些因素是否有影响.去除 batch effect 后再研究不同处理下的差异表达基因,可以减 ...

  6. 生信论文分享:通过稳健矩阵分解对单细胞rna测序数据进行插值

    题目:scRMD: imputation for single cell RNA-seq data via robust matrix decomposition 出处:bioinformatics, ...

  7. 文献阅读 | 基于单细胞RNA测序数据的谱系追踪

    Overcoming Genetic Drop-outs in Variants-based Lineage Tracing from Single-cell RNA Sequencing Data ...

  8. SingleR包注释单细胞数据

    SingleR包通过利用纯细胞类型的参考转录组数据集独立推断每个单细胞的起源细胞,从单细胞RNA测序数据执行无偏细胞类型识别. 1. 载入单细胞数据 # if (!requireNamespace(& ...

  9. 重磅综述:三万字长文读懂单细胞RNA测序分析的最佳实践教程 (原理、代码和评述)

    原文链接: https://www.embopress.org/doi/10.15252/msb.20188746 主编评语 这篇文章最好的地方不只在于推荐了工具,提供了一套分析流程,更在于详细介绍了 ...

最新文章

  1. SPOJ - COT Count on a tree(LCA+主席树+离散化)
  2. P3803 【模板】多项式乘法(FFT)
  3. ExtJs 分组表格控件----监听
  4. Oracle数据库物理存储结构管理遇到的问题与解决
  5. java开发工作经历_开发人员在寻找第二份工作时会经历什么
  6. linux 显示套接字统计信息,Linux 命令 - ss: 查看套接字统计信息
  7. 解决Maven的jar包冲突问题
  8. oracle 闪回技术
  9. 都是过客,相煎何急?
  10. sqlite 表与表之间的关系_第33章 Django多表关系之一对一
  11. (附源码)app订餐APP 毕业设计 190711
  12. 计算机双硬盘安装需要跳线吗,双硬盘安装图文教程
  13. 阿里巴巴技术大牛赏鉴
  14. malloc函数详解
  15. java生成zipf分布_用于文本生成的Java中的Zipf定律 – 太慢了
  16. Ansible Tests详解
  17. OpenCV开发笔记(六十一):红胖子8分钟带你深入了解Shi-Tomasi角点检测(图文并茂+浅显易懂+程序源码)
  18. 寒冰老师 计算机 山西,计算机科学与技术口号, 计算机培训小组口号
  19. 美国医院权威评估体系
  20. [构造] Codeforces Gym 101173 CERC 16 K BZOJ 4796 Key Knocking

热门文章

  1. 计算机书籍-R语言机器学习预测分析实战
  2. angularjs 让当前路由重新加载_Vuerouter(路由)
  3. 彻底剖析室内、室外激光SLAM关键算法原理、代码和实战(cartographer+LOAM+LIO-SAM)
  4. 计算机视觉来看看苏伊士运河堵船(船舶检测)
  5. python 连接mysql数据库
  6. javaScript中的提示对话框
  7. Nat. Commun | 用于全基因组药物重定位的系统网络算法
  8. Linux(CentOS 7_x64位)系统下安装Xmgrace
  9. php接口 汉字出错 空,php接口开发时,数据解析失败问题,字符转义,编码问题(示例代码)...
  10. 如何在游标里控制条件_热处理精密渗碳里的碳势如何控制