美文网首页
一文详解宏基因组组装工具Megahit安装及应用

一文详解宏基因组组装工具Megahit安装及应用

作者: 香菇泡泡青 | 来源:发表于2022-02-21 13:37 被阅读0次

要点

 Megahit简介要点

 Megahit的基本组装原理

 Megahit的安装和使用

                                    Megahit实战

hello,大家好,今天为大家带来关于宏基因组组装工具Megahit的超详细安装及应用教程。

我们将持续为大家带来生物医疗大数据分析一文详解系列文章。

Megahit简介

Megahit是一款超速的宏基因组从头组装工具,由港大—华大基因联合实验室(HKU-BGI)开发,和其他基因组组装软件相比,Megahit在计算时间和内存消耗方面有着巨大优势,适用于土壤等复杂环境样本的组装和大量样本的混合组装[1,2]。

megahit的基本组装原理

Megahit采取的算法是基于kmer迭代的DBG法 (De-Bruijn Graph)。原文链接:https://doi.org/10.1093/bioinformatics/btv033,感兴趣的可以拓展阅读。

如上图所示,Megahit首先将待组装的read分割为更小的k-mer片段,构建简化版的SdBG (succinct de Bruijn graphs ) [3]。

这里有三个动态的变量参数:最小的kmer长度Kmin,最大kmer长度Kmax,以及每次迭代kmer增加的步长Step。

1)Megahit首先使用最小的kmer:Kmin, 构建简化的de brujin图,然后移除de brujin图上的tips,合并bubbles,移除低覆盖度的边(此处和之前提到的SOAPdenovo的处理类似),这样就构建该kmer下的contig: Ck;

2)将当前的kmer增长为kmer+step,然后将该read和之前组装的contig(Ck-step)按现在的kmer大小进行kmer分割,继续之前SdBG构图操作,直到最终kmer大小达到Kmax则终止;

3)最后一次迭代得到的contig:Ck即最终组装结果。

megahit的安装和使用

3.1 安装

megahit的github链接为: https://github.com/voutcn/megahit。megahit的安装相对比较简单,可以通过以下三种方式,用户可以根据自己的实际情况选择。

1、Conda安装:

conda install -c bioconda megahit

2、直接下载二进制文件:

wget https://github.com/voutcn/megahit/releases/download/v1.2.9/MEGAHIT-1.2.9-Linux-x86_64-static.tar.gztar zvxf MEGAHIT-1.2.9-Linux-x86_64-static.tar.gzcd MEGAHIT-1.2.9-Linux-x86_64-static/bin/ #可以看到目录下的可执行文件megahit

3、源码编译安装:

git clone https://github.com/voutcn/megahit.gitcd megahitgit submodule update --initmkdir build && cd buildcmake .. -DCMAKE_BUILD_TYPE=Release  # add -DCMAKE_INSTALL_PREFIX=MY_PREFIX if neededmake -j4make simple_test  # will test MEGAHIT with a toy dataset# make install if needed

编译的时候需要保证安装了以下软件:zlib, cmake >= 2.8, g++ >= 4.8.4, 运行的时候需要使用gzip和bzip2两个软件,用于压缩和解压。

3.2 使用说明

基本使用:

megahit [options] {-1 <pe1> -2 <pe2> | --12 <pe12> | -r <se>} [-o <out_dir>]

参数详解:

