DeltaSplice — 由5个膨胀一维卷积神经网络组成的集成模型,用于RNA剪接位点预测
纯PyTorch重新实现 · 已适配昇腾NPU
DeltaSplice是一种深度学习模型,用于从基因组DNA序列中预测RNA剪接位点(受体/供体位点及其使用情况)。该模型由5个相互独立的膨胀一维卷积神经网络集成而成;预测结果在各成员之间取平均值,以提升稳健性。
原始模型:multimolecule/deltasplice
适配说明:原始multimolecule库(v0.2.x)依赖于transformers.initialization和merge_with_config_defaults,这两个模块在transformers 4.57.6中已被移除。本仓库提供了一种纯PyTorch重新实现,精确复现了原始架构,并可直接加载原始权重。
Input: DNA sequence (one-hot, [B, 4, 30000])
│
▼
┌──────────┐
│ Encoder │ 24 × ResidualBlock(Conv1d, k=3, d=1, BN, ReLU, Dropout)
└──────────┘ hidden_size = 64
│ output: [B, 64, L]
▼
┌──────────────────┐
│ Reference Proj │ Linear(130 → 256) → ReLU → Linear(256 → 64)
└──────────────────┘ reference: [B, 64]
│
├───────── + ─────────┐
│ │
▼ ▼
[B, 64, L] ◄─────────────┘ (encoder + reference broadcast)
│
▼
┌──────────────────┐
│ Prediction Heads │ 3 tasks × (Linear(64→256) → ReLU → Linear(256→256) → ReLU → Linear(256→3))
└──────────────────┘ output: [B, L, 3] per task
│
▼
Ensemble average (5 members)| 输出 | 形状 | 描述 |
|---|---|---|
site_prediction | [B, L, 3] | 剪接位点分类 |
usage_prediction | [B, L, 3] | 剪接位点使用率 |
delta_prediction | [B, L, 3] | Delta 分数预测 |
| 项目 | 数值 |
|---|---|
| 隐藏层大小 | 64 |
| 卷积核 | 3 |
| 膨胀率 | 1 |
| 丢弃率 | 0.3 |
| 集成成员数 | 5 |
| 每个成员的编码器层数 | 24 |
| 上下文长度 | 30,000 bp |
| 总参数量 | 40,375,725 |
torch >= 2.0
safetensors >= 0.4.0pip install torch>=2.0 safetensors>=0.4.0python3 inference.py --model-path weights --sequence "ACGTACGT..."python3 inference.py --model-path weights --sequence-file input.txtfrom inference import encode_sequence, DeltaSpliceEnsemble
import torch
model = DeltaSpliceEnsemble(config)
model.load_weights("weights/model.safetensors")
model.eval()
seq = encode_sequence("ACGT" * 7500) # 30000bp
ref = torch.zeros(1, 130)
with torch.no_grad():
out = model(seq, ref)
site = out["site_prediction"] # [1, 30000, 3]
usage = out["usage_prediction"] # [1, 30000, 3]
delta = out["delta_prediction"] # [1, 30000, 3]已在搭载 CANN 8.5.1 的昇腾 NPU 上完成测试。当检测到可用 NPU 时将自动启用:
device = torch.device("npu:0" if torch.npu.is_available() else "cpu")
torch.npu.set_device(0)性能:在NPU上处理30,000bp约需0.5秒。
详见 license.md。