macでインフォマティクス

macでインフォマティクス

HTS (NGS) 関連のインフォマティクス情報についてまとめています。

HiFiロングリードを使ってhaplotype-resolved assemblyを行う Hifiasm

2022/03/26 Hi-Cと組み合わせた論文引用、ツイート追記

2023/02ツイート追記

2024/04/06 追記、help更新

 

 Haplotype-resolved de novo assemblyは、ゲノム配列のバリエーションを研究するための究極のソリューションである。しかし、既存のアルゴリズムでは、ヘテロ接合型の対立遺伝子を1つのコンセンサスコピーにresolveするか、ハプロタイプをきれいに分離して高品質の段階的アセンブリを行うことができない。ここでは、 long high-fidelity sequence readsを利用してハプロタイプ情報を忠実に表現する新しいde novoアセンブラであるhifiasmについて述べる。1つのハプロタイプの連続性の維持のみを目的とする他のグラフベースのアセンブラとは異なり、hifiasmはすべてのハプロタイプの連続性を維持することを目指している。この機能により、標準的なトリオビニングよりも大幅に進化したグラフトリオビニングアルゴリズムの開発が可能になった。ヒトとヒト以外の5つのデータセット(約30ギガベースの六倍体ゲノムを持つカリフォルニアレッドウッドを含む)を用いて、hifiasmが既存のツールよりも優れたアセンブリを提供し、haplotype-resolved assemblyにおいて他のツールよりも一貫して優れていることを示した。

 

レポジトリより

  • Hifiasmは高品質なアセンブリを提供する。Hifiasmは他のアセンブラよりも長いコンティグを生成し、より多くのセグメント重複を解決する傾向がある。

  • 親のシーケンスリードも与えられた場合、hifiasmはこれまでのところ、全体的に最高のhaplotype-resolved assemblyを生成することができる。Human Pangenome Projectがバッチサンプルを対象に選択した最初のアセンブラになった。

  • Hifiasmは、purge_dupsのようなサードパーティ製ツールに頼らずに、ハプロタイプ間の重複をパージすることができる。Hifiasm は pilon や racon のようなポリッシングツールも必要ない。これにより、アセンブリパイプラインが簡素化され、実行時間が短縮される。

  • Hifiasmは高速である。ヒトゲノムを半日でアセンブルし、~30Gbのレッドウッドゲノムを3日でアセンブルすることができる。Hifiasmには大きすぎるゲノムはない。

  • Hifiasmはインストールが簡単で使いやすい。python、R、C++11コンパイラを必要とせず、1つの実行ファイルにコンパイルすることができる。デフォルト設定で様々なゲノムに対応する。

 

 

Documentation

https://hifiasm.readthedocs.io/en/latest/index.html

Tutorial

Hifiasm — hifiasm 0.16.0 documentation

 

インストール

ubuntu18.04LTSでテストした。レポジトリではmambaによる導入が推奨されているが、ここではcondaコマンドでcondaの仮想環境に導入した。

本体 Github

#from source
git clone https://github.com/chhylp123/hifiasm
cd hifiasm && make -j20

#bioconda (link)
conda install -c bioconda hifiasm -y

hifiasm -h

Usage: hifiasm [options] <in_1.fq> <in_2.fq> <...>

