macでインフォマティクス

macでインフォマティクス

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

ディープニューラルネットワークによる高速・高精度・多用途な系統復元を行う Phyloformer

 

系統推論は、共通の祖先から派生した配列の進化を記述する樹を再構築することを目的としている。最新の最尤推論やベイズ推論は計算コストが高いため、現実的な進化モデルの下では使い勝手が悪い。尤度なし推論と幾何学ディープラーニングの最近の進歩を利用して、進化的距離推定と系統再構築のための高速で正確な手法であるPhyloformerを紹介する。進化モデルの下で多数の木と配列をサンプリングし、ネットワークを訓練して、複数配列アラインメントから木を予測できる関数を学習する。模擬データを用いて、Phyloformerと、距離法であるFastME、2つの最尤法とを比較する: FastTreeとIQTreeである。一般的に使われているタンパク質配列進化のモデルのもとで、GPU(Graphics Processing Unit)アクセラレーションを利用した場合、Phyloformerは他のすべてのアプローチを凌駕し、トポロジーと枝の長さの両方を考慮したKuhner-Felsenstein指標において、それらの精度を上回った。トポロジーのみの精度では、PhyloformerはFastMEを上回るが、特に配列数が増えるにつれて最尤アプローチに遅れをとる。部位間の依存性を含む配列進化のモデルを使用した場合、Phyloformerは80配列未満のアラインメントにおいて、全ての評価基準において他の全ての方法を凌駕した。5つの異なるデータセットから得られた3,801の経験的遺伝子アラインメントにおいて、Phyloformerは2つの最尤実装のトポロジー精度に匹敵した。我々の結果は、洗練された現実的なモデルを系統推定に採用する道を開くものである。

 

HP

http://www.atgc-montpellier.fr/fastme/

 

インストール

mambaで環境を作ってテストした。

GitLab

git clone https://github.com/lucanest/Phyloformer.git
cd Phyloformer

mamba create -n phylo python=3.8 -y
conda activate phylo
pip install -r requirements.txt
#失敗したら
pip install tqdm scipy dendropy
pip install torch==2.0.1+cu117 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117

> ./bin/bin_linux/phylocompare -h

Compare trees to reference trees

 

Usage: phylocompare [OPTIONS] --output-prefix <OUTPUT_PREFIX> <REF_TREES> [CMP_TREES]...

 

Arguments:

  <REF_TREES>     Directory containing reference trees

  [CMP_TREES]...  Directory containing trees to compare

 

Options:

  -o, --output-prefix <OUTPUT_PREFIX>  Output file prefix that will be used for all output files

  -m, --marker <MARKER>                Add `marker` columns to csv output with this constant. If unset, the column will be empty in the output file

  -l, --lengths                        Compare branch lengths instead of tree metrics

  -i, --include-tips                   Include tips when comparing branches of trees (this flag is only used when the `--lengths` flag is specified)

  -d, --distances                      If specified compare pairwise distances

  -t, --topology                       If specified compare topologies

  -b, --branches                       If specified compare branches

  -a, --all                            Compare everything: topology, branches and pairwise distances

  -s, --strict                         Exit the program early on error instead of listing them at the end

      --threads <THREADS>              Number of threads to use in parallel (0 = all available threads) [default: 0]

  -n, --no-compression                 Do not compress output csv using gzip

  -h, --help                           Print help 

 

テストラン

こちらのデータを使う。

data/testdata/msas/

 

1,infer_alns.py を使って各MSAファイル(FASTA形式)から距離行列(Phylip形式)を推定(モデル: LG+GC PF model )。

python infer_alns.py -o data/testdata/pf_matrices models/pf.ckpt data/testdata/msas

出力例

data/testdata/pf_matrices/

 

2,FastMEを使って系統推定

mkdir data/testdata/pf_trees
for file in data/testdata/pf_matrices/*; do
  base="${file##*/}"
  stem="${base%%.*}"
  ./bin/bin_linux/fastme -i "${file}" -o "data/testdata/pf_trees/${stem}.nwk" --nni --spr
done

#注;arm CPUならbin_macosを使う

出力例

data/testdata/pf_trees/

 

3,phylocompareを使って構築した系統樹を比較して評価する。

./bin/bin_linux/phylocompare -t -n -o data/cmp data/testdata/trees data/testdata/pf_trees

data/

 

4,比較結果から平均KF距離を計算

./bin/bin_linux/phylocompare -t -n -o data/cmp data/testdata/trees data/testdata/pf_trees

出力例

 

その他

  • 現在5つのモデルが提供されている(link)。

引用

Phyloformer: Fast, Accurate, and Versatile Phylogenetic Reconstruction with Deep Neural Networks

Luca Nesterenko , Luc Blassel , Philippe Veber , Bastien Boussau , Laurent Jacob

Molecular Biology and Evolution, Volume 42, Issue 4, April 2025

 

*1

phyloformer/model.pyの175行を以下のように修正

out = torch.matmul(self.seq2pair.to(out.device), out.transpose(-1, -2))