#必须输入参数-1 <pe1> comma-separated list of fasta/q paired-end #read1的序列文件-2 <pe2> comma-separated list of fasta/q paired-end #read2的序列文件--12 <pe12> comma-separated list of interleaved fasta/q paired-end files # 交错的双端PE序列-r/--read <se> comma-separated list of fasta/q single-end files# 单端SE的序列文件#基本参数:--min-count <int> minimum multiplicity for filtering (k_min+1)-mers [2] #过滤的最小重合bp数--k-list <int,int,..> comma-separated list of kmer size #设定固定的kmer迭代列表。逗号分隔,必须为奇数#另一种kmer迭代列表设置方式--k-min <int> minimum kmer size (<= 255), must be odd number [21] #设置最小的kmer size,应小于255,必须为奇数--k-max <int> maximum kmer size (<= 255), must be odd number [141] #设置最大的kmer size,应小于255,必须为奇数--k-step <int> increment of kmer size of each iteration (<= 28), must be even number [12] #间隔大小,应小于等于28,必须为偶数#高级参数--no-mercy do not add mercy kmers--bubble-level <int> intensity of bubble merging (0-2), 0 to disable [2] #bubble融合强度--merge-level <l,s> merge complex bubbles of length <= l*kmer_size and similarity >= s [20,0.95] # 合并长度<= l*kmer_size和相似度>= s的复杂bubble--prune-level <int> strength of low depth pruning (0-3) [2] # 低深度区域的修剪强度--prune-depth <int> remove unitigs with avg kmer depth less than this value [2]# 如果kmer平均深度低于该值则移除该unitigs--disconnect-ratio <float> disconnect unitigs if its depth is less than this ratio times #如果深度小于这个比率乘以其深度则断开unitigs--low-local-ratio <float> remove unitigs if its depth is less than this ratio times # 如果深度小于这个比率乘以相邻unitigs的平均深度则移除unitigs--max-tip-len <int> remove tips less than this value [2*k] #移除小于该值的tips --cleaning-rounds <int> number of rounds for graph cleanning [5] # --no-local disable local assembly #禁止局部组装#硬件参数-m/--memory <float> max memory in byte to be used in SdBG construction # 设定内存大小,单位为byte,如果小于1则为机器最大内存的比例-t/--num-cpu-threads <int> number of CPU threads #线程数#输出参数-o/--out-dir <string> output directory [./megahit_out] #输出目录--out-prefix <string> output prefix (the contig file will be OUT_DIR/OUT_PREFIX.contigs.fa) #输出结果文件的前缀--min-contig-len <int> minimum length of contigs to output [200] #设定输出contig最小值--keep-tmp-files keep all temporary files #保留所有中间文件--tmp-dir <string> set temp directory # 设定临时目录

3.3 软件运行

#双端megahit -1 pe_1.fq -2 pe_2.fq -o out  # 1 paired-end library#交叉双端megahit --12 interleaved.fq -o out # one paired & interleaved paired-end library# 单端双端混合megahit -1 a1.fq,b1.fq,c1.fq -2 a2.fq,b2.fq,c2.fq -r se1.fq,se2.fq -o out # 3 paired-end libraries + 2 SE libraries# 使用megahit_core获取中间某个kmer的fasta文件megahit_core contig2fastg 119 out/intermediate_contigs/k119.contig.fa > k119.fastg # get FASTG from the intermediate contigs of k=119

megahit实战

下面我们找个武汉新冠的测序数据,具体来实践一下吧。

4.1 数据下载

下载测序数据:

wget http://www.sixoclock.net/resources/data/NGS/SARS-COV-2/RNA_Seq/nCoVR.WH-100K_1.fastq.gzwget http://www.sixoclock.net/resources/data/NGS/SARS-COV-2/RNA_Seq/nCoVR.WH-100K_2.fastq.gz

4.2 运行命令

此处我们将程序运行的标准输出和标准错误都分别重定向到对应的log和err文件中了。

./megahit -1 nCoVR.WH-100K_1.fastq.gz -2 nCoVR.WH-100K_2.fastq.gz -o out/ 1> log 2>err

4.3 输出结果

此处我们的测试数据比较小,因此可以非常快速的跑完,具体的结果如下图所示,可以看到生成了不少的中间结果文件,其中final.contigs.fa即组装结果。

此外,我们的sixoclock基于CWL (common workflow language) 对megahit软件进行了封装,通过我们开发的sixbox软件可以快速进行软件的运行。

具体的运行步骤如下:

1)下载cwl 源码sixbox pull 321daf5b-e0cf-4d3e-96e1-8773a0a71db0或 在六点了上下载megahit.cwl[1]。

2)下载数据

wget http://www.sixoclock.net/resources/data/NGS/SARS-COV-2/RNA_Seq/nCoVR.WH-100K_1.fastq.gzwget http://www.sixoclock.net/resources/data/NGS/SARS-COV-2/RNA_Seq/nCoVR.WH-100K_2.fastq.gz

3) 使用sixbox生成参数模板文件(YAML) , 并配置yaml文件