Options:

  Input/Output:

    -o STR       prefix of output files [hifiasm.asm]

    -t INT       number of threads [1]

    -h           show help information

    --version    show version number

  Overlap/Error correction:

    -k INT       k-mer length (must be <64) [51]

    -w INT       minimizer window size [51]

    -f INT       number of bits for bloom filter; 0 to disable [37]

    -D FLOAT     drop k-mers occurring >FLOAT*coverage times [5.0]

    -N INT       consider up to max(-D*coverage,-N) overlaps for each oriented read [100]

    -r INT       round of correction [3]

    -z INT       length of adapters that should be removed [0]

    --max-kocc   INT

                 employ k-mers occurring <INT times to rescue repetitive overlaps [2000]

    --hg-size    INT(k, m or g)

                 estimated haploid genome size used for inferring read coverage [auto]

  Assembly:

    -a INT       round of assembly cleaning [4]

    -m INT       pop bubbles of <INT in size in contig graphs [10000000]

    -p INT       pop bubbles of <INT in size in unitig graphs [0]

    -n INT       remove tip unitigs composed of <=INT reads [3]

    -x FLOAT     max overlap drop ratio [0.8]

    -y FLOAT     min overlap drop ratio [0.2]

    -i           ignore saved read correction and overlaps

    -u           post-join step for contigs which may improve N50; 0 to disable; 1 to enable

                 [1] and [1] in default for the UL+HiFi assembly and the HiFi assembly, respectively

    --hom-cov    INT

                 homozygous read coverage [auto]

    --lowQ       INT

                 output contig regions with >=INT% inconsistency in BED format; 0 to disable [70]

    --b-cov      INT

                 break contigs at positions with <INT-fold coverage; work with '--m-rate'; 0 to disable [0]

    --h-cov      INT

                 break contigs at positions with >INT-fold coverage; work with '--m-rate'; -1 to disable [-1]

    --m-rate     FLOAT

                 break contigs at positions with <=FLOAT*coverage exact overlaps;

                 only work with '--b-cov' or '--h-cov'[0.75]

    --primary    output a primary assembly and an alternate assembly

  Trio-partition:

    -1 FILE      hap1/paternal k-mer dump generated by "yak count"

    -2 FILE      hap2/maternal k-mer dump generated by "yak count"

    -3 FILE      list of hap1/paternal read names

    -4 FILE      list of hap2/maternal read names

    -c INT       lower bound of the binned k-mer's frequency [2]

    -d INT       upper bound of the binned k-mer's frequency [5]

    --t-occ      INT

                 forcedly remove unitigs with >INT unexpected haplotype-specific reads;

                 ignore graph topology; [60]

    --trio-dual  utilize homology information to correct trio phasing errors

  Purge-dups:

    -l INT       purge level. 0: no purging; 1: light; 2/3: aggressive [0 for trio; 3 for unzip]

    -s FLOAT     similarity threshold for duplicate haplotigs in read-level [0.75 for -l1/-l2, 0.55 for -l3]

    -O INT       min number of overlapped reads for duplicate haplotigs [1]

    --purge-max  INT

                 coverage upper bound of Purge-dups [auto]

    --n-hap      INT

                 number of haplotypes [2]

  Hi-C-partition:

    --h1 FILEs   file names of Hi-C R1  [r1_1.fq,r1_2.fq,...]

    --h2 FILEs   file names of Hi-C R2  [r2_1.fq,r2_2.fq,...]

    --seed INT   RNG seed [11]

    --s-base     FLOAT

                 similarity threshold for homology detection in base-level;

                 -1 to disable [0.5]; -s for read-level (see <Purge-dups>)

    --n-weight   INT

                 rounds of reweighting Hi-C links [3]

    --n-perturb  INT

                 rounds of perturbation [10000]

    --f-perturb  FLOAT

                 fraction to flip for perturbation [0.1]

    --l-msjoin   INT

                 detect misjoined unitigs of >=INT in size; 0 to disable [500000]

  Ultra-Long-integration:

    --ul FILEs   file names of Ultra-Long reads [r1.fq,r2.fq,...]

    --ul-rate    FLOAT

                 error rate of Ultra-Long reads [0.2]

    --ul-tip     INT

                 remove tip unitigs composed of <=INT reads for the UL assembly [6]

    --path-max   FLOAT

                 max path drop ratio [0.6]; higher number may make the assembly cleaner

                 but may lead to more misassemblies

    --path-min   FLOAT

                 min path drop ratio [0.2]; higher number may make the assembly cleaner

                 but may lead to more misassemblies

    --ul-cut     INT

                 filter out <INT UL reads during the UL assembly [0]

  Dual-Scaffolding:

    --dual-scaf  output scaffolding

    --scaf-gap   INT

                 max gap size for scaffolding [3000000]

Example: ./hifiasm -o NA12878.asm -t 32 NA12878.fq.gz

See `https://hifiasm.readthedocs.io/en/latest/' or `man ./hifiasm.1' for complete documentation.

 

 

実行方法

HiFiロングリードを指定する。

hifiasm -o outprefix -t 32 input.fq.gz
  • -t <INT>   number of threads [1]
  • -o <STR>  prefix of output files [hifiasm.asm]
  • -i   ignore saved read correction and overlaps

初の実行時、hifiasm は修正されたリードとオーバーラップを outprefix.*.bin としてディスクに保存する。次回以降、保存された結果を利用して時間のかかるall versus allのオーバーラップ計算を回避する。事前に計算されたオーバーラップを無視し、raw readsからオーバーラップをやり直すには "-i" を指定する。

 

テストラン

wget https://github.com/chhylp123/hifiasm/releases/download/v0.7/chr11-2M.fa.gz
#use -f0 for small datasets
hifiasm -o test -t 12 -f 0 chr11-2M.fa.gz 2> test.log
# get primary contigs in FASTA
awk '/^S/{print ">"$2;print $3}' test.p_ctg.gfa > test.p_ctg.fa
  • -f <INT>   number of bits for bloom filter; 0 to disable [37]

出力

f:id:kazumaxneo:20210106003155p:plain

