macでインフォマティクス

macでインフォマティクス

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

ロングリードのハイブリッドエラー訂正を行う HERRO

20240419 タイトル修正

 

注;論文のタイトルにはHEROと書かれてますが、レポジトリではHERROとなっています。ここではHERROで統一します。

 

一般的に優れているが、次世代シーケンシング(NGS)リードを用いた第3世代シーケンシング(TGS)リードのエラーを修正するハイブリッドアプローチは、ハプロタイプ特異的バリアントを、倍数体サンプルや混合サンプルのエラーと取り違える。HERROは、NGSリードとTGSリードの特定の強みに最適に対応するために、de Bruijnグラフとオーバーラップグラフの両方を利用する最初の「ハイブリッド-ハイブリッド」アプローチとして提案する。広範なベンチマーク実験により、HERROはindelとミスマッチのエラー率を平均65% (27~95%)および20% (4~61%)、ゲノムアセンブリの前にHEROを使用することで、関連するカテゴリーの大部分でアセンブリが大幅に改善される。

 

 

HERROはHaplotype-aware ERRor cOrrectionを意味する。

インストール

依存

注;HERROはGPUのVRAMをかなり使う。推奨80GBかつ複数GPUとなっている(ヒトゲノムなど)。

 

説明されている通り、レポジトリをcloneして依存するツールを導入(前処理のステップ1と2用)、それからsingularityイメージをビルドした。最後にモデルをダウンロードして実行した(古いsingularityだと動かないので注意。v3.9.5を使用した)。

Github

https://github.com/lbcb-sci/herro

#1
git clone https://github.com/dominikstanojevic/herro.git
cd herro
mamba env create --file scripts/herro-env.yml

#2  singularityイメージのビルド
sudo singularity build herro.sif herro-singularity.def
#もしくはビルド済みのイメージをダウンロード(3.5GB)
wget http://complex.zesoi.fer.hr/data/downloads/herro.sif

> scripts/preprocess.sh

Please place porechop_with_split.sh and no_split.sh in the same directory as this script.

This script requires 4 arguments:

1. The input sequence file. e.g. input.fastq

2. The output prefix. e.g. 'preprocessed' or 'output_dir/preprocessed'

3. The number of threads to be used.

4. The number of parts to split the inputs into for porechop (since RAM usage may be high).

 

> scripts/create_batched_alignments.sh

Please place batch.py in the same directory as this script.

This script requires 4 arguments:

1. The path to the preprocessed reads.

2. The path to the read ids of these reads e.g. from seqkit seq -n -i.

3. The number of threads to be used.

4. The directory to output the batches of alignments.

 

> singularity run --nv herro.sif inference -h

$ singularity run --nv herro.sif inference -h

Subcommand used for error-correcting reads

 

Usage: herro inference [OPTIONS] -m <MODEL> -b <BATCH_SIZE> <READS> <OUTPUT>

 

Arguments:

  <READS>   Path to the fastq reads (can be gzipped)

  <OUTPUT>  Path to the corrected reads

 

Options:

      --read-alns <READ_ALNS>    Path to the folder containing *.oec.zst alignments

      --write-alns <WRITE_ALNS>  Path to the folder where *.oec.zst alignments will be saved

  -w <WINDOW_SIZE>               Size of the window used for target chunking (default 4096) [default: 4096]

  -t <FEAT_GEN_THREADS>          Number of feature generation threads per device (default 1) [default: 1]

  -m <MODEL>                     Path to the model file

  -d <DEVICES>                   List of cuda devices in format d0,d1... (e.g 0,1,3) (default 0) [default: 0]

  -b <BATCH_SIZE>                Batch size per device. B=64 recommended for 40 GB GPU cards.

  -h, --help                     Print help

 

 

 

モデルのダウンロード

wget http://complex.zesoi.fer.hr/data/downloads/model_v0.1.pt

 

実行方法

HERROは複数のステージから構成されている。ステップ1、2はcondaで作った環境で実行する前処理のステップ(HERROは使わない)。ステップ3のherro inferenceコマンドはsingularityイメージを使用する。

 

1、Preprocess reads

PorechopによるONTリードの前処理。10スレッド指定。最後にメモリ使用量を削減するために一過的にリードを分割して扱うための分割数を指定する。分割が不要な場合は、メモリ使用量が増えるが<parts_to_split_job_into>を1に設定する。ONTデータが巨大なら分割が推奨される。

conda activate herro
scripts/preprocess.sh input_fastq out_prefix 10 <parts_to_split_job_into>

Dorado v0.5では、アダプタートリミングが追加されたため、Porechopやduplexツールを使用したアダプタートリミングや分割はおそらく将来不要になる(レポジトリより)。

outprefix.fastq.gzが得られる。

 

2、minimap2 alignment and batching

1の出力のロングリードを指定する。reads.idはseqkitで取得できる。20スレッド指定。

#1 seqkit seq
seqkit seq -ni outprefix.fastq.gz > reads.id

#2 minimap2 alignment and batching
scripts/create_batched_alignments.sh outprefix.fastq.gz reads.id 20 outdir

outdir/を3で指定する。

 

3、Error-correction

singularityイメージを使う。モデルファイル、バッチサイズ、リードと出力を指定する。推奨バッチサイズは、VRAM40GB(32GBでも可能)のGPUでは64、VRAM80GBのGPUでは128となっている。

singularity run --nv --bind <host_path>:<dest_path> herro.sif inference --read-alns outdir -t <feat_gen_threads_per_device> -d <gpus> -m model_v0.1.pt -b <batch_size> <preprocessed_reads> <fasta_output> 

(レポジトリより)GPU は ID を使って指定する。例えば、パラメータ -d の値が 0,1,3 に設定された場合、herro は 1 番目、2 番目、4 番目の GPU カードを使用する。パラメータ -t はデバイスごとに与えられる - 例えば、-t が 8 に設定され、3 つの GPU が使われる場合、herro は合計で 24 の特徴生成パッドを作成する。

 

 

メモ

  • 論文のR-HERO、F-HERO、L-HEROはRatatosk、FMLRC、LoRDECの3つの反復を指す。
  • 論文では、DBGベースのHybrid error correction (HEC) 手法であるLoRDEC、FMLRC、Ratatosk のいずれかを用いてTGSリードを事前補正している。FMLRC、LoRDEC、およびRatatoskとも、最初の3ラウンドの反復で結果が著しく改善している。
  • レポジトリには、HG002のHifi reads/Duplex ONT reads/Corrected UL readsを使ってHifiasmでアセンブルした結果の表が提示されている。未訂正Duplex ONT readsよりHERRO Corrected readsの方が著しくアセンブリが改善されていて、エラー率では及ばないものの、連続性ではHifiリードを上回っている。

引用

Hybrid-hybrid correction of errors in long reads with HERO
Xiongbin Kang, Jialu Xu, Xiao Luo & Alexander Schönhuth 
Genome Biology volume 24, Article number: 275 (2023) 

 

関連

ナノポアのアダプタートリミングツール Porechop