使用mixcr构建免疫组库及下游分析

免疫组库(Immune Repertoire,IR)是指个体在某个特定时间其循环系统中所有多样性的T细胞和B细胞的总和,即V(D)J序列多样性的集合。免疫组库分析是指运用高通量测序技术对个体免疫组库多样性分析,以及对T细胞和B细胞独特性分析。
mixcr允许多种数据输入,特异性免疫组库测序或RNA-seq测序都可以作为输入。

mixcr工作流程

实例展示

下载8个新冠样本8个健康样本RNA-seq单端测序作为输入。


批量下载数据:可参考RNA-seq转录组差异分析及可视化

#下载数据
prefetch -O /path to out/ --option-file SRR_Acc_List.txt
#将NCBI下载的数据转为fastq格式
cat SRR_Acc_List.txt|while read id;do fastq-dump --gzip -O /path to out/ /path to input/${id}.sra;done
#path to out:输出路径
#path to input:输入文件路径
#mixcr non-enriched
#single-read
cat SRR_Acc_List.txt|while read name;do mkdir ${name};done
cat SRR_Acc_List.txt|while read name;do mixcr analyze shotgun -s hsa --starting-material rna --only-productive --impute-germline-on-export --report ./report/${name}.report ./rawdata/${name}.fastq.gz ./results/${name}/${name};done
#运行时间比较长,16个样本大约用时35h。
#推荐使用多线程分开提交任务运行。
mixcr输出结果

得到mixcr的输出结果后vdjtools与immunarch(R包)都可以用来进行可视化输出。



1.准备工作

mixcr与vdjtools是基于java平台开发的处理从原始序列到定量克隆型的大量免疫组数据的免疫分析软件,在使用前要确保java环境是ok的。

最低配置

  • Any Java-enabled platform (Windows, Linux, Mac OS X)
  • Java version 7 or higher (download from Oracle web site)
  • 1–16 Gb RAM (depending on number of clones in the sample)

检查环境并下载软件

官网下载 Java Runtime Environment,jre是java的运行环境。

java -version #检查java环境是否ok

官网下载mixcr的压缩包并解压,并添加至环境变量。
若未添加至环境变量,每次运行时需使用此代码

java -jar path_to_mixcr\mixcr.jar ...  #path_to_mixcr = 解压mixcr的地址

2.MIXCR

MIXCR分析流程主要包含三个程序步骤,分别是alignassembleexport

  • align:将测序结果比对到TCR或BCR的V,D,J和C的参考基因上。
  • assemble:将上一步得到的结果进行组装,可以得到特定的基因区域序列,如CDR3序列。
  • export:将比对结果或组装结果输出,得到可阅读的txt文件。

MIXCR支持输入单端或双端的测序文件,可使用原始测序文件也可使用质控后的文件,质控方法和RNA-seq差异分析中的方法一致,使用fastp或者trimmomatic进行质控,参考RNA-seq转录组差异分析及可视化。

3.一站式流程使用

MIXCR软件提供了两种analysis模式,包含了上述三种参数,一站式进行分析。

  • analyze amplicon: for analysis of targeted TCR/IG library amplification (5’RACE, Amplicon, Multiplex, etc).
  • analyze shotgun: for analysis of random fragments (RNA-Seq, Exome-Seq, etc).
#environment:Linux
# for enriched targeted TCR/IG libraries
mixcr analyze amplicon
    -s hsa \ # or mmu
    --starting-material dna  \#or rna
    --5-end v-primers \#or no-v-primers
    --3-end j-primers  \#or j-c-intron-primers or c-primers
    --adapters adapters-present \#or no-adapters
    R1.fastq.gz R2.fastq.gz  ./path/mixcr_result/sample1
Option                           Description
-s,--species hsa (or HomoSapiens), mmu (or MusMusculus), rat (currently only TRB, TRA and TRD are supported), or any species from IMGT ® library, if it is used (see here import segments).
--starting-material rna or dna
--5-end no-v-primers(e.g. 5’RACE with template switch oligo )or v-primers
--3-end j-primers or j-c-intron-primers or c-primers
--adapters adapters-present or no-adapters

The following parameters are optional:

