Unicycler github
简介
Unicycler是组装细菌基因组的软件套装。它既可以使用SPAdes组装纯Illumina短读长的二代数据,也可以使用miniasm+Racon管道组装三代长读长数据(PacBio或Nanopore)。进一步,可以同时给它二代和三代数据,它将进行短读长优先的混合组装,以获得最好的组装结果。
软件原理:
Wick RR, Judd LM, Gorrie CL, Holt KE. Unicycler: resolving bacterial genome assemblies from short and long sequencing reads. PLoS Comput Biol 2017.
2022 更新版本特点
Unicycler最初是在2016年诞生的,当时长读段是稀疏的,而且非常错误率较高。例如,早期的牛津纳米孔测序可能对一个细菌只产生15倍的测序深度,而且大部分的读段有很多错误。因此,Unicycler被设计为优先使用短读段组装出主体,再使用低深度和低精度的长读段来构建短读段组装图,以完成组装,这种方法我称之为短读段优先的混合组装。假设短读组装图处于良好的状态,Unicycler就能很好地做到这一点。
然而,在过去的六年里,情况发生了变化。纳米孔测序的产量现在要高得多,使得>100倍的深度很容易获得,即使是在多个run的项目。读段精度也得到了改善,并且每年都在不断提高。高深度和高精度的长读使得长读段优先混合组装(长读段组装后再进行短读段抛光)成为一种可行的方法,通常比Unicycler更可取。我已经开发了Trycycler和Polypolish,以追求理想的长读段优先组装。
Unicycler并没有完全过时,因为它仍然是细菌基因组短读段优先混合组装的最佳工具。但是我认为它只应该在长读段优先不可行的情况下–即长读深度较低的情况下用于混合组装。我还认为Unicycler适合于短读的细菌基因组,因为它比SPAdes单独产生更干净的组装图。因此,虽然Unicycler最近没有得到我大量的时间和关注,但我还不认为它是废弃软件。
关于一些最新的细菌基因组组装技巧,请查看Trycycler的维基中的这些部分。
我应该用Unicycler还是Trycycler来组装我的细菌基因组?
细菌基因组组装指南
使用简介
作为输入,Unicycler需要以下文件之一:
- 来自分离细菌的Illumina读段(最好是成对的,但不成对的也可以)。
- 一组来自细菌的长读段(PacBio或Nanopore)。
- 来自同一细菌的Illumina读段和长读段(最佳情况)。
使用Unicycler的原因:
- 它能使复制子(replicons )成环,而不需要像Circlator那样的单独工具。
- 它能处理富含质粒的基因组。
- 它可以在杂交组装中使用任何深度和质量的长读段。完成一个基因组可能需要20倍或更多,但Unicycler可以用少得多的长读段做出几乎完整的基因组。
- 除了生成可在Bandage中查看的contigs FASTA文件外,它还产生一个组装图。
- 它能过滤掉低深度的contigs,即使读段集有低水平的污染,也能得到干净的组装。
- 它的错误组装率很低。
- 它可以处理高度重复的基因组,如志贺氏菌(Shigella)。
- 它很容易使用:只需一个命令就可以运行,通常不需要修改参数。
不使用Unicycler的原因:
- 你正在组装真核生物基因组或元基因组(Unicycler是专门为分离培养的细菌设计的)。
- 你的Illumina读段和长读段来自不同的菌株(Unicycler在处理样品的异质性时很困难)。
- 你没有耐心(Unicycler组装结果好,但不是特别快)。
安装
$ mamba create -n unicycler -c bioconda unicycler
快速使用
- Illumina-only assembly:
unicycler -1 short_reads_1.fastq.gz -2 short_reads_2.fastq.gz -o output_dir
- Long-read-only assembly:
unicycler -l long_reads.fastq.gz -o output_dir
- Hybrid assembly:
unicycler -1 short_reads_1.fastq.gz -2 short_reads_2.fastq.gz -l long_reads.fastq.gz -o output_dir
sample_data 目录有示例文件可以用于测试
测试数据集
宋氏志贺菌(Shigella sonnei)plasmids (synthetic reads)
这些是来自宋氏志贺菌53G基因组组装的质粒A、B和E的合成读段。
figshare页面下载reads
志贺菌53G基因组5.22M,GC50.73%,有A、B、C、E共4个质粒
与细菌基因组相比,这些质粒很小,但插入序列会产生许多重复。
- 最小的质粒可以单独用短读段组装出来
- 低深度长读段的混合组装能够完成中等大小的质粒组装
- 而高深度长读段混合组装才能完成所有三个质粒的组装。
# 日志默认标准输出,同时也会在输出结果中产生一个日志
(unicycler)$ time unicycler -t 50 -1 short_reads_1.fastq.gz -2 short_reads_2.fastq.gz -o only_short_asm &
# real 3m30.019s
(unicycler)$ time unicycler -t 50 -1 short_reads_1.fastq.gz -2 short_reads_2.fastq.gz -l long_reads_low_depth.fastq.gz -o short_long_low_asm &
# real 6m42.131s
(unicycler)$ time unicycler -t 50 -1 short_reads_1.fastq.gz -2 short_reads_2.fastq.gz -l long_reads_high_depth.fastq.gz -o short_long_high_asm
# real 8m5.647s
幽门螺旋杆菌(Helicobacter pylori)
这些是来自幽门螺杆菌样FDAARGOS_300的Illumina和PacBio真实读段。
幽门螺旋杆菌的基因组小而简单。它只有两个RNA操作子的拷贝,没有其他大的重复序列,因此与大多数细菌基因组相比,它非常容易组装。
- 用高深度的长读段进行杂交组装应该能产生一个完整的染色体
- 用低深度长读段进行的杂交组装非常接近于完成,只剩下几个稍微模糊的点
$ time unicycler -t 100 -l long_reads_high_depth.fastq.gz -o long_asm
# real 1m53.626s
化脓性链球菌(Streptococcus pyogenes)
这些是来自化脓性链球菌样品FDAARGOS_190的真实Illumina和PacBio读段。
化脓性链球菌的基因组特别小而且简单,用Illumina读段组装起来相对容易。然而,它有一些重复的元件,包括5个RNA操作子拷贝和六个IS1548的拷贝。
- 用高深度的长读段进行杂交组装应能产生一个完整的染色体。
- 使用低深度长读段的混合组装将不太完整,在一些RNA操作子周围留下了一些模糊不清的地方
淋病奈瑟菌(Neisseria gonorrhoeae)
这些是真实的Illumina和PacBio读段,来自淋病奈瑟菌样品FDAARGOS_204。
虽然淋病奈瑟菌的基因组很小,但它是一个很难组装的基因组,有许多IS1016、ISNgo2和其他重复的拷贝。
- 用高深度的长读段进行杂交组装应该能产生一个完整的染色体
- 用低深度长读段进行的混合组装,虽然仍比只用Illumina组装有很大的改进,但在一些区域却无法解决
- 这表明,更复杂的基因组需要更高的长读段深度来实现完整的组装
Unicycler不同组装模式
bold模式有最长的contigs,因此错误比对率也最高,最后得到大于500bp以上的数量最少,conservative模式有最低的错误组装率,因此得到的contig长度最小,数量最多; normal模式在contig长度和组装错误率上有比较好的平衡。
# normal model: moderate contig size and misassembly rate
(unicycler) [yutao@myosin Bacillus_anthracis]$ nohup time unicycler -1 R9-5_1.unpaired.fq.gz -2 R9-5_2.unpaired.fq.gz -t 50 --min_fasta_length 500 -o R9-5_unicycler_assembly &>R9-5_unicycler_assembly.log&
# bold model:longest contig, more misassambly
(unicycler) [yutao@myosin Bacillus_anthracis]$ nohup time unicycler -1 R9-5_1.unpaired.fq.gz -2 R9-5_2.unpaired.fq.gz --mode bold -t 50 --min_fasta_length 500 -o R9-5_unicycler_bold_model_assembly &>R9-5_unicycler_bold_model_assembly.log&
# conservative:smaller contigs, lowest misassembly rate
(unicycler) [yutao@myosin Bacillus_anthracis]$ nohup time unicycler -1 R9-5_1.unpaired.fq.gz -2 R9-5_2.unpaired.fq.gz --mode conservative -t 50 --min_fasta_length 500 -o R9-5_unicycler_conservative_model_assembly &>R9-5_unicycler_conservative_model_assembly.log&
# --min_fasta_length MIN_FASTA_LENGTH
Exclude contigs from the FASTA file which are shorter than this
length (default: 100)
# --mode {conservative,normal,bold}
Bridging mode (default: normal)
conservative = smaller contigs, lowest misassembly rate
normal = moderate contig size and misassembly rate
bold = longest contigs, higher misassembly rate
# 耗时:30min
- N50结果
normal和bold模式N50均为189,782比conservative模式169,074大20kb,normal大于500bp的contig数量居中74(基因组居中),bold 68个(基因组最大),conservative80个(基因组最小);三者最大contig都为570,896
(unicycler) [yutao@myosin Bacillus_anthracis]$ seqkit stats -a R9-5_unicycler_bold_model_assembly/assembly.fasta
file format type num_seqs sum_len min_len avg_len max_len Q1 Q2 Q3 sum_gap N50 Q20(%) Q30(%)
R9-5_unicycler_bold_model_assembly/assembly.fasta FASTA DNA 68 5,253,677 518 77,260 570,896 4,839 35,918.5 101,072.5 0 189,782 0 0
R9-5_unicycler_normal_model_assembly/assembly.fasta FASTA DNA 74 5,248,872 518 70,930.7 570,896 4,232 32,799 87,644 0 189,782 0 0
R9-5_unicycler_conservative_model_assembly/assembly.fasta FASTA DNA 80 5,244,945 518 65,561.8 570,896 5,632 32,614 79,913 0 169,074 0 0
- 比对率
基因组最大的bold比对率最高,其次是normal,conservative最低,但是三者相差并不大
# index
for i in normal conservative bold ;do bowtie2-build --threads 30 R9-5_unicycler_${i}_model_assembly.fasta R9-5_unicycler_${i}_model_bt2_index & done
# mapping
(metawrap) for i in normal bold conservative;do bowtie2 -x R9-5_unicycler_${i}_model_bt2_index -1 ../R9-5_1.unpaired.fq.gz -2 ../R9-5_2.unpaired.fq.gz -p 30 >/dev/null 2>R9-5_unicycler_${i}_model_mapping_rate.txt & done
(metawrap) [yutao@myosin R9-5_unicycler_assembly]$ grep -i Overall *rate.txt
R9-5_unicycler_bold_model_mapping_rate.txt:98.99% overall alignment rate
R9-5_unicycler_conservative_model_mapping_rate.txt:98.82% overall alignment rate
R9-5_unicycler_normal_model_mapping_rate.txt:98.95% overall alignment rate
Ragtag基于参考基因组校正
- 对于组装后并不成环的contig,需要使用ragtag依据参考基因组将contig排序
# 1.基于参考基因组correct,校正是使用参考基因组来鉴定和校正contigs中的组装错误,该步骤不会将序列减少或增加,仅仅是将序列在错误组装的位置进行打断。
(ragtag) [yutao@myosin R9-5_unicycler_assembly]$ time ragtag.py correct B.anthracis_Ames_Ancestor.fna R9-5_unicycler_bold_model_assembly.fasta -t 30 -o Ragtag_correct/R9-5_unicycler_bold_model_correct
# 2.基于上一步校正结果用N连接成scaffold,该步骤是将相邻的contigs序列用100个N连起来,序列的位置和方向需要根据与参考基因组的比对结果确定。
(ragtag) [yutao@myosin R9-5_unicycler_assembly]$ time ragtag.py scaffold -t 30 -C B.anthracis_Ames_Ancestor.fna Ragtag_correct/R9-5_unicycler_bold_model_correct/ragtag.correct.fasta -o Ragtag_correct/R9-5_unicycler_bold_model_scaffold
- 1.结果
# unicycler原始组装结果
(prokka) [yutao@myosin R9-5_unicycler_assembly]$ grep ">" R9-5_unicycler_bold_model_assembly.fasta
>1 length=570896 depth=1.25x
>2 length=362942 depth=0.61x
>3 length=318902 depth=1.00x
>4 length=274270 depth=2.03x
>5 length=272416 depth=2.08x
>6 length=234342 depth=0.71x
>7 length=231813 depth=0.97x
>8 length=209289 depth=0.68x
>9 length=189782 depth=1.64x
>10 length=180292 depth=0.87x
>11 length=169074 depth=1.22x
>12 length=145445 depth=1.50x
>13 length=144041 depth=1.33x
>14 length=143824 depth=0.77x
>15 length=137391 depth=1.77x
>16 length=126712 depth=1.62x
>17 length=105557 depth=2.22x
>18 length=96588 depth=2.15x
>19 length=95132 depth=1.87x
>20 length=91118 depth=0.88x
>21 length=87644 depth=2.27x
>22 length=84120 depth=1.14x
>23 length=73811 depth=0.79x
>24 length=63846 depth=1.75x
>25 length=58175 depth=2.40x
>26 length=57284 depth=1.70x
>27 length=55138 depth=2.97x circular=true
>28 length=53352 depth=1.75x
>29 length=52500 depth=1.50x
>30 length=48204 depth=2.34x
>31 length=45531 depth=2.23x
>32 length=44059 depth=1.48x
>33 length=40830 depth=1.41x
>34 length=37461 depth=1.56x
>35 length=34376 depth=1.40x
>36 length=31222 depth=2.11x
>37 length=29029 depth=0.75x
>38 length=28569 depth=0.87x
>39 length=26552 depth=0.75x
>40 length=23077 depth=0.81x
>41 length=22886 depth=2.23x
>42 length=20525 depth=0.80x
>43 length=18425 depth=1.73x
>44 length=15973 depth=2.21x
>45 length=15625 depth=0.64x
>46 length=15487 depth=2.20x
>47 length=14650 depth=2.25x
>48 length=8224 depth=1.56x
>49 length=7266 depth=1.64x
>50 length=6555 depth=3.79x circular=true
>51 length=5047 depth=2.18x
>52 length=4631 depth=13.67x circular=true
>53 length=2893 depth=1.97x
>54 length=2449 depth=2.08x
>55 length=2443 depth=2.16x
>56 length=1933 depth=0.61x
>57 length=1566 depth=33.30x
>58 length=1498 depth=32.38x
>59 length=1457 depth=2.14x
>60 length=1417 depth=2.11x
>61 length=1371 depth=34.42x
>62 length=1269 depth=5.93x
>63 length=1203 depth=2.06x
>64 length=1039 depth=2.09x
>65 length=1035 depth=2.47x
>66 length=879 depth=8.11x
>67 length=807 depth=14.11x
>68 length=518 depth=18.86x
# ragtag correct结果
(prokka) [yutao@myosin R9-5_unicycler_assembly]$ grep ">" Ragtag_correct/R9-5_unicycler_bold_model_correct/ragtag.correct.fasta
>1
>10
>11
>12
>13
>14
>15
>16
>17
>18
>19
>2_1_353677_+
>2_353678_362942_+
>20
>21_1_9219_+
>21_9220_87644_+
>22
>23_1_40012_+
>23_40013_73811_+
>24
>25
>26
>27_1_34569_+
>27_34570_55138_+
>28
>29
>3
>30
>31
>32
>33
>34
>35
>36
>37
>38
>39
>4
>40
>41
>42
>43
>44
>45
>46
>47
>48
>49
>5
>50
>51
>52
>53
>54
>55
>56
>57
>58
>59
>6
>60
>61
>62
>63
>64
>65
>66
>67
>68
>7
>8
>9
- scaffold使用N碱基连接contig
# unicycler原始组装大小
(prokka) [yutao@myosin R9-5_unicycler_assembly]$ bioawk -c fastx '{s+=length($seq)}END{print s}' R9-5_unicycler_bold_model_assembly.fasta
5253677
# ragtag correcr基因组大小:与原始基因组大小一致
(prokka) [yutao@myosin R9-5_unicycler_assembly]$ bioawk -c fastx '{s+=length($seq)}END{print s}' Ragtag_correct/R9-5_unicycler_bold_model_correct/ragtag.correct.fasta
5253677
# ragtag scaffold基因组大小
(prokka) [yutao@myosin R9-5_unicycler_assembly]$ bioawk -c fastx '{s+=length($seq)}END{print s}' Ragtag_correct/R9-5_unicycler_bold_model_scaffold/ragtag.scaffold.fasta
5260577
# scaffold包含的N碱基数量
(prokka) [yutao@myosin R9-5_unicycler_assembly]$ grep -o "N" Ragtag_correct/R9-5_unicycler_bold_model_scaffold/ragtag.scaffold.fasta|wc -l
6900
(prokka) [yutao@myosin R9-5_unicycler_assembly]$ echo |awk '{print 5260577-5253677}'
6900
-
校正之后基因组已经按照参考基因组序列重排
在https://proksee.ca/右侧Tools的fastANI中可视化,但是只支持2个基因组
-
2.圈图结果
在https://proksee.ca/可视化细菌基因组圈图
下图为未成环的基因组,最大特点是基因组GC Skew交错并不连续,而经过ragtag校正并且连接成scaffold的有明显的GC skew正负分界。
-
2.基因组共线分析(collinear)
在pyGenomeViz(https://pygenomeviz.streamlit.app/)上传多个基因组的gbk文件进行共线分析(注意是按照上传顺序展示的,上传后不可调整),左侧Plot link method使用MUMmer (nucleotide)。 -
prokka生成gbk文件
(prokka) [yutao@myosin R9-5_unicycler_assembly]$ prokka --cpus 50 --prefix R9-5_unicycler_bold_model_ragtag_correct_prokka Ragtag_correct/R9-5_unicycler_bold_model_correct/ragtag.correct.fasta
常见问题
RecursionError: maximum recursion depth exceeded
- 可能原因:原始数据存在多个物种污染
Read depth filter: removed 5215 contigs totalling 2053037 bp
Deleting /datanode02/yut/04_MicroFungi/Unicycler_assembly/MD-228/spades_assembly/
ESC[93mESC[1mESC[4mDetermining graph multiplicityESC[0m (2024-01-25 02:14:52)
Multiplicity is the number of times a sequence occurs in the underlying
sequence. Single-copy contigs (those with a multiplicity of one, occurring only
once in the underlying sequence) are particularly useful.
RecursionError: maximum recursion depth exceeded
...
RecursionError: maximum recursion depth exceeded
- 解决方法:直接使用spades组装:
(unicycler) [yut@node02 Scripts]$ nohup time spades.py -1 /datanode02/yut/04_MicroFungi/Trimgalore/Clean_reads/MD-228_1.fq.gz -2 /datanode02/yut/04_MicroFungi/Trimgalore/Clean_reads/MD-228_2.fq.gz -o /datanode02/yut/04_MicroFungi/Unicycler_assembly/MD-228_spades --isolate -t 30 &>/datanode02/yut/04_MicroFungi/Unicycler_assembly/MD-228_spades.log &
Error: miniasm assembly failed
除了软件安装不完整外,另外一种可能是测序深度太低。你有多少bp的长读段,你的基因组有多大?Miniasm对低深度的长读段无法组装。如果这是一个混合组装,那么miniasm组装失败也不一定是个问题–Unicycler可以用其他方法为Illumina组装图提供支架。
然而,如果你的长读段是相当高的深度(20倍或更多),而它仍然失败,那么就不太确定了,我们必须深入挖掘。
- Unable to polish assembly using Pilon: Pilon encountered an error
Pilon version 1.24 Thu Jan 28 13:00:45 2021 -0500
Genome: 1_polish_input.fasta
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.broadinstitute.pilon.GenomeRegion.<init>(GenomeRegion.scala:57)
at org.broadinstitute.pilon.GenomeFile.$anonfun$contigRegions$1(GenomeFile.scala:73)
at org.broadinstitute.pilon.GenomeFile.$anonfun$contigRegions$1$adapted(GenomeFile.scala:73)
at org.broadinstitute.pilon.GenomeFile$$Lambda$31/0x0000000100149040.apply(Unknown Source)
at scala.collection.immutable.Range.map(Range.scala:59)
at org.broadinstitute.pilon.GenomeFile.contigRegions(GenomeFile.scala:73)
at org.broadinstitute.pilon.GenomeFile.$anonfun$regions$1(GenomeFile.scala:53)
at org.broadinstitute.pilon.GenomeFile$$Lambda$30/0x0000000100148040.apply(Unknown Source)
at scala.collection.immutable.List.map(List.scala:250)
at org.broadinstitute.pilon.GenomeFile.<init>(GenomeFile.scala:53)
at org.broadinstitute.pilon.Pilon$.main(Pilon.scala:108)
at org.broadinstitute.pilon.Pilon.main(Pilon.scala)
解决方法:
找到pilon脚本的位置,打开源码修改如下代码,即将pilon使用的java默认最小及最大内存设置更大数值
$ vi ~/Software/Miniconda3/envs/unicycler/bin/pilon
default_jvm_mem_opts = ['-Xms100g', '-Xmx999g']
#default_jvm_mem_opts = ['-Xms512m', '-Xmx1g']
下载unicycler github测试数据,运行如下命令测试是否成功
time unicycler -1 short_reads_1.fastq.gz -2 short_reads_2.fastq.gz -l long_reads_low_depth.fastq.gz --verbosity 3 -t 20 -o short_long_assembly &>log&
Failed to determine offset! Specify it manually and restart, please!
== Running read error correction tool: /datanode02/yut/Software/Miniconda3/envs/unicycler/share/spades-3.13.1-0/bin/spades-hammer /datanode02/yut/04_MicroFungi/Unicycler_assembly/Tricholomamatsutake_Z951-R01/spades_assembly/read_correction/corrected/configs/config.info
0:00:00.001 4M / 4M INFO General (main.cpp : 75) Starting BayesHammer, built from refs/heads/spades_3.13.1, git revision 9a9d54db2ff9abaac718155bf74c12ec9464e8ca
0:00:00.026 4M / 4M INFO General (main.cpp : 76) Loading config from /datanode02/yut/04_MicroFungi/Unicycler_assembly/Tricholomamatsutake_Z951-R01/spades_assembly/read_correction/corrected/configs/config.info
0:00:00.049 4M / 4M INFO General (main.cpp : 78) Maximum # of threads to use (adjusted due to OMP capabilities): 10
0:00:00.050 4M / 4M INFO General (memory_limit.cpp : 49) Memory limit set to 250 Gb
0:00:00.051 4M / 4M INFO General (main.cpp : 86) Trying to determine PHRED offset
0:00:01.839 4M / 4M ERROR General (main.cpp : 89) Failed to determine offset! Specify it manually and restart, please!
== Error == system call for: "['/datanode02/yut/Software/Miniconda3/envs/unicycler/share/spades-3.13.1-0/bin/spades-hammer', '/datanode02/yut/04_MicroFungi/Unicycler_assembly/Tricholomamatsutake_Z951-R01/spades_assembly/read_correction/corrected/configs/config.info']" finished abnormally, err code: 255
- 解决:https://github.com/rrwick/Unicycler/issues/279
$ mamba update bioconda::unicycler
(unicycler) [yut@node03 04_MicroFungi]$ unicycler --version
Unicycler v0.5.0
# 现在Illumina数据都是phred33,因此添加--spades_options "--phred-offset 33"选项运行
Error: SPAdes failed to produce an assembly graph
原因:之前kmer组装结果不完整,后续无法迭代
解决:删除输出目录,重新运行