标签:
- 模型中心混合
- PyTorch模型中心混合
管道标签: 特征提取
SegmentBorzoi
SegmentBorzoi 是一种利用 Borzoi 的分割模型,用于预测序列中多种基因组元素在单核苷酸分辨率下的位置。该模型在14种不同类别上进行了训练,包括基因(蛋白质编码基因、lncRNA、5'UTR、3'UTR、外显子、内含子、剪接受体和供体位点)和调控元件(polyA信号、组织不变和组织特异性启动子及增强子,以及CTCF结合位点)。
需要注意的是,该模型基于Borzoi的已发布实现(最初为Keras版本)。我们使用了 FlashZoi 实现来简化与已发布模型的通用部分,但在必要时根据发布版本进行了调整,例如注意力层中的位置嵌入。
开发团队: InstaDeep
使用方法
在下一个版本发布之前,需要通过以下命令从源代码安装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号染色体。训练过程中,序列在基因组中随机采样并附带注释。然而,我们通过使用524kb(原始borzoi输入长度)的滑动窗口在20号和21号染色体上保持验证集和测试集中的序列固定。验证集用于监控训练和早期停止。
训练流程
预处理
DNA序列使用与Enformer模型类似的one-hot编码进行标记化。
架构
该模型由Borzoi主干组成,我们移除了其头部并替换为一个1维U-Net分割头,该分割头由2个下采样卷积块和2个上采样卷积块组成。每个块由2个卷积层组成,分别具有1,024和2,048个核。
BibTeX条目和引用信息
@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}
}