M6AFormer
Deep learning toolkit for transcriptome-wide N6-methyladenosine (m6A) site prediction, built on a hybrid CNN + lightweight Transformer architecture.
Highlights
- One model, multiple variants. Four pretrained checkpoints covering both 201 bp and 801 bp windows, with random and DRACH-filtered negative sampling strategies.
- Three ways to use it. A clean Python API, a
m6aformerCLI, and an optional local web UI, all driven by the same coreM6AFormerclass. - Frozen, audited thresholds. Each checkpoint ships with a decision threshold selected on inner-validation F1 (overridable at predict time).
- Reproducible. MIT licensed, fully open-source; bundled weights are shipped inside the wheel.
Pretrained models
| Name | Architecture | Window | Negatives | Default |
|---|---|---|---|---|
all_801 |
CNN + Transformer | 801 bp | random | yes |
all_201 |
CNN + Transformer | 201 bp | random | |
drach_801 |
CNN + Transformer | 801 bp | DRACH | |
drach_201 |
CNN + Transformer | 201 bp | DRACH |
Each model ships with a frozen decision threshold selected on inner-validation
F1, recorded in its threshold.json. Users can override the threshold at
prediction time.
Installation
# Basic (CPU/GPU inference + CLI)
pip install m6aformer
# With local web UI
pip install "m6aformer[web]"
# Development install (from a clone)
git clone https://github.com/zhixinniu/M6AFormer.git
cd M6AFormer
pip install -e ".[dev,web]"
PyTorch is intentionally pinned only as
torch>=2.0. Install the CUDA-matching wheel from https://pytorch.org/get-started/locally/ first if you want GPU support.
Quickstart
Python
from m6aformer import M6AFormer
model = M6AFormer.from_pretrained("all_801") # default checkpoint
df = model.predict_fasta("genome.fa", motif="DRACH") # scan all DRACH As
# df columns: chrom, position, strand, motif_5mer, prob, label, ...
CLI
# List all bundled pretrained checkpoints
m6aformer list-models
# Score a FASTA file (auto-finds candidate adenosines)
m6aformer predict --input genome.fa --output sites.tsv --model all_801
# Score one or more inline sequences (no file needed)
m6aformer predict --seq ACGT...A...ACGT --strand + --model all_801
Local web UI
The [web] extra installs FastAPI + uvicorn and registers the serve
subcommand. The bundled single-page UI exposes the same prediction
pipeline as the CLI.
pip install "m6aformer[web]"
m6aformer serve # http://127.0.0.1:8000
For remote use over SSH (recommended over --host 0.0.0.0):
# On your laptop, forward the port and keep the server bound to localhost:
ssh -L 8000:localhost:8000 user@server
# Then open http://localhost:8000 in your browser.
Repository layout
M6AFormer/
├── src/m6aformer/ # the pip package (only this ships in the wheel)
├── training/ # training scripts (GitHub only, import m6aformer)
├── data_prep/ # dataset preparation scripts (GitHub only)
├── examples/ # runnable usage examples
├── tests/ # unit + integration tests
├── docs/ # documentation source
See training/README.md for how to retrain from
scratch, and data_prep/README.md for the dataset
construction pipeline.
Citation
If you use M6AFormer in your research, please cite the project. A
machine-readable citation is provided in CITATION.cff.
License
MIT © 2026 Zhixin Niu.
Metadata
Release files for m6aformer 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| m6aformer-0.1.2.tar.gz | 10.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| m6aformer-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.6 MB
Release files / m6aformer-0.1.2.tar.gz
| Download URL | m6aformer-0.1.2.tar.gz |
|---|---|
| Size | 10.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d886315e75edfed5beeaff9c87916accdf63fc2a348c9bed34664609391cf82
|
|
BLAKE2b-256 checksum How to use checksums |
08dc3c5746fee0c5e931636a79df71cb03843cb2e8780a8bbdc5a65535cfaf3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / m6aformer-0.1.2-py3-none-any.whl
| Download URL | m6aformer-0.1.2-py3-none-any.whl |
|---|---|
| Size | 10.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b1fe8ad8dd5aa8796459595b044b725163b84a2dae86f118fa9bcb09eeba297
|
|
BLAKE2b-256 checksum How to use checksums |
379b64ec276735fd88af149732e6f64bb14f9574cfa40202243debe9efa4ea13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|