Option                                     Default Description
--report analysis_name.report Report file.
--receptor-type xcr By default, all T- and B-cell receptor chains are analyzed.Possible values are:xcr (all chains), tcr, bcr, tra, trb, trg, trd, igh, igk, igl.
--contig-assembly false Whether to assemble full receptor sequences (assembleContigs). This option may slow down the computation.
--impute-germline-on-export false Use germline segments (printed with lowercase letters) for uncovered gene features.
--region-of-interest CDR3 MiXCR will use only reads covering the whole target region; reads which partially cover selected region will be dropped during clonotype assembly. All non-CDR3 options require long high-quality paired-end data. See Gene features and anchor points for details.
--only-productive false Filter out-of-frame and stop-codons in export
--align Additional parameters for align step specified with double quotes (e.g –align “–limit 1000” –align “-OminSumScore=100”)
--assemble Additional parameters for assemble step specified with double quotes (e.g –assemble “-ObadQualityThreshold=0”).
--assembleContigs Additional parameters for assembleContigs step specified with double quotes.
--export Additional parameters for exportClones step specified with double quotes.
# for non-enriched or random fragments
mixcr analyze shotgun
    -s hsa # or mmu
    --starting-material dna  #or rna
    [OPTIONS] input_file1 [input_file2] analysis_name
Option                                     Default Description
--report analysis_name.report Report file.
--receptor-type xcr Dedicated receptor type for analysis. By default, all T- and B-cell receptor chains are analyzed. MiXCR has special aligner kAligner2, which is used when B-cell receptor type is selected. Possible values for --receptor-type are: xcr (all chains), tcr, bcr, tra, trb, trg, trd, igh, igk, igl.
--contig-assembly false Whether to assemble full receptor sequences (assembleContigs). This option may slow down the computation.
--impute-germline-on-export false Use germline segments (printed with lowercase letters) for uncovered gene features.
--only-productive false Filter out-of-frame and stop-codons in export
--assemble-partial-rounds 2 Number of consequent assemblePartial executions.
--do-not-extend-alignments Do not perform extension of good TCR alignments.
--align Additional parameters for align step specified with double quotes (e.g –align “–limit 1000” –align “-OminSumScore=100”)
--assemblePartial Additional parameters for assemblePartial step specified with double quotes.
--extend Additional parameters for extend step specified with double quotes.
--assemble Additional parameters for assemble step specified with double quotes (e.g –assemble “-ObadQualityThreshold=0”).
--assembleContigs Additional parameters for assembleContigs step specified with double quotes.
--export Additional parameters for exportClones step specified with double quotes.

上述两种分析模式可满足大多要求,更多参数细节参考mixcr用户手册

4.逐级分析

没有特殊的分析需求这部分可略过。

4.1 Alignment

mixcr align [options] input_file1 [input_file2] output_file.vdjca
options                  default value description
-r,--report 输出文件名称
-l,--loci ALL 比对的靶点,可由,连接多个。IGH,IGL,IGK, TRA, TRB, TRG, TRD, IG (for all immunoglobulin loci),TCR (for all T-cell receptor loci), ALL (for all loci) .
-s,--specoes HomoSapiens 同上个表格
-p,--parameters default defaultorrna-seq,rna-seq是专门为分析rna-seq数据而优化的。
-i,--diff-loci 接受与V和J基因不同loci的比对(在默认情况下,这种比对被丢弃)。
-t number of available CPU cores 线程数
-n,--limit 只处理输入文件的前-n个序列。
-Oparameter = value 比对区域,具体见下面表格

Alignment parameters

Parameters     Default value Description
vParameters.geneFeatureToAlign VRegion region in V gene which will be used as target in align
dParameters.geneFeatureToAlign DRegion region in D gene which will be used as target in align
jParameters.geneFeatureToAlign JRegion region in J gene which will be used as target in align
cParameters.geneFeatureToAlign CRegion region in C gene which will be used as target in align

-OvParameters.geneFeatureToAlign是比对过程中的一个重要参数,有三个常用value。

  • – VRegion(默认值):如果你的免疫组库是使用多重PCR构建的5端文库则使用这个选项。
  • – VTranscript:以RNA为起始材料进行的非模板特异性扩增,例如5'RACE。使用这个选项有助于提高测序信息5'端的利用率,有助于提高V基因的准确性。
  • – VGene:DNA为起始材料,5'端的信息(包括V区内含子,leader sequence,5'UTR)应该存在于测序信息中。