sixbox run --make-template ./megahit.cwl > megahit.job.yamlvim megahit.job.yaml # 编辑参数配置文件,替换或设置参数以实现个性化分析

可以直接粘贴下方示例内容到megahit.job.yaml

threads: 2  # default value of type "int".pe2:  # type "File" (optional)    class: File    path: http://www.sixoclock.net/resources/data/NGS/SARS-COV-2/RNA_Seq/nCoVR.WH-100K_2.fastq.gzpe1:  # type "File" (optional)    class: File    path: http://www.sixoclock.net/resources/data/NGS/SARS-COV-2/RNA_Seq/nCoVR.WH-100K_1.fastq.gzoutpre: "final"  # default value of type "string".outdir: "./megahit_out"  # default value of type "string".min_count: 2  # default value of type "int".k_list: "21,29,39,59,79,99,119,141"  # default value of type "string".

4) 使用sixbox运行

sixbox run ./megahit.cwl ./megahit.job.yaml#或者指定输出目录sixbox run --outdir /home/path ./megahit.cwl ./megahit.job.yaml

运行结果即可看到当前目录或者指定的输出目录输出组装结果。

至此,megahit的实战体验基本就结束了。

以上为我们给大家带来的宏基因组组装工具Megahit基本原理知识,以及运行详细操作过程。

References

[1]megahit.cwl:https://www.sixoclock.net/application/pipe/321daf5b-e0cf-4d3e-96e1-8773a0a71db0

[2] Li, D., Luo, R., Liu, C.M., Leung, C.M., Ting, H.F., Sadakane, K., Yamashita, H. and Lam, T.W., 2016. MEGAHIT v1.0: A Fast and Scalable Metagenome Assembler driven by Advanced Methodologies and Community Practices. Methods.

[3] Bowe,A. et al. (2012) Succinct de Bruijn Graphs. In: B., Raphael and J., Tang

(eds.) Algorithms in Bioinformatics. Springer, Berlin, pp. 225–235

[4]  六点了官网: http://www.sixoclock.net

推荐阅读

一文详解基因组denovo组装原理和实战

首发!生信分析--入门实践一条龙的CWL中文教程来了

第三期 Gatk snp calling流程的配置及使用

第四期 GATK最佳实践之流程运行

相关文章

  • 宏基因组分箱(二)Metabat2分箱实战

    导读 上一篇:宏基因组分箱(一)Megahit组装和QUAST质量评价。分箱工具有很多,我为什么选择Metabat...

  • 宏基因组:基因组组装之MEGAHIT

    megahit软件安装 megahit使用帮助 megahit使用 查看拼接结果

  • 宏基因组组装工具如何选择?MetaSPAdes还是Megahit

    导读 宏基因组组装工具非常多。如何从众多组装工具中选择适合组装自己的宏基因组测序数据的工具呢?为了解决这个问题,我...

  • Bacteria genome denovo assembly

    细菌基因组组装金标准:GAGE-B 组装软件的选择 细菌基因组组装的目标不同于大型生物基因组的组装,大型基因组组装...

  • 双端组装时reads1 file与reads2 file不完全m

    在用metaspade组装双端fastq,或用megahit组装双端fasta时,因双端不齐会报告相应的error...

  • 常用转录组组装软件集合

    转录组组装软件 基因组组装 基因组组装(Genome assembly)是指使用测序方法将待测物种的基因组生成序列...

  • 安装leanengine

    安装leanengine LeanCloud文档云引擎命令行工具使用详解 关联应用avoscloud add

  • 基因组结构注释

    1. 组装基因组质控 得到组装好的基因组序列之后,首先要使用多种方法评估组装质量。这里用到2款可用于基因组组装质量...

  • 基因组 组装教程 (T2T)

    导读 本文将介绍T2T基因组,并提供一份基因组组装的资料,其中包含:基因组组装数据和组装策略介绍;染色体水平基因组...

  • 组装简介

    基因组 应该是 生信分析的基因组。一个好的基因组会让生信分析事半功倍。基因组组装简单的理解:借助工具进行 read...

网友评论

      本文标题:一文详解宏基因组组装工具Megahit安装及应用

      本文链接:https://www.haomeiwen.com/subject/fofwlrtx.html