license: cc-by-nc-sa-4.0
widget:
- text: ACCTGATTCTGAGTC
tags:
- DNA
- 生物学
- 基因组学
- 分割
segment-nt-multi-species
SegmentNT-multi-species 是一种分割模型,利用 Nucleotide Transformer (NT) DNA 基础模型,以单核苷酸分辨率预测序列中多种基因组元素的位置。该模型是在 SegmentNT 模型的基础上,通过在一个包含人类基因组以及五种选定物种(小鼠、鸡、果蝇、斑马鱼和线虫)基因组的数据集上进行微调而得到的。
为了在多物种基因组上进行微调,我们精心挑选了用于训练 SegmentNT 的注释子集,主要是因为只有这部分注释对这些物种是可用的。因此,这些注释涉及来自 Ensembl 的7种主要基因元素,即蛋白质编码基因、5'UTR、3'UTR、内含子、外显子、剪接受体和供体位点。
开发团队: InstaDeep
模型来源
使用方法
在下一个版本发布之前,需要通过以下命令从源代码安装 transformers
库才能使用这些模型:
pip install --upgrade git+https://github.com/huggingface/transformers.git
这里提供了一个小代码片段,用于从虚拟DNA序列中获取logits和嵌入。
⚠️ 默认情况下,最大序列长度设置为训练时的30,000个核苷酸,或5001个token(包括CLS token)。然而,SegmentNT已被证明可以推广到50,000 bp的序列。如果您需要在30kbp到50kbp之间的序列上进行推理,请确保在配置中将 rescaling_factor
参数更改为 num_dna_tokens_inference / max_num_tokens_nt
,其中 num_dna_tokens_inference
是推理时的token数量(例如,对于40,008个碱基对的序列为6669),而 max_num_tokens_nt
是骨干nucleotide-transformer训练时的最大token数,即 2048
。
from transformers import AutoTokenizer, AutoModel
import torch
tokenizer = AutoTokenizer.from_pretrained("InstaDeepAI/segment_nt_multi_species", trust_remote_code=True)
model = AutoModel.from_pretrained("InstaDeepAI/segment_nt_multi_species", trust_remote_code=True)
max_length = 12 + 1
assert (max_length - 1) % 4 == 0, (
"DNA token的数量(不包括预置的CLS token)需要能被2的幂次方整除,即4。")
sequences = ["ATTCCGATTCCGATTCCG", "ATTTCTCTCTCTCTCTGAGATCGATCGATCGAT"]
tokens = tokenizer.batch_encode_plus(sequences, return_tensors="pt", padding="max_length", max_length = max_length)["input_ids"]
attention_mask = tokens != tokenizer.pad_token_id
outs = model(
tokens,
attention_mask=attention_mask,
output_hidden_states=True
)
logits = outs.logits.detach()
probabilities = torch.nn.functional.softmax(logits, dim=-1)
print(f"概率形状: {probabilities.shape}")
idx_intron = model.config.features.index("intron")
probabilities_intron = probabilities[:,:,idx_intron]
print(f"内含子概率形状: {probabilities_intron.shape}")
训练数据
segment-nt-multi-species 模型在人类、小鼠、鸡、果蝇、斑马鱼和线虫的基因组上进行了微调。对于每个物种,保留一部分染色体作为验证集用于训练监控和测试集用于最终评估。
训练过程
预处理
DNA序列使用Nucleotide Transformer分词器进行分词,该分词器将序列分词为6-mer token,如相关代码库的分词部分所述。该分词器的词汇量为4105。模型的输入形式如下:
<CLS> <ACGTGT> <ACGTGC> <ACGGAC> <GACTAG> <TCAGCA>
训练
模型在DGXH100节点上使用8个GPU进行了3天的微调,共处理了80亿个token。
架构
该模型由 nucleotide-transformer-v2-500m-multi-species 编码器组成,我们移除了其语言模型头部,并替换为一个1维U-Net分割头部[4],该头部由2个下采样卷积块和2个上采样卷积块组成。每个块由2个卷积层组成,分别具有1,024和2,048个核。这个额外的分割头部包含5300万个参数,使总参数数达到5.62亿。
BibTeX条目和引用信息
@article{de2024segmentnt,
title={SegmentNT: 以单核苷酸分辨率注释基因组:基于DNA基础模型的方法},
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}
}