dna-craft / README.md
BockLab's picture
Add files using upload-large-folder tool
fb9a0d9 verified
|
Raw History Blame Contribute Delete
7.04 kB
---
license: cc-by-nc-4.0
library_name: pytorch
tags:
- biology
- genomics
- dna
- regulatory-dna
- diffusion
- discrete-diffusion
- sequence-design
datasets:
- BockLab/dna-craft-data
---
# DNA-CRAFT
Model checkpoints for [*Designing Cell-Type-Specific Regulatory DNA with Guided Discrete Diffusion*](https://arxiv.org/abs/2604.20488) (Awasthi et al., 2026). This repository contains the regulatory-class-conditioned discrete diffusion model and sequence-to-activity models for the cell-line (Gosai) and immune-cell (CATlas) benchmarks.
Code & reproduction: [epigen/dna-craft](https://github.com/epigen/dna-craft)
Datasets: [BockLab/dna-craft-data](https://huggingface.co/datasets/BockLab/dna-craft-data)
NeurIPS 2026 poster: [Project page](https://neurips.cc/virtual/2026/loc/sydney/poster/155302)
## Architecture
| Component | Architecture | Role |
| --- | --- | --- |
| Diffusion model | DiMamba, a bidirectional Mamba backbone with 10 blocks and hidden dimension 128 | Generate DNA conditioned on regulatory class |
| Design oracle | Fine-tuned Enformer | Guide search using predicted activity |
| Evaluation oracle | Separately fine-tuned Enformer | Score generated sequences |
| Additional evaluation oracles | Fine-tuned Borzoi and AlphaGenome | Assess designs across predictive architectures |
The diffusion model uses a cosine noise schedule and classifier-free guidance. Its conditioning labels are CTCF (0), enhancers (1), open chromatin (2), poised elements (3), and promoters (4). Cell-type specificity is driven by the selected activity oracle and search objective.
## Training data
- **ENCODE (diffusion model):** around 3.2M human and mouse candidate cis-regulatory elements (max length 350 bp) with regulatory-class labels and train/valid/test splits.
- **Gosai MPRA (cell-line oracles):** Activity measurements for HepG2, K562, and SK-N-SH (in that column order), split into separate design and eval subsets.
- **CATlas (accessibility oracles):** Chromatin accessibility across 204 cell types (preserving the training table's column order), split into design and eval subsets. The immune-cell benchmark evaluates designs across 8 immune cell types.
See the dataset card for file schemas, splits, and original source citations.
## Checkpoints
Diffusion model:
```text
trained_models/2M_cosine_dimamba_lr0.001_bs4096_cfgTrue_type_combined_class/checkpoints/best.ckpt
```
Oracle checkpoints follow `oracles/checkpoints/<architecture>/<dataset>/<split>/`.
| Architecture | Dataset | Split | Filename |
| --- | --- | --- | --- |
| Enformer | Gosai | `design` | `epoch=7-step=2872.ckpt` |
| Enformer | Gosai | `eval` | `epoch=8-step=3231.ckpt` |
| Enformer | Gosai | `full` | `epoch=14-step=9705.ckpt` |
| Enformer | CATlas | `design` | `epoch=6-step=3836.ckpt` |
| Enformer | CATlas | `eval` | `epoch=7-step=4384.ckpt` |
| Borzoi | Gosai | `eval` | `epoch=3-step=720.ckpt` |
| Borzoi | CATlas | `eval` | `epoch=1-step=548.ckpt` |
| AlphaGenome | Gosai | `eval` | `best.pt` |
| AlphaGenome | CATlas | `eval` | `best.pt` |
## Usage
Clone the code repository and install its `dna-craft` environment using the GitHub README. Run the following example from the checkout root on a CUDA-capable machine. It downloads the diffusion checkpoint, loads the model, and generates eight 200-base enhancer-class sequences.
```python
import torch
from huggingface_hub import hf_hub_download
from config_utils import compose_benchmark_config
from dataloader_encode_CFG import batch_dna_detokenize
from diffusion_encode_update_CFG import Diffusion
checkpoint_path = hf_hub_download(
repo_id="BockLab/dna-craft",
filename=(
"trained_models/2M_cosine_dimamba_lr0.001_bs4096_cfgTrue_type_combined_class/"
"checkpoints/best.ckpt"
),
)
cfg = compose_benchmark_config(overrides=[
"guidance.condition=1",
"guidance.gamma=1.0",
"model.length=200",
"sampling.sequence_length=200",
"sampling.steps=32",
])
cfg.eval.checkpoint_path = checkpoint_path
model = Diffusion(cfg, eval=False).cuda()
checkpoint = torch.load(checkpoint_path, map_location="cpu", weights_only=False)
model.load_state_dict(checkpoint["state_dict"], strict=True)
model.eval()
torch.manual_seed(42)
with torch.no_grad():
tokens = model._sample(
num_steps=32,
eval_sp_size=8,
cond=1,
gamma=1.0,
sequence_length=200,
)
sequences = batch_dna_detokenize(tokens.cpu().numpy())
print(sequences[0])
```
For oracle-guided design, download the oracle checkpoints into the checkout's expected directory structure.
```python
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="BockLab/dna-craft",
local_dir=".",
allow_patterns=["oracles/checkpoints/**"],
)
```
Enformer and Borzoi checkpoints load through gReLU's `LightningModel.load_from_checkpoint`. AlphaGenome uses the loader in `benchmark_common.py`. The GitHub README includes a complete cell-line-specific DNA-CRAFT search example and workflow configuration instructions. [Model usage and benchmarks](https://github.com/epigen/dna-craft).
## Additional dependencies
- **AlphaGenome trunk:** Evaluation requires the upstream fold-0 weights (model_fold_0.safetensors), downloaded to oracles/architectures/pretrained_weights/ via:
```bash
python oracles/architectures/pretrained_weights/download_alphagenome_weights.py
```
- **Other evaluation resources:** Embedding metrics load Nucleotide Transformer v2, and extracting CATlas natural reference sequences uses hg38 via gReLU/genomepy. Local path configuration is documented in the [GitHub README](https://github.com/epigen/dna-craft).
## Benchmarks
Both Snakemake workflows evaluate designs on predicted specificity, motif/sequence-composition agreement, diversity, and cross-oracle agreement (Enformer, Borzoi, AlphaGenome):
| Workflow | Targets |
| --- | --- |
| `workflows/cell_line_enhancer_benchmark/` | HepG2, K562, SK-N-SH |
| `workflows/immune_cell_type_benchmark/` | CD8 T cells, CD4 T cells, NK T cells, Naive T cells, Memory B cells, Plasma B cells, Macrophages, Mast cells |
Configure local checkpoint and resource paths before running Snakemake. External baselines require their own environments and checkpoints (see the [GitHub repo](https://github.com/epigen/dna-craft)).
## License
DNA-CRAFT weights are licensed under CC BY-NC 4.0. Upstream models (Enformer, Borzoi, AlphaGenome, Nucleotide Transformer v2) and source datasets remain subject to their respective licenses.
## Citation
If you use these checkpoints, please cite:
```bibtex
@misc{awasthi2026dnacraft,
title = {Designing Cell-Type-Specific Regulatory DNA with Guided Discrete Diffusion},
author = {Awasthi, Animesh and Stoll, Martin and Bednarsky, Raphael and Schaefer, Moritz and Bock, Christoph},
year = {2026},
eprint = {2604.20488},
archivePrefix = {arXiv},
primaryClass = {q-bio.GN},
doi = {10.48550/arXiv.2604.20488},
url = {https://arxiv.org/abs/2604.20488}
}
```