cellranger使用的初步探索(3)cellranger aggr

在学习cellranger aggr这一步之前,还是需要再一次复习10x Genomics的测序原理。
在cellranger aggr部分,官网(https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/using/aggregate)是这么说的:

When doing large studies involving multiple GEM wells, run cellranger count on FASTQ data from each of the GEM wells individually, and then pool the results using cellranger aggr.当你的实验涉及到多个GEM well的时候,要分别独立的把你的fastq文件运行cellranger count,之后使用cellranger aggr进行合并。

在之前的文章里,我使用的练习数据(cellranger使用的初步探索(1)),该文献的作者在介绍数据处理的时候也是说明了把每一个fastq文件分别运行cellranger count,再进行整合。

那么问题就来了,什么是GEM wells?
这个问题在我之前的一篇笔记里有涉及过(10×单细胞测序分析练习(一)),这里再加强一下记忆(记性不好),并且要进行进一步深入的理解,图片来源于陈巍学基因视频(【陈巍学基因】视频56:10X genomics分析单细胞表达):

这就是10x Genomics芯片,每一个芯片可以测8个样品。每一列就是一个样品。编号为1的,也就是sample well是放样品的;编号为2的一行,是放预制微珠的;编号为3的一行是放油的。最上面的一排孔是在制作好乳浊液之后,回收乳浊液的。

那么上面这个芯片的Gel Beads的孔里放的凝胶微珠是什么结构呢:

每一个凝胶微珠上,都连有一段特定的DNA序列。每一个微珠对应一个barcode,这也就是为什么barcode是细胞的“身份证”了。
从左到右通过这个装置,你的细胞样品就被包裹成小油滴(实际上是油包水),上图的细胞混悬液和凝胶微珠的标记写反了,感谢读者留言提醒

上面说的GEM well,就是芯片上的一个单独的区室,也就是一个油滴。也就是说,一个GEM well就是一个library。也就是说,每个油滴里=一个细胞+一个凝胶微珠(带有barcode和UMI)。说的在明白一点,只要你的实验是多个样品的时候,你就需要cellranger aggr这一步。

(一)cellranger aggr的输入文件

cellranger aggr的输入文件来自于上一步cellranger count的输出文件(特别是molecule_info.h5),并且产生一个单独的feature-barcode矩阵。当结合多个GEM wells时,每一个通道的barcode序列会被加在barcode上的GEM well suffix区分开来。

每一个GEM well是在物理上的空间划分,而barcode是不一样的(排列组合有好几百万种),在混合成油包水液滴的过程也就是从barcode库里随机抽取。为了避免这个随机抽取过程中两个GEM well抽到相同的barcode,10x Genomics将barcode整合了一个“标记”,这样有了barcode和这个ID,在feature-barcode矩阵里就可以很容易的区分这些Reads到底来源于哪个GEM了。比如说: AGACCATTGAGACTTA-1 and AGACCATTGAGACTTA-2是来自两个不同GEM well室的两个不同的barcode(即使barcode的序列一样也可以区分来源)。这个数字就可以告诉我们barcode序列的来源,也就是被加在barcode序列上的GEM well suffix。这个会在之后cellranger aggr整合后的csv文件里体现出来。

这一步值得注意的参数是 “normalize”,默认值为mapped,计算方式是对每一个要合并的样品取得「每个细胞平均mapped到多少Transcriptome」,再以最小值当做基准,依比例重新计算每个合并样品的 UMI count。若下游分析会进行其他标准化处理,可以在这一步设置为none。另外,cellranger aggr 也提供了一个batch correction 功能,但是这里官方有特別说明,此功能主要是针对「样本所采用的不同试剂版本」做校正,其他的,例如重复试验的校正是不适用的。(参考文章:單細胞定序分析介紹 (一): Cell Ranger)

(二)创建cellranger aggr所需csv文件

在运行cellranger aggr这一步之前,需要手动自己构建一个表(csv格式的),这里面包含:
(1)library_id: 文库的ID,这个ID是用来区分不同的GEM well的。
(2)molecule_h5: 你在之前cellranger count那一步的输出文件里,有一个文件是molecule_info.h5。这里要你把这个文件的路径列出来。

构建后的表应该长这样,比如我只想合并两个Tumor样品:

