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 프론트 엔드와 함께 바이오 트레인을 사용하려면 BioCentral을 확인하십시오.
cd examples/residue_to_class
poetry run biotrainer config.yml 개발 및 디버깅에 제공된 run-biotrainer.py 파일을 사용할 수도 있습니다 (제공된 가상 환경에서 Run-BiotRainer.py를 직접 실행하기 위해 IDE를 설정할 수도 있습니다).
# 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
모든 프로토콜에 대해 입력 데이터를 제공하는 방법에 대한 표준화를 만들었습니다. 각 프로토콜에 대한 자세한 정보를 여기에서 찾을 수 있습니다.
다음은 gress_to_class 프로토콜의 시퀀스 및 레이블 파일이 어떻게 보이는지에 대한 예를 보여줍니다.
시퀀스 .fasta
>Seq1
SEQWENCE
labels.fasta
>Seq1 SET=train VALIDATION=False
DVCDVVDD
Biotrainer를 실행하려면 순서 및 레이블 데이터와 함께 구성 파일을 .yaml 형식으로 제공해야합니다. 여기에서 residue_to_class 프로토콜에 대한 예시 파일을 찾을 수 있습니다. 모든 구성 옵션은 여기에 나열되어 있습니다.
residue_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)에 의해 생성 된 임베딩은 지난 몇 년 동안 널리 적용되었습니다. 따라서, 바이오 리너는 프로토콜에 따라 시퀀스 당 및 재시성당 수준에 대한 임베딩을 자동으로 계산할 수 있습니다. 사용 가능한 모든 임베딩 방법에 대해 알아 보려면 임베딩 옵션을 살펴보십시오. 제공된 계산 파이프 라인과 무관하게 자체 임베더를 사용하여 자체 임베딩 파일을 제공 할 수도 있습니다. 이 작업을 수행하는 방법을 배우려면 데이터 표준화 문서 및 관련 예제를 참조하십시오. 사전 계산 된 임베딩은 구성 옵션에 설명 된 바와 같이 embeddings_file 매개 변수를 통해 훈련 프로세스에 사용될 수 있습니다.
설치 또는 실행 중에 문제가 발생하는 경우 먼저 문제 해결 안내서를 확인하십시오.
문제가 해결되지 않은 경우 문제를 만드십시오.
작업에 바이오 리너를 사용하는 경우 인용을 추가하십시오.
@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}
}