使用Hisat2, Bowtie, Bowtie2和BWA对PE150进行比对-细菌转录组实战

一、基因组下载及索引构建

1.1下载基因组

我下载的是支原体基因组,http://bacteria.ensembl.org/index.html
Mycoplasma hyorhinis
Mycoplasma arginini

1.2 软件安装

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh#亲测可用
bash Miniconda3-latest-Linux-x86_64.sh
conda install -c bioconda hisat2
conda install -c bioconda bowtie
conda install -c bioconda bowtie2
conda install -c bioconda bwa

1.3 建立索引文件

参考:https://www.jianshu.com/p/89b35626befa

1.3.1 Hisat2

hisat2-build -p 2 Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel.fa Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel

-p 线程
运行完成后,生成后缀名为ht2的8个文件。
使用帮助:

hisat2-build --usage

1.3.2 Bowtie

bowtie-build --threads 2 Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel.fa Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel

--threads,线程
运行完成后,生成后缀名为ebwt的6个文件。
使用帮助:

bowtie-build --usage

1.3.3 Bowtie2

bowtie2-build --threads 2 Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel.fa Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel

--threads,线程
运行完成后,生成后缀名为bt2的6个文件。
使用帮助:

bowtie2-build --usage

1.3.4 BWA

bwa index -p Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel
Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel.fa

-p,prefix of the index,指定生成index的前缀名。
运行完成之后,会生成后缀名为bwt,pac,ann,amb,sa 的5个文件。
使用帮助:

bwa index

二、比对

比对文件含有58370545对reads,或者说58370545条fragment,双末端测序。

2.1 Hisat2

ls *1.clean.fq.gz |while read id
do
hisat2 -t -q -p 2 -X 500 \
-x /media/luozhixin/本地磁盘/bioinfomatics/INDEX/hisat2/Mycoplasma_hyorhinis_sk76/Mycoplasma_hyorhinis_sk76.ASM3136 \
-1 $id -2 ${id%_*}_2.clean.fq.gz 2>${id%_*}.hisat2.log \
|samtools sort -@ 2 -o ${id%_*}_ht2p.bam
done

-t,输出载入index和reads比对所花的时间
-q,输入为fastq文件
-p,指定线程数
-X,指定fragment的最大长度(最小长度为-I),默认500,设置以后,不支持gap比对,-X和-I数值相差越大,运行越慢
-x,指定索引文件
-1,指定双端测序中第一个文件
-2,指定双端测序中第二个文件
-S,指定输出sam文件的文件名

比对结果

Time loading forward index: 00:00:00
Time loading reference: 00:00:00
Multiseed full-index search: 00:40:12
58370545 reads; of these:
  58370545 (100.00%) were paired; of these:
    46328683 (79.37%) aligned concordantly 0 times
    12021906 (20.60%) aligned concordantly exactly 1 time
    19956 (0.03%) aligned concordantly >1 times
    ----
    46328683 pairs aligned concordantly 0 times; of these:
      4284 (0.01%) aligned discordantly 1 time
    ----
    46324399 pairs aligned 0 times concordantly or discordantly; of these:
      92648798 mates make up the pairs; of these:
        92458697 (99.79%) aligned 0 times
        188110 (0.20%) aligned exactly 1 time
        1991 (0.00%) aligned >1 times
20.80% overall alignment rate
Time searching: 00:40:13
Overall time: 00:40:13

2.2 Bowtie

-n比对模式

ls *1.clean.fq.gz |while read id
do
bowtie -t -p 2 -q -n 3 -l 28 -X 500 -a --best --strata /media/luozhixin/0000678400004823/Indexs/bowtie/Mycoplasma_hyorhinis_sk76/Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel \
-1 $id -2 ${id%_*}_L1.2.clean.fq.gz \
2>${id%_*}.bowtie.log\
|samtools sort -@ 2 -o ${id%%.*}_btp.bam
done

-t ,打印每个阶段花费的时间
-p,线程数(或--threads)
-n,-n比对模式,种子区错配的碱基数
-l,左侧至高质量种子区的碱基数,设置越大运行越快
-X,指定fragment的最大长度(最小长度为-I),默认为250
-q,指定输入为fastq文件(-f,指定输入为fasta文件)
-a --best --strata,有多个比对结果时,只报告所有比对结果中匹配度最高的。
-1,指定双端测序中第一个文件
-2,指定双端测序中第二个文件(单端数据用--12)
-S,指定输出sam文件的文件名

比对结果

Time loading reference: 00:00:00
Time loading forward index: 00:00:00
Time loading mirror index: 00:00:00
Seeded quality full-index search: 01:35:23
# reads processed: 58370545
# reads with at least one reported alignment: 10944515 (18.75%)
# reads that failed to align: 47426030 (81.25%)
Reported 10967021 paired-end alignments
Time searching: 01:35:24
Overall time: 01:35:24

-v比对模式

ls *1.clean.fq.gz |while read id
do
bowtie -t -p 2 -q -v 3 -X 500 -a --best --strata \
/media/luozhixin/0000678400004823/Indexs/bowtie/Mycoplasma_hyorhinis_sk76/Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel \
-1 $id -2 ${id%_*}_L1.2.clean.fq.gz  \
2>${id%_*}.bowtie.log \
|samtools sort -@ 2 -o ${id%%.*}_btp.bam
done

-t ,打印每个阶段花费的时间
-p,线程数(或--threads)
-v,-v比对模式,比对不超过v个碱基错配
-X,指定fragment的最大长度(最小长度为-I),默认为250
-q,指定输入为fastq文件(-f,指定输入为fasta文件)
-a --best --strata,有多个比对结果时,只报告所有比对结果中匹配度最高的。
-1,指定双端测序中第一个文件
-2,指定双端测序中第二个文件(单端数据用--12)
-S,指定输出sam文件的文件名