如果想获得TCR或BCR的全部克隆型(包括FR和CDR区域),使用- VTranscript或者- VGene。

4.1.1 分析RNA-seq数据

Analysis of RNA-Seq data performed with -p rna-seq option is almost equivalent to the following set of aligners parameters:

  • (most important) turned off floating bounds of V and J alignments:
    -OvParameters.parameters.floatingLeftBound=false
    -OjParameters.parameters.floatingRightBound=false
  • higher thresholds:
    -OvParameters.parameters.absoluteMinScore=80 (was 40)
    -OjParameters.parameters.absoluteMinScore=70 (was 40)
    -OminSumScore=200 (was 120; see below)
  • more strict scoring for all alignments (V, J, C):
    -OxParameters.parameters.scoring.gapPenalty=-21
    -OxParameters.parameters.scoring.subsMatrix=’simple(match=5,mismatch=-12)’

4.2 Assemble clones

这一步使用到上一步得到的.vdjca文件,提取特定的基因序列,最后输出.clns文件。

mixcr assemble [options] alignments.vdjca output.clns
options                         default value description
-r --report Report file name.
-t --threads number of available CPU cores Number of processing threads.
-a, --write-alignments Save initial alignments and alignments <> clones mapping in the resulting .clna file.
-Oparameter=value Overrides default value of assembler parameter (see next subsection).

-OassemblingFeatures参数用来设置需要组装的区域。默认值是CDR3。如果要组装全序列,使用VDJRegion选项。

mixcr assemble -OassemblingFeatures="[V5UTR+L1+L2+FR1,FR3+CDR3]" alignments.vdjca output.clns

(note:assemblingFeatures must cover CDR3).

Other global parameters are:

Parameter     Default value Description
minimalClonalSequenceLength    12 Minimal length of clonal sequence
badQualityThreshold 20 Minimal value of sequencing quality score: nucleotides with lower quality are considered as “bad”. If sequencing read contains at least one “bad” nucleotide within the target gene region, it will be deferred at initial assembling stage, for further processing by mapper.
maxBadPointsPercent 0.7 Maximal allowed fraction of “bad” points in sequence: if sequence contains more than maxBadPointsPercent “bad” nucleotides, it will be completely dropped and will not be used for further processing by mapper. Sequences with the allowed percent of “bad” points will be mapped to the assembled core clonotypes. Set -OmaxBadPointsPercent=0 in order to completely drop all sequences that contain at least one “bad” nucleotide.
qualityAggregationType Max Algorithm used for aggregation of total clonal sequence quality during assembling of sequencing reads. Possible values: Max (maximal quality across all reads for each position), Min (minimal quality across all reads for each position), Average (average quality across all reads for each position), MiniMax (all letters has the same quality which is the maximum of minimal quality of clonal sequence in each read).
minimalQuality 0 Minimal allowed quality of each nucleotide of assembled clone. If at least one nucleotide in the assembled clone has quality lower than minimalQuality, this clone will be dropped (remember that qualities of reads are aggregated according to selected aggregation strategy during core clonotypes assembly; see qualityAggregationType).
addReadsCountOnClustering false Aggregate cluster counts when assembling final clones: if addReadsCountOnClustering is true, then all children clone counts will be added to the head clone; thus head clone count will be a total of its initial count and counts of all its children. Refers to further clustering strategy (see below). Does not refer to mapping of low quality sequencing reads described above.

example:

mixcr assemble -ObadQualityThreshold=10 alignments.vdjca output.clns
mixcr assemble -OmaxBadPointsPercent=0 alignments.vdjca output.clns #In order to prevent mapping of low quality reads (filter them off) one can set maxBadPointsPercent to zero

4.3Export

将比对结果或组装结果输出,得到可阅读的txt文件。

#
mixcr exportAlignments [options] alignments.vdjca alignments.txt
mixcr exportClones [options] clones.clns clones.txt

5.结果解读

参考mixcr官方手册export部分。

可视化处理

参考使用vdjtools进行免疫组库分析

你可能感兴趣的:(使用mixcr构建免疫组库及下游分析)