PlantDNA-FM
PlantDNA-FM is a plant DNA foundation model with a context length of 16 kb at single-nucleotide resolution, pre-trained with masked nucleotide modelling on genomes of 260 plant species. In the accompanying paper, attention from PlantDNA-FM is used as a prior that ranks variants within each gene for expression GWAS (expGWAS) detection and fine-mapping in Arabidopsis thaliana and maize. The attention is read out with a single forward pass per window, which needs 30- to 118-fold less GPU time than in silico mutagenesis at the same context length.
Code for attention extraction, prior construction and fine-mapping: https://github.com/atlasbioinfo/PlantDNA-Finemapping
Model
| Architecture | bidirectional Transformer encoder (EsmForMaskedLM) |
| Layers × heads | 36 × 12 (head dimension 64) |
| Hidden / feed-forward dimension | 768 / 3,072 (GELU) |
| Positional encoding | rotary (RoPE, θ = 10,000) |
| Maximum input | 16,386 tokens (16,384 nucleotides + <cls> and <eos>) |
| Parameters | 255,765,179 |
| Tokenisation | single nucleotide; vocabulary <cls> <pad> <eos> <unk> A T C G N <mask> |
| Dropout | none; input and output embeddings are tied |
Pre-training
- Corpus: annotated genes with at least one exon-containing transcript, plus 10 kb of flanking sequence on each side, from genome assemblies of 260 plant species: 116 genomes from Ensembl Plants release 60, 9 further genomes from Ensembl Plants release 63 and 135 species from NCBI RefSeq (one representative assembly per species; cultivar-level duplicates of species already in Ensembl Plants excluded; full list in Supplementary Table 1 of the paper). Windows were written in the direction of transcription; windows with > 10% N and duplicate windows (within and across assemblies) were removed; 5% of windows were held out.
- Objective: masked nucleotide modelling: 15% of positions (A/C/G/T only) selected per sequence, 80% replaced by
<mask>, 10% by a random nucleotide and 10% left unchanged; cross-entropy on the selected positions; masks resampled at every step. - Training: two stages with increasing window length, the final stage on 16,384-nt windows; AdamW (β₁ = 0.9, β₂ = 0.98, ε = 10⁻⁶, weight decay 0.01), linear warm-up and cosine decay, gradient clipping at 1.0, bfloat16 mixed precision.
Usage
from transformers import AutoModelForMaskedLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("ATLASBIOINFO/PlantDNA-FM")
model = AutoModelForMaskedLM.from_pretrained("ATLASBIOINFO/PlantDNA-FM")
seq = "ATGGCGGCTTCAGATCCATTGAAGCTTAGCTAG" # upper case
inputs = tok(seq, return_tensors="pt") # <cls> + one token per nucleotide + <eos>
out = model(**inputs)
- Use upper-case sequence. Lower-case (soft-masked) bases are not in the vocabulary and are tokenised as
<unk>without an error; convert withseq.upper(). Other IUPAC codes should be replaced byN. - Inputs up to 16,384 nt; the attention prior of the paper uses 16,000-nt windows tiling the gene body ± 10 kb (step 8,000 nt), read in the direction of transcription; attention from exon positions is averaged over all 36 layers × 12 heads.
- Tested with PyTorch 2.10 and transformers 5.9. Load in float32 for attention extraction; a 16-kb window needs about 12 GB of GPU memory.
- To compute the attention prior for your own genes, use the
attentioncommand of the PlantDNA-Finemapping package rather than reimplementing the readout.
Citation
Yu H., Korte A., Menon G., Sun W., Dean C., Nordborg M., Zhang H. & Ding Y. Plant DNA foundation model prioritises functional variants for fine-mapping (submitted).
License
MIT.