マニュアルより

  • `prefix`.r_utg.gfa:ハプロタイプを解決したraw unitigグラフ。このグラフはすべてのハプロタイプ情報を保持している。
  • prefix`.p_utg.gfa:小さなバブルを含まないハプロタイプを解決したunitigグラフ。小さなバブルは、体細胞変異やデータ中のノイズに起因する可能性があり、本当のハプロタイプ情報ではない。Hifiasmはこのような小さなバブルをカバレッジに基づいて自動的に削除する。オプション--hom-covが結果に影響する。オプション -p は強制的にバブルをポップさせる。
  • `prefix`.p_ctg.gfa: プライマリコンティグのアセンブリグラフ。このグラフには、位相分けされたブロックが長く続く完全なアセンブリが含まれる。
  • `prefix`.a_ctg.gfa: 代替コンティグのアセンブリグラフ。このグラフはプライマリコンティググラフで破棄されたすべてのコンティグから構成される。
  • `prefix`.*hap*.p_ctg.gfa: フェーズドコンティググラフ。このグラフは段階的コンティグを保持する。

 

 

レポジトリに記載されている実行例

# Assemble inbred/homozygous genomes (-l0 disables duplication purging)
hifiasm -o CHM13.asm -t 32 -l 0 CHM13-HiFi.fa.gz 2> CHM13.asm.log
# Assemble heterozygous with built-in duplication purging
hifiasm -o HG002.asm -t 32 HG002-file1.fq.gz HG002-file2.fq.gz
  • -l <INT>    purge level. 0: no purging; 1: light; 2: aggressive [0 for trio; 2 for unzip]
  • -z <INT>   length of adapters that should be removed [0]
  • -f <INT>    number of bits for bloom filter; 0 to disable [37]

Hifiasmはデフォルトでハプロティグ重複をパージする。Inbredやホモ接合体ゲノムの場合は、"-l 0"オプションでパージを無効にすることができる。古いHiFiリードには、リードの末端に短いアダプター配列が含まれている場合がある。"-z 20" を指定すると、リードの両端を 20bp トリムすることができる。小規模なゲノムの場合は、-f 0を使用して、最初に16GBのメモリを消費するブルームフィルタを無効にする。ヒトよりも大きなゲノムの場合は、"-f 38"や"-f 39"を指定すると、k-merカウントのメモリを節約できる。

 

Trio binning assembly

# Trio binning assembly (requiring https://github.com/lh3/yak)
yak count -b 37 -t 16 -o pat.yak <(cat pat_1.fq.gz pat_2.fq.gz) <(cat pat_1.fq.gz pat_2.fq.gz)
yak count -b 37 -t 16 -o mat.yak <(cat mat_1.fq.gz mat_2.fq.gz) <(cat mat_1.fq.gz mat_2.fq.gz)
hifiasm -o HG002.asm -t 32 -1 pat.yak -2 mat.yak HG002-HiFi.fa.gz

親のショートリードが利用可能な場合、hifiasmはトリオビニングを用いてhaplotype-resolved assemblyを生成することができる。このようなアセンブリを行うには、まずyak(github)でk-merをカウントしてからアセンブリを行う必要がある。

 

ウルトラロングONTリードを使ったT2Tアセンブリ

hifiasm -o NA12878.asm -t32 --ul ul.fq.gz HiFi-reads.fq.gz
  • --ul     file names of Ultra-Long reads [r1.fq,r2.fq,...]

 

HiFIリードに加えてウルトラロングONTリード、Hii-Cリード(illumina)も使ったT2Tアセンブリ

hifiasm -o NA12878.asm -t32 --ul ul.fq.gz --h1 read1.fq.gz --h2 read2.fq.gz HiFi-reads.fq.gz
  • --h1    file names of Hi-C R1  [r1_1.fq,r1_2.fq,...]
  • --h2    file names of Hi-C R2  [r2_1.fq,r2_2.fq,...]

 

追記

エラーコレクションされたリードを出力する(hifievalより)。

hifiasm -o outprefix --primary -t 10 --write-ec reads.fastq 2> hifiasm.log

outprefix.ec.faが出力される。

 

 

引用

Haplotype-resolved de novo assembly with phased assembly graphs

Haoyu Cheng, Gregory T Concepcion, Xiaowen Feng, Haowen Zhang, Heng Li

arXiv, Submitted on 3 Aug 2020

 
Haplotype-resolved de novo assembly using phased assembly graphs with hifiasm

Haoyu Cheng, Gregory T. Concepcion, Xiaowen Feng, Haowen Zhang & Heng Li
Nature Methods (2021), Published: 01 February 2021

 

2022/03/26

Haplotype-resolved assembly of diploid genomes without parental data

Haoyu Cheng, Erich D. Jarvis, Olivier Fedrigo, Klaus-Peter Koepfli, Lara Urban, Neil J. Gemmell & Heng Li 
Nature Biotechnology (2022)

 

関連

 

2022/03/26