在你的命令行里打开这个csv文件,应该是这样的格式:

#应该是以逗号区分开的
$ cat Tumor_libraries.csv
library_id,molecule_h5
Tumor937,/gpfs/home/practice/Tumor937/molecule_info.h5
Tumor938,/gpfs/home/practice/Tumor938/molecule_info.h5

(三)运行cellranger aggr

cellranger aggr有几个参数:

代码:

$ cellranger aggr --id=Tumor \
                  --csv=Tumor_libraries.csv \
                  --normalize=mapped

在运行时,会弹出很多东西,最后如果看到以下内容,就说明运行成功了:

Outputs:
- Aggregation metrics summary HTML:       /gpfs/home/practice/Tumor/outs/web_summary.html
- Aggregation metrics summary JSON:       /gpfs/home/practice/Tumor/outs/summary.json
- Secondary analysis output CSV:          /gpfs/home/practice/Tumor/outs/analysis
- Filtered gene-barcode matrices HDF5:    /gpfs/home/practice/Tumor/outs/filtered_gene_bc_matrices_h5.h5
- Filtered gene-barcode matrices MEX:     /gpfs/home/practice/Tumor/outs/filtered_gene_bc_matrices_mex
- Filtered molecule-level info:           /gpfs/home/practice/Tumor/outs/filtered_molecules.h5
- Unfiltered gene-barcode matrices HDF5:  /gpfs/home/practice/Tumor/outs/raw_gene_bc_matrices_h5.h5
- Unfiltered gene-barcode matrices MEX:   /gpfs/home/practice/Tumor/outs/raw_gene_bc_matrices_mex
- Unfiltered molecule-level info:         /gpfs/home/practice/Tumor/outs/raw_molecules.h5
- Barcodes of cell-containing partitions: /gpfs/home/practice/Tumor/outs/cell_barcodes.csv
- Copy of the input aggregation CSV:      /gpfs/home/practice/Tumor/outs/aggregation_csv.csv
- Loupe Cell Browser file:                /gpfs/home/practice/Tumor/outs/cloupe.cloupe

Waiting 6 seconds for UI to do final refresh.
Pipestance completed successfully!

Saving pipestance info to Tumor/Tumor.mri.tgz

使用服务器200G内存,运行时间1小时左右。
下面可以看看输出文件有哪些:

$ ll
total 4500
-rw------- 1 fy04 fy04     140 Aug  9 00:58 _cmdline
-rw------- 1 fy04 fy04   22343 Aug  9 00:58 _filelist
-rw------- 1 fy04 fy04  267284 Aug  9 00:58 _finalstate
-rw------- 1 fy04 fy04     339 Aug  8 23:49 _invocation
-rw------- 1 fy04 fy04       5 Aug  8 23:49 _jobmode
-rw------- 1 fy04 fy04   30158 Aug  9 00:58 _log
-rw------- 1 fy04 fy04   25900 Aug  8 23:49 _mrosource
drwx------ 5 fy04 fy04    8192 Aug  9 00:58 outs #重点关注文件夹
-rw------- 1 fy04 fy04  141455 Aug  9 00:58 _perf
drwx------ 6 fy04 fy04    8192 Aug  9 00:57 SC_RNA_AGGREGATOR_CS
-rw------- 1 fy04 fy04   12148 Aug  9 00:58 _sitecheck
-rw------- 1 fy04 fy04       2 Aug  8 23:49 _tags
-rw------- 1 fy04 fy04      51 Aug  9 00:58 _timestamp
-rw------- 1 fy04 fy04 3697193 Aug  9 00:58 Tumor.mri.tgz
-rw------- 1 fy04 fy04      36 Aug  8 23:49 _uuid
-rw------- 1 fy04 fy04   21606 Aug  9 00:58 _vdrkill
-rw------- 1 fy04 fy04      61 Aug  8 23:49 _versions

生成的文件和之前cellranger count差不多,重要的文件也都在outs文件夹里:

到此我们就拿到了下游分析所需的基因表达矩阵(在filtered_gene_bc_matrices
_mex文件夹里)。之后就可以用R进行分析了。

你可能感兴趣的:(cellranger使用的初步探索(3)cellranger aggr)