生信 | 基因组组装实战(四):组装软件mecat2、flye、wtdbg2、Canu、Falcon

写在前面

  • 以下内容均来自我在菲沙基因(Frasergen)暑期生信培训班上记录的课堂笔记

1.基因组概念

  • 基因组应该指单倍体细胞中包括编码序列和非编码序列在内的全部DNA分子。即核基因组是单倍体细胞核内的全部DNA分子;线粒体基因组则是一个线粒体所包含的全部DNA分子 ;叶绿体基因组则是一个叶绿体所包含的全部DNA分子。

2.三代PacBio数据准备

2.1 数据格式
  • Pacbio平台测序出来的reads,由接头序列, 条码序列, 插入序列间隔线性分布,即ABIB-ABIB—ABIB-ABIB—(A: adapter, B: barcode, I: insert)
├── Sample
│ └── Library(不分文库时文库名为 all)
│ └── Cell
│ ├── *.subreads.bam 用于下游分析的有效数据(相当于clean data)
│ ├── *.subreads.bam.pbi subreads.bam文件的索引文件
│ └── *.xml 测序信息记录文件
2.2 数据格式转换(bam转fq/fa)
  • 软件:bam2fastq
  • 使用conda安装
conda install -c yuxiang bam2fastq -y
  • bam 转 fastq/ fasta(后缀自动补充为.fastq/ fasta)
bam2fastq *subreads.bam –o *subreads.bam -u
bam2fasta *subreads.bam –o *subreads.bam -u

-u:输出文件不压缩。去掉则输出压缩文件,由于后续需要用到非压缩文件,所以这里加上-u参数,且节省时间

  • 数据量统计(小工具:GNX)