比对结果

2.3 Bowtie2

ls *1.clean.fq.gz |while read id
do
bowtie2 -t -p 2 -q --fast-local -X 500 -x /media/luozhixin/0000678400004823/Indexs/bowtie2/Mycoplasma_hyorhinis_sk76/Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel \
-1 $id -2 ${id%_*}_L1.2.clean.fq.gz \
2>${id%_*}.bowtie2.log\
|samtools sort -@ 2 -o ${id%%.*}_bt2p.bam
done

-t ,打印每个阶段花费的时间
-p,线程数(或--threads)
-q,指定输入为fastq文件,默认。(-f,指定输入为fasta文件)
-X,指定fragment的最大长度(最小长度为-I),默认为500
--fast-local,局部快速比对
-x 指定索引文件
-1,指定双端测序中第一个文件
-2,指定双端测序中第二个文件(单端数据用-U)
-S,指定输出sam文件的文件名

比对结果:

Time loading reference: 00:00:00
Time loading forward index: 00:00:00
Time loading mirror index: 00:00:00
Multiseed full-index search: 02:18:18
58370545 reads; of these:
  58370545 (100.00%) were paired; of these:
    45474574 (77.91%) aligned concordantly 0 times
    12836595 (21.99%) aligned concordantly exactly 1 time
    59376 (0.10%) aligned concordantly >1 times
    ----
    45474574 pairs aligned concordantly 0 times; of these:
      11476 (0.03%) aligned discordantly 1 time
    ----
    45463098 pairs aligned 0 times concordantly or discordantly; of these:
      90926196 mates make up the pairs; of these:
        90861721 (99.93%) aligned 0 times
        63533 (0.07%) aligned exactly 1 time
        942 (0.00%) aligned >1 times
22.17% overall alignment rate
Time searching: 02:18:18
Overall time: 02:18:18

2.4 BWA

ls *1.clean.fq.gz |while read id
do
bwa mem -t 2 /media/luozhixin/0000678400004823/Indexs/BWA/Mycoplasma_hyorhinis_sk76/Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel \
$id  ${id%_*}_L1.2.clean.fq.gz \
2>${id%_*}.bwa.log \
|samtools sort -@ 2 -o ${id%%.*}_bwap.bam
done

-t,number of threads
-o,指定输出sam文件名

比对结果:

#都比对上2或3
samtools fasta -@ 2 -f 3 bwa.sam|wc -l
[M::bam2fq_mainloop] discarded 0 singletons
[M::bam2fq_mainloop] processed 27708394 reads
55416788
#都没比对上12或13
samtools fasta -@ 2 -f 12 bwa.sam|wc -l
[M::bam2fq_mainloop] discarded 0 singletons
[M::bam2fq_mainloop] processed 88864414 reads
177728828
samtools fasta -@ 2 -f 4 bwa.sam|wc -l
[M::bam2fq_mainloop] discarded 0 singletons
[M::bam2fq_mainloop] processed 88938842 reads
177877684
samtools fasta -@ 2 -F 4 bwa.sam|wc -l
[M::bam2fq_mainloop] discarded 0 singletons
[M::bam2fq_mainloop] processed 27802248 reads
55604496

配对reads都比对上序列:27708394条,13854197对,23.7349%;
配对reads都没比对上序列:88864414条,44432207对,76.1209%;
都未比对上序列+单未必对上序列:88938842条,44469421对,76.1846%;
单比对上序列=单未必对上序列:27802248-27708394=93854条,0.080395%。

三、提取未比对上的序列

ls *.bam |while read id
do
samtools fasta -@ 2 -f 4 -N $id -1 ${id%_*}_1.fa -2 ${id%_*}_2.fa -s ${id%_*}_single.fa;
gzip ${id%_*}_1.fa ${id%_*}_2.fa ${id%_*}_single.fa;
done

四、重新比对未比对上序列

4.1 Hisat2

ls *1.fa.gz |while read id
do
hisat2 -t -f -p 2 -X 800 -x /media/luozhixin/0000678400004823/Indexs/Hisat2/H.sapiens/grch38/genome \
-1 $id -2 ${id%_*}_2.fa.gz \
2>${id%_*}.ht2.log\
|samtools sort -@ 2 -o ${id%%.*}_ht2p.bam
done

-t,输出载入index和reads比对所花的时间
-f,输入为fasta文件
-p,指定线程数
-X,指定fragment的最大长度(最小长度用-I指定)
-x,指定索引文件
-1,指定双端测序中第一个文件
-2,指定双端测序中第二个文件
-S,指定输出sam文件的文件名

4.2 bowtie2

ls *1.clean.fq.gz |while read id
do
bowtie2 -t -p 2 -q --fast -X 500 \
-x /media/luozhixin/0000678400004823/Indexs/bowtie2/Mycoplasma_hyorhinis_sk76/Mycoplasma_hyorhinis_sk76.ASM31363v1.dna.toplevel \
-1 $id -2 ${id%_*}_L1.2.clean.fq.gz \
2>${id%_*}.bowtie2.log\
|samtools sort -@ 2 -o ${id%%.*}_bt2p.bam
done

结果

33142842 reads; of these:
  33142842 (100.00%) were unpaired; of these:
    16404150 (49.50%) aligned 0 times
    11456205 (34.57%) aligned exactly 1 time
    5282487 (15.94%) aligned >1 times
50.50% overall alignment rate

你可能感兴趣的:(使用Hisat2, Bowtie, Bowtie2和BWA对PE150进行比对-细菌转录组实战)