Ahmed Doghri Logo Image
Ahmed Doghri

methyloadapt

Six target-species examples aren't enough to learn methylation from scratch. Transferring from related species looked like chance-to-100%, but that was one lucky seed. Reweighted properly, it never does worse than training alone across 90 seeds.

methyloadapt reproduced benchmark result

The Labels Run Out Before the Species Do

Methylation predictors have abundant data for a few organisms and scraps for everyone else. Training a fresh model per species throws away the sequence grammar they share.

methyloadapt builds two source species and a low-label target species with a shifted but related methylation motif. The baseline sees six target examples. The adapted model sees the shared species first.

Transfer the Motif, Not the Answer Sheet

The model learns transparent k-mer evidence. The source species contribute conserved CpG structure, and the small target set then reweights what's species-specific. There's no claim that a two-mer score replaces hierarchical attention. The point is to make domain-adaptive pretraining's advantage visible under controlled label scarcity.

The Number

On the published seed, target-only training stays at 50% accuracy and domain-adaptive training reaches 100% on 160 held-out sequences, a 50-point gain. The dataset is synthetic and non-diagnostic. The next section is why that seed shouldn't have been the headline.

The Published Gain Was a Lucky Seed

The adapted model trained on raw vote counts, so the source species' 360 examples numerically swamped the target's 24. Worse, the two source species share one positive motif while the target uses a different one, so the dominant signal often pointed the wrong way for the species that mattered.

Across 60 seeds, the median gain was 1.2 points, not 50, and five seeds came out worse than the target-only baseline, one by 16.9 points. A disjoint 30-seed holdout, evaluated once, agreed: median 3.75 points, one seed worse.

The fix normalizes source and target into separate vote profiles and combines them with an explicit domain weight, so the target can't be drowned out by volume. It never once does worse than target-only across all 90 seeds, with a median gain of 49.1 points on tuning and 46.6 on the holdout. The means, 33.0 and 32.4, are the more honest summary, because on some seeds adaptation simply adds nothing. The original module is untouched, so the published 50-point number still reproduces exactly. 9 tests pass on GitHub Actions across Python 3.9 through 3.13.

Research Basis

Inspired by the 2025 iDNA-DAPHA methylation study. Every number on this page comes from this repository's own controlled benchmark, not from the paper.

Try It

Standard library only:

git clone https://github.com/ahmeddoghri/methyloadapt && cd methyloadapt
python methyloadapt.py     # the published seed: 50% → 100%
python eval_v2.py          # 90 seeds: raw counts median +1.2, domain-weighted median +49.1

Tools Used

Python
DNA Methylation
Transfer Learning
K-mer Models
Domain Adaptation
Statistical Robustness
unittest