gloop-dnabert2 / README.md
zapell's picture
Model card: link the web app Space
4542318 verified
|
Raw History Blame Contribute Delete
3.33 kB
---
base_model: zhihan1996/DNABERT-2-117M
pipeline_tag: text-classification
tags:
- biology
- genomics
- dna
- g-quadruplex
- r-loop
---
# gloop-dnabert2: candidate G-loop classifier
DNABERT-2 fine-tuned to score a 500 bp stretch of human DNA for how likely it is to be a
**candidate G-loop**, a region where a G-quadruplex (G4) and an R-loop are both detected.
A high score marks a candidate worth studying, not a confirmed G-loop.
BIOINF 535 (University of Michigan) group project by Zach Apell, Tony Bowei Wang and
Oscar Reyes Parker. The project also has a small web app (paste DNA, get a score per 500 bp
window) that loads this model: [zapell/gloop-predictor](https://huggingface.co/spaces/zapell/gloop-predictor).
## Training data
All hg38, K562 cells, chr1–22, 500 bp windows (ENCODE blacklist removed).
| Label | Windows | Source |
|---|---|---|
| 1: G4 + R-loop | 2,300 | overlaps both a replicated R-loop core and a G4 core |
| 0: G4 only | 2,300 | G4 core, no R-loop in any replicate; GC-matched to label 1 |
| 0: R-loop only | 271 | R-loop core, no G4 in any replicate |
| 0: neither | 2,300 | no G4 or R-loop; GC-matched to label 1 |
- **G4s:** BG4 ChIP peaks, GEO [GSE181373](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE181373).
- **R-loops:** R-ChIP (D210N) peaks from R-loopBase, cores shared by both replicates.
- **Splits by chromosome:** test chr1 + chr8, dev chr2 + chr9, train the rest.
## Results (test set: chr1 + chr8, 1,079 windows, 40% positive)
| Model | AUROC | AUPRC | MCC |
|---|---|---|---|
| this model | 0.865 | 0.782 | 0.494 |
| k-mer (k ≤ 4) + GC logistic regression | 0.814 | 0.701 | 0.375 |
AUROC for G-loops against each negative class: G4 only 0.789, R-loop only 0.772, neither 0.950.
## Limitations
- **Labels are peak overlaps.** A window labeled positive has G4 and R-loop peaks from separate
experiments; that does not prove both structures form on the same molecule at the same time.
- **One cell line.** Trained only on K562; other cell types are untested.
- **Balanced, GC-matched test set.** Real G-loops are rare in the genome, so a genome-wide scan
will have far lower precision than the numbers above suggest.
- **Mostly promoters.** 89% of G-loop windows are within 1 kb of a TSS (vs 68% of G4-only).
Within promoters, AUROC drops to 0.781.
- **500 bp windows.** Inputs of other lengths are outside what the model was trained on.
## Usage
Needs `torch==1.13.1` and `transformers==4.29.2`, without Triton installed. The DNABERT-2 model
code (`bert_layers.py` etc., upstream commit `7bce263b`) is included in this repo.
```python
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
repo = "zapell/gloop-dnabert2"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForSequenceClassification.from_pretrained(repo, trust_remote_code=True).eval()
seq = "ACGT..." # 500 bp, A/C/G/T only
with torch.no_grad():
x = tokenizer([seq], return_tensors="pt", truncation=True, max_length=128)
p_gloop = torch.softmax(model(**x).logits, dim=-1)[0, 1].item()
```
Training: full fine-tune with DNABERT-2's `finetune/train.py`, learning rate 3e-5, batch 32,
5 epochs, fp16, max length 128 tokens. The saved weights are the checkpoint with the lowest dev
loss (step 400 of 840).