🚀 SegmentBorzoi
SegmentBorzoi是一個分割模型,它利用Borzoi,以單核苷酸分辨率預測序列中幾種基因組元素的位置。該模型在14種不同的類別上進行訓練,包括基因(蛋白質編碼基因、長鏈非編碼RNA、5'非翻譯區、3'非翻譯區、外顯子、內含子、剪接受體和供體位點)和調控(多聚腺苷酸信號、組織不變和組織特異性啟動子和增強子,以及CTCF結合位點)元素。
🚀 快速開始
在該模型的下一個版本發佈之前,為了使用這些模型,需要從源代碼安裝transformers
庫。同時,還需要安裝PyTorch、einops和borzoi_pytorch
。
pip install --upgrade git+https://github.com/huggingface/transformers.git
pip install torch einops borzoi_pytorch==0.4.0
以下是一段代碼示例,用於從虛擬DNA序列中獲取對數幾率(logits)。
💻 使用示例
基礎用法
import torch
from transformers import AutoModel
model = AutoModel.from_pretrained("InstaDeepAI/segment_borzoi", trust_remote_code=True)
def encode_sequences(sequences):
one_hot_map = {
'a': torch.tensor([1., 0., 0., 0.]),
'c': torch.tensor([0., 1., 0., 0.]),
'g': torch.tensor([0., 0., 1., 0.]),
't': torch.tensor([0., 0., 0., 1.]),
'n': torch.tensor([0., 0., 0., 0.]),
'A': torch.tensor([1., 0., 0., 0.]),
'C': torch.tensor([0., 1., 0., 0.]),
'G': torch.tensor([0., 0., 1., 0.]),
'T': torch.tensor([0., 0., 0., 1.]),
'N': torch.tensor([0., 0., 0., 0.])
}
def encode_sequence(seq_str):
one_hot_list = []
for char in seq_str:
one_hot_vector = one_hot_map.get(char, torch.tensor([0.25, 0.25, 0.25, 0.25]))
one_hot_list.append(one_hot_vector)
return torch.stack(one_hot_list)
if isinstance(sequences, list):
return torch.stack([encode_sequence(seq) for seq in sequences])
else:
return encode_sequence(sequences)
sequences = ["A"*524_288, "G"*524_288]
one_hot_encoding = encode_sequences(sequences)
preds = model(one_hot_encoding)
print(preds['logits'])
📦 訓練數據
SegmentBorzoi模型在除20號和21號染色體(作為測試集)以及22號染色體(作為驗證集)之外的所有人染色體上進行訓練。在訓練過程中,序列是從基因組中隨機採樣並關聯註釋的。不過,我們通過在20號和21號染色體上使用長度為524kb(原始Borzoi輸入長度)的滑動窗口,固定了驗證集和測試集中的序列。驗證集用於監控訓練過程和提前停止訓練。
🔧 訓練過程
預處理
DNA序列使用與Enformer模型類似的獨熱編碼進行標記化。
架構
該模型由Borzoi主幹組成,我們移除了其頭部,並將其替換為一個一維U-Net分割頭,該分割頭由2個下采樣卷積塊和2個上採樣卷積塊組成。每個塊分別由2個卷積層組成,卷積核數量分別為1024和2048。
📚 引用信息
@article{de2024segmentnt,
title={SegmentNT: annotating the genome at single-nucleotide resolution with DNA foundation models},
author={de Almeida, Bernardo P and Dalla-Torre, Hugo and Richard, Guillaume and Blum, Christopher and Hexemer, Lorenz and Gelard, Maxence and Pandey, Priyanka and Laurent, Stefan and Laterre, Alexandre and Lang, Maren and others},
journal={bioRxiv},
pages={2024--03},
year={2024},
publisher={Cold Spring Harbor Laboratory}
}
開發者:InstaDeep