Biotrainerは、生物学的用途向けの機械学習モデルのトレーニングプロセスを簡素化するためのオープンソースツールです。タンパク質の特徴を予測するためのモデルを専門としています。 Biotrainerは、両方をサポートし、新しいモデルのトレーニングを行い、推論のために訓練されたモデルを採用しています。 Biotrainerを使用すると、構成ファイルとともに、シーケンスとラベルデータを正しい形式で提供するのと同じくらい簡単です。
curl -sSL https://install.python-poetry.org/ | python3 -poetryを介して依存関係と生物学者をインストールします。 # In the base directory:
poetry install
# Adding jupyter notebook (if needed):
poetry add jupyter
# [WINDOWS] Explicitly install torch libraries suited for your hardware:
# Select hardware and get install command here: https://pytorch.org/get-started/locally/
# Then run for example:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118モデルの再現性については、 pyproject.tomlで提供されるのと同じトーチバージョンを使用してください!
素敵なGUIフロントエンドでBiotrainerを使用したい場合は、 Biocentralをご覧ください。
cd examples/residue_to_class
poetry run biotrainer config.yml開発とデバッグのために提供されたrun-biotrainer.pyファイルを使用することもできます(IDEを設定して、提供された仮想環境でrun-biotrainer.pyを直接実行することをお勧めします):
# residue_to_class
poetry run python3 run-biotrainer.py examples/residue_to_class/config.yml
# sequence_to_class
poetry run python3 run-biotrainer.py examples/sequence_to_class/config.yml # Build
docker build -t biotrainer .
# Run
docker run --rm
-v " $( pwd ) /examples/docker " :/mnt
-u $( id -u ${USER} ) : $( id -g ${USER} )
biotrainer:latest /mnt/config.ymlその後、出力は、提供された構成ファイルのディレクトリにあります。
モデルがトレーニングされた後、デフォルトでoutputディレクトリにout.ymlファイルがあります。これを使用して、新しいデータのモデルで予測を作成できるようになりました。 inferencerモジュールは、チェックポイントを自動的に読み込むことになります。
from biotrainer . inference import Inferencer
from biotrainer . embedders import OneHotEncodingEmbedder
sequences = [
"PROVTEIN" ,
"SEQVENCESEQVENCE"
]
out_file_path = '../residue_to_class/output/out.yml'
inferencer , out_file = Inferencer . create_from_out_file ( out_file_path = out_file_path , allow_torch_pt_loading = True )
print ( f"For the { out_file [ 'model_choice' ] } , the metrics on the test set are:" )
for metric in out_file [ 'test_iterations_results' ][ 'metrics' ]:
print ( f" t { metric } : { out_file [ 'test_iterations_results' ][ 'metrics' ][ metric ] } " )
embedder = OneHotEncodingEmbedder ()
embeddings = list ( embedder . embed_many ( sequences ))
# Note that for per-sequence embeddings, you would have to reduce the embeddings now:
# embeddings = [[embedder.reduce_per_protein(embedding)] for embedding in embeddings]
predictions = inferencer . from_embeddings ( embeddings , split_name = "hold_out" )
for sequence , prediction in zip ( sequences , predictions [ "mapped_predictions" ]. values ()):
print ( sequence )
print ( prediction )
# If your checkpoints are stored as .pt, consider converting them to safetensors (supported by biotrainer >=0.9.1)
inferencer . convert_all_checkpoints_to_safetensors ()ここで完全な例を参照してください。
inferencerモジュールは、 bootstrappingとmonte carlo dropoutによる予測も特徴です。
Biotrainerは、生物学のための機械学習の使用を容易にするように設計された多くのデータ標準を提供します。この標準化プロセスは、さまざまな科学分野間のコミュニケーションを改善し、タンパク質予測の急速に発展している分野に関する概要を維持するのに役立つことも期待されています。
プロトコルは、入力データの解釈方法、およびどの種類の予測タスクを適用する必要があるかを定義します。次のプロトコルはすでに実装されています。
D=embedding dimension (e.g. 1024)
B=batch dimension (e.g. 30)
L=sequence dimension (e.g. 350)
C=number of classes (e.g. 13)
- residue_to_class --> Predict a class C for each residue encoded in D dimensions in a sequence of length L. Input BxLxD --> output BxLxC
- residues_to_class --> Predict a class C for all residues encoded in D dimensions in a sequence of length L. Input BxLxD --> output BxC
- residues_to_value --> Predict a value V for all residues encoded in D dimensions in a sequence of length L. Input BxLxD --> output Bx1
- sequence_to_class --> Predict a class C for each sequence encoded in a fixed dimension D. Input BxD --> output BxC
- sequence_to_value --> Predict a value V for each sequence encoded in a fixed dimension D. Input BxD --> output Bx1
すべてのプロトコルについて、入力データの提供方法に関する標準化を作成しました。各プロトコルの詳細情報はこちらをご覧ください。
以下に、sequence andラベルファイルがresidue_to_classプロトコルのどのように見えるかについての例を示します。
sequences.fasta
>Seq1
SEQWENCE
Labels.Fasta
>Seq1 SET=train VALIDATION=False
DVCDVVDD
Biotrainerを実行するには、シーケンスとラベルデータとともに.yaml形式で構成ファイルを提供する必要があります。ここでは、 destimue_to_classプロトコルの模範的なファイルを見つけることができます。すべての構成オプションはここにリストされています。
Lestimue_to_classの例の構成:
protocol : residue_to_class
sequence_file : sequences.fasta # Specify your sequence file
labels_file : labels.fasta # Specify your label file
model_choice : CNN # Model architecture
optimizer_choice : adam # Model optimizer
learning_rate : 1e-3 # Optimizer learning rate
loss_choice : cross_entropy_loss # Loss function
use_class_weights : True # Balance class weights by using class sample size in the given dataset
num_epochs : 200 # Number of maximum epochs
batch_size : 128 # Batch size
embedder_name : Rostlab/prot_t5_xl_uniref50 # Embedder to useシーケンスデータをモデルのより意味のある入力に変換するために、タンパク質言語モデル(PLM)によって生成された埋め込みは、過去数年間に広く適用されています。したがって、 Biotrainerは、プロトコルに応じて、シーケンスごとおよびレシドごとのレベルでの埋め込みの自動計算を可能にします。埋め込みオプションを見て、利用可能なすべての埋め込み方法について調べてください。また、提供された計算パイプラインとは無関係に、独自の埋め込みを使用して独自の埋め込みファイルを提供することもできます。これを行う方法を学ぶには、データ標準化ドキュメントと関連する例を参照してください。事前に計算された埋め込みは、構成オプションで説明されているように、 embeddings_fileパラメーターを介してトレーニングプロセスに使用できます。
インストールや実行中に問題が発生している場合は、最初にトラブルシューティングガイドを確認してください。
問題がカバーされていない場合は、問題を作成してください。
仕事にBiotrainerを使用している場合は、引用を追加してください。
@inproceedings{
sanchez2022standards,
title={Standards, tooling and benchmarks to probe representation learning on proteins},
author={Joaquin Gomez Sanchez and Sebastian Franz and Michael Heinzinger and Burkhard Rost and Christian Dallago},
booktitle={NeurIPS 2022 Workshop on Learning Meaningful Representations of Life},
year={2022},
url={https://openreview.net/forum?id=adODyN-eeJ8}
}