hapadapter-as-h3k27ac
HapAdapter adapter heads for allele-specific H3K27ac on diploid personal genomes, built on a DNABERT-2 encoder.
Each checkpoint predicts, for a heterozygous SNV, whether the two haplotypes show allelic imbalance in H3K27ac signal. Input is a pair of 257 bp personal-genome windows, one per haplotype, centered on the variant.
Repo Contents
ENC-001/dnabert2-personal/
ENC-001/dnabert2-trunk/
ENC-002/dnabert2-personal/
ENC-002/dnabert2-trunk/
ENC-003/dnabert2-personal/
ENC-003/dnabert2-trunk/
ENC-004/dnabert2-personal/
ENC-004/dnabert2-trunk/
<donor>/dnabert2-trunk/β the binding model: a DNABERT-2 encoder fine-tuned to regress H3K27ac signal from reference sequence. Also usable on its own as a binding predictor.<donor>/dnabert2-personal/β the adapter head trained on windows cut from that donor's own phased genome. It resolves its backbone fromdnabert2-trunk/.
Donors: ENC-001, ENC-002, ENC-003, ENC-004. Arms: personal, trunk.
Loading
This is not an AutoModel. The adapter head is a siamese network that requires two
pooled haplotype embeddings, so loading goes through the hapadapter package:
from huggingface_hub import snapshot_download
from hapadapter.loading import load_model_and_tokenizer
# BOTH subfolders: the head needs the trunk to load
local = snapshot_download("hapadapter-as-h3k27ac", allow_patterns="ENC-001/dnabert2-*/*")
model, tokenizer, run_config = load_model_and_tokenizer(
f"{local}/ENC-001/dnabert2-personal")
model.eval()
Potential warnings (and which to ignore)
transformers prints two warnings while the architecture is being built, before this
repo's weights are applied on top:
Some weights of the model checkpoint at zhihan1996/DNABERT-2-117M were not used ... ['cls.predictions...']
Some weights of BertModel were not initialized ... ['bert.pooler.dense.weight', ...]
You should probably TRAIN this model on a down-stream task ...
Both are expected. The first drops the masked-language-model head, which this model does
not use. The second reports a randomly initialised pooler, which is then overwritten by
this repo's encoder weights and does not reach the readout in any case -- the model pools
token embeddings around the variant rather than using BERT's pooler output. The final
"you should probably TRAIN this model" line is transformers not knowing that training
already happened, so don't worry about that!
The readout
The twin head computes ell = softplus(a) * ||P(h_1) - P(h_2)|| + b, where P is the projected
embedding of each pooled haplotype window (h_1 and h_2).
That distance is symmetric, so the score cannot say WHICH haplotype binds more. It is a magnitude: higher means more likely to be allele-specific.
Reported performance
See the paper; per-assay numbers are not duplicated here.
Intended use and limits
- Trained on one assay and one donor per checkpoint, but measured to generalize well across other EN-TEx donors.
- 257 bp windows only. Longer or shorter input is out of distribution.
- Research use. Not validated for clinical or diagnostic interpretation of human variants.
Citation
Paper in preparation. Please check this repo for an updated reference before citing.