#安装与编译
git clone https://github.com/mh11/gnx-tools.git
mkdir bin
javac -d bin/ src/uk/ac/ebi/gnx/*
ant -f package.xml
java -jar gnx.jar
#使用
java -jar gnx.jar all_subreads.bam.fasta > N50
cat N50

3.基因组组装

  • 共款软件:Mecat2、Flye、wtdbg2、Canu、Falcon,以下分别进行介绍
3.1 使用Mecat2进行基因组组装
  • 软件介绍
Mecat2软件介绍
  • 使用git安装并编译
git clone https://github.com/xiaochuanle/MECAT2.git 
cd MECAT2 
make 
  • 新建配置文件config_file.txt
vi config_file.txt
  • 填写内容如下:
PROJECT=test
RAWREADS= /local_data1/all_subreads.bam.fasta #从bam转过来的fasta文件
GENOME_SIZE= 12251230  #根据《生信 | 基因组组装实战(三):Kmer评估基因组》来确定
THREADS=15   #线程数
MIN_READ_LENGTH=2000 
CNS_OVLP_OPTIONS="-kmer_size 13" 
CNS_PCAN_OPTIONS="-p 100000 -k 100" CNS_OPTIONS="" 
CNS_OUTPUT_COVERAGE=30  #根据菲沙基因老师的经验,30-45范围较好,可以多次调整
TRIM_OVLP_OPTIONS="-skip_overhang" 
TRIM_PM4_OPTIONS="-p 100000 -k 100" 
TRIM_LCR_OPTIONS="" 
TRIM_SR_OPTIONS="" 
ASM_OVLP_OPTIONS="" 
FSA_OL_FILTER_OPTIONS="--max_overhang=-1 --min_identity=-1" 
FSA_ASSEMBLE_OPTIONS="" 
CLEANUP=0

:以上前面的内容根据自己的需求修改,其他默认即可

  • 保存配置后,运行程序
MECAT2/Linux-amd64/bin/mecat.pl correct config_file.txt
MECAT2/Linux-amd64/bin/mecat.pl assemble config_file.txt
  • MECAT2运行结果
    【4-fsa】目录下的【contigs.fasta】为结果文件


    MECAT2运行结果
3.2 使用Flye进行基因组组装
  • 软件简介
Flye软件简介
  • 使用git安装并编译
git clone https://github.com/fenderglass/Flye
cd Flye
make
  • 使用方法
Flye/bin/flye \
--pacbio-raw 
/local_data1/all_subreads.bam.fasta \
--out-dir test \
--genome-size 12251230 \  #根据需要请修改
--threads 10
  • 结果文件
Flye结果文件
3.3 使用wtdbg2进行基因组组装
  • 软件简介
wtdbg2软件简介
  • 使用git安装并编译
git clone https://github.com/ruanjue/wtdbg2 
cd wtdbg2
make
  • 软件使用
#quick start with wtdbg2.pl 
./wtdbg2.pl -t 16 -x rs -g 12m -o dbg reads.fa 
# Step by step commandlines # assemble long reads 
./wtdbg2 -x rs -g 4.6m -i reads.fa.gz -t 16 -fo dbg 
# derive consensus 
./wtpoa-cns -t 16 -i dbg.ctg.lay.gz -fo dbg.raw.fa 
# polish consensus, not necessary if you want to polish the assemblies using other tools 
minimap2 -t16 -ax map-pb -r2k dbg.raw.fa reads.fa.gz | samtools sort -@4 >dbg.bam 
samtools view -F0x900 dbg.bam | ./wtpoa-cns -t 16 -d dbg.raw.fa -i - -fodbg.cns.fa 
# Addtional polishment using short reads 
bwa index dbg.cns.fa 
bwa mem -t 16 dbg.cns.fa sr.1.fa sr.2.fa | samtools sort -O SAM | ./wtpoa-cns -t 16 -x 
sam-sr -d dbg.cns.fa -i - -fo dbg.srp.fa
  • 结果文件
wtdbg2结果文件
3.4 使用Canu进行基因组组装
  • 软件简介与原理
Canu运行流程
  • 使用conda安装
conda install -c bioconda canu -y
  • 软件使用,来源不同的数据使用不同代码
#For PacBio:
canu -p ecoli -d ecoli-pacbio genomeSize=4.8m -pacbio-raw pacbio.fastq
#For Nanopore:
canu -p ecoli -d ecoli-oxford genomeSize=4.8m -nanopore-raw oxford.fasta
#Assembling PacBio HiFi with HiCanu:
canu -p asm -d ecoli_hifi genomeSize=4.8m -pacbio-hifi ecoli.fastq
#Trio Binning Assembly:
canu -p asm -d ecoliTrio genomeSize=5m \
 -haplotype K12 K12.parental.fasta \
 -haplotype O157 O157.parental.fasta \
 -pacbio-raw F1.fasta

-p 指定输出前缀
-d 指定输出结果目录
genomeSize 设置一个预估的基因组大小,便于让Canu估计测序深度,单位是K,M,G
maxThreads 设置最大线程数
-pacbio-raw 直接测序得到的原始pacbio数据
-pacbio-corrected 经过纠正的pacbio数据
-nanopore-raw 原始的nanopore数据
-nanopore-corrected 结果纠正的nanopore数据
rawErrorRate 设置两个未纠错read之间最大期望差异碱基数
correctedErrorRate 设置纠错后read之间最大期望差异碱基数
minReadLength 设置最小使用的reads长度
minOverlapLength 设置Overlap的最小长度

3.5 使用Falcon进行基因组组装
  • 软件组装原理
falcon软件组装原理
  • 使用conda安装软件
conda install -c conda-forge falcon -y
  • 软件使用,和mecat2一样,关键就是弄好配置文件。比较好的做法是去官网下载合适的配置文件,然后将其中的某些参数稍加修改即可。如我下载植物的fc_run_plant.cfg
wget https://pb-falcon.readthedocs.io/en/latest/_downloads/fc_run_plant.cfg
cat fc_run_plant.cfg
[General]
input_fofn = input.fofn
input_type = raw
stop_all_jobs_on_failure = False
length_cutoff = 5000
genome_size = 1400000000
seed_coverage = 30
length_cutoff_pr = 4000
sge_option_da = -pe smp 5 -q bigmem
sge_option_la = -pe smp 20 -q bigmem
sge_option_pda = -pe smp 6 -q bigmem 
sge_option_pla = -pe smp 16 -q bigmem
sge_option_fc = -pe smp 24 -q bigmem
sge_option_cns = -pe smp 12 -q bigmem
pa_concurrent_jobs = 96
cns_concurrent_jobs = 96
ovlp_concurrent_jobs = 96
pa_HPCdaligner_option =  -v -B128 -M32 -e.70 -l4800 -s100 -k18 -h480 -w8 
ovlp_HPCdaligner_option = -v -B128 -M32 -h1024 -e.96 -l2400 -s100 -k18
#下面两行其中的参数在下面介绍
pa_DBsplit_option = -a -x500 -s400
ovlp_DBsplit_option = -s400
falcon_sense_option = --output_multi --min_idt 0.70 --min_cov 2 --max_n_read 200 --n_core 8 
falcon_sense_skip_contained = True
overlap_filtering_setting = --max_diff 100 --max_cov 100 --min_cov 2 --n_core 12

常规参数:
input_fofn = input.fofn 指出所有输入数据,路径+文件名
input_type = raw ( 或preads ) 标明序列类型,即是否已经完成了错误修正
length_cutoff = 10000 用于错误修正的种子序列的最低长度
length_cutoff_pr = 10000 用于构建重叠的预组装种子序列的最低长度
b 如果基因组组分有偏好性(例如65% AT rich)应该设置b参数。
M 参数控制内存, l默认是1000,低于这个长度的序列丌用比对
S 默认是100,输出点也可以设置成500提高速度,也有1000
E 准确性默认是0.7一般的设置成0.75
B 参数决定一个job中包含的block之间比对的数目
T 参数是控制在一个block里一个kmer出现的最多次数,这个参数有的设置8,12,16.这个值
越小速度越快。
k(kmer) 要小于32,线程数目T默认是4.

  • 保存配置文件后,直接执行fc_run.py脚本即可
fc_run.py fc_run.cfg
  • 结果文件较多,具体在官网查看,组装的结果文件在下面
falcon_job/
    ├── 0-rawreads/     # Raw read error correction directory
组装报告   └── report/   # pre-assembly stats
    ├── 1-preads_ovl/   # Corrected read overlap detection
    ├── 2-asm-falcon/   # String Graph Assembly
结果文件   └── a_ctg_all.fa   # all associated contigs, including duplicates
结果文件   └── a_ctg.fa    # De-duplicated associated fasta file
    ├── mypwatcher/     # Job scheduler logs
    ├── scripts/
    └── sge_log/        # deprecated

写在最后

  • 本文一共介绍了5款软件,但以后肯定还会有更多更优秀的软件,但原理和用法都相差不大,我们总归是要选择一个作为我们后续的分析,如何选?


  • 组装完成后,就要对组装结果进行矫正,下一节介绍。

你可能感兴趣的:(生信 | 基因组组装实战(四):组装软件mecat2、flye、wtdbg2、Canu、Falcon)