EpiRefine
Refine metagenome bins with nanopore methylation. EpiRefine takes the bins from any binner and checks every contig against the methylation fingerprint of its bin. It removes contigs that don't belong (contamination) and puts unbinned contigs into the bin whose methylation they share. Every decision comes with a probability that is calibrated on pieces cut from the sample's own bins; very long contigs remain overconfident (see the FAQ).
Bacteria methylate short DNA motifs everywhere in the cell, on the chromosome and usually on its plasmids and phages as well, and nanopore reads record that methylation. The set of methylated motifs is therefore a signature of the genome a contig comes from. It is measured separately from the sequence composition and coverage that binners use, so it can catch errors they miss, but it is not fully independent of them: decisions need at least 5x coverage, and in bins without methylated motifs the remaining signal follows GC content.
Contents: Install · Quick start · What you get · Documentation · When to trust it · Citing
Install
pip install epirefine
Python 3.10 or newer; Linux and macOS. Check it works with epirefine --version. A Bioconda recipe follows the
PyPI release; until it is there, install with pip (also inside a conda environment).
The wheels for Linux (x86_64, aarch64; glibc 2.17 or newer, and musl on x86_64) and macOS (Apple silicon and Intel)
carry compiled kernels, which EpiRefine uses by default. On any other platform pip installs the pure-Python wheel
and EpiRefine runs its numpy code: the same decisions, more slowly. The log's third line says which code runs
(kernels: compiled (...) or kernels: numpy (<reason>)), a run on numpy without being asked says so in a
warning, and params.json records it under kernels. EPIREFINE_RS=0 forces the numpy code. pip never compiles
anything: the pure wheel fits every platform, so building from source happens only when asked for
(pip install --no-binary epirefine epirefine, which needs Rust and a C compiler). A separately installed
epirefine_rs (the unpublished kernel package of earlier development versions) is not used.
Quick start
You need four files for the sample:
| Input | What it is | Made with |
|---|---|---|
assembly.fasta |
the assembled contigs | any long-read assembler (e.g. myloasm or metaFlye) |
contig_bin.tsv |
which bin each binned contig is in: contig<TAB>bin, no header |
any binner |
pileup.bed |
reads called modified / unmodified at every position | modkit pileup |
bin-motifs.tsv |
the methylated motifs found in the bins | nanomotif motif_discovery (Nanomotif; the benchmarks of 0.12 used version 1.3.0) |
Then run:
epirefine run \
--assembly assembly.fasta \
--contig-bin contig_bin.tsv \
--pileup pileup.bed \
--motifs bin-motifs.tsv \
--out epirefine_out \
--workers 16
New to nanopore methylation? The getting-started guide walks through making the pileup and the motif file, running EpiRefine, and writing the refined bins as FASTA.
What you get
The refined binning is in epirefine_out/new_contig_bin.tsv (contig<TAB>bin): the bins without their
contaminants and with the included contigs added. Every contig's decision, with its probabilities, is in
contig_decisions.tsv:
| Status | Meaning |
|---|---|
kept |
binned, and its methylation fits its bin |
contaminant |
binned, but its methylation contradicts its bin: removed |
moved |
a contaminant that clearly belongs to another bin: moved there |
mixed |
a long contig that is partly its bin's and partly another genome's: kept, with a map of which stretch fits which bin |
included |
unbinned, and its methylation fits one bin: added to it |
unbinned |
unbinned, and no bin fits well enough: left out |
redundant |
unbinned; would be included, but its sequence is already in the bin |
low_coverage, too_short, no_methylation_evidence, sole_contig_of_bin |
not judged: too few reads, too short, no informative methylation, or nothing to compare it with |
bin_contamination.tsv, include_contigs.tsv and decontaminated_contig_bin.tsv list the flags, the inclusion
candidates and the bins without their contaminants in a fixed column format for downstream scripts. All files are
described in docs/outputs.md.
Documentation
| Guide | For |
|---|---|
| Getting started | a first run, step by step, from reads to refined bins |
| Options | every command-line option, its default and when to change it |
| Outputs | every output file and column |
| How it works | the model in plain terms, from read counts to decisions |
| FAQ and troubleshooting | common questions, runtime, memory, odd results |
| Changelog | what changed in each version |
When to trust it
- Most of its calls are right, though less often on new data than on the data it was developed on. On the six monoculture test and validation communities (spent: they were looked at during development, so they are no longer an unseen evaluation; version 0.10.1; 0.11.0 gives the same results), 311 of 316 flags (98.4%) were true contaminants and 1,096 of 1,180 placements (92.9%) went into the right bin: 98.4% in the test set, 89.6% in the validation set, where contigs of genomes without a bin were placed into bins with few methylated motifs. It found 311 of 363 planted contaminants (85.7%). With the same version, on the development benchmarks every flag and 99.8% of placements were right. With 0.12.0, on the six training communities (development) it found 94.8% of the contaminants with a flag precision of 100% and put back 89.6% of the removed contigs (benchmarks/results.tsv). No evaluation on data held out from development has been run yet; the manuscript will report it.
- It declines rather than guesses. Contigs below 5x coverage, shorter than 1 kb or without informative methylation get no call. On a complex fecal sample (a development sample, version 0.8.0) that was 76% of the contigs and 31% of the assembled sequence. If the calibration finds no usable temperature (it ends at the cap of its grid), the run makes no call at all and says so in the log.
- Results depend on the motif table, and on whether unbinned genomes share a bin's methylation (their contigs are then placed in that bin, and more short contigs get no call); see known limitations.
- Methylation cannot separate genomes that methylate the same motifs, such as very close strains. EpiRefine then keeps both bins in its credible set or leaves the contig where it is.
More in the FAQ.
Citing
A manuscript is in preparation. Until then, please cite this repository and the version you used
(epirefine --version); CITATION.cff holds the citation data (GitHub's "Cite this repository"). EpiRefine takes its motifs from Nanomotif
(motif discovery) and its read counts from modkit (the pileup).
Contributing
Bug reports and questions: GitHub issues. To work on the code:
git clone https://github.com/SorenHeidelbach/epirefine.git && cd epirefine
uv venv && uv pip install -e ".[dev]"
.venv/bin/pytest -q
The editable install compiles the kernels in rust/ and needs a Rust toolchain and a C compiler (with a conda
toolchain, set AR=gcc-ar). EPIREFINE_RS=0 runs the numpy code in such an install.
Development rules are in CLAUDE.md, the
benchmark used for every release in benchmarks/ (results per version in
benchmarks/results.tsv), and
notes on the statistical model and performance in
docs/development/.
Licence: MIT.
Metadata
Release files for epirefine 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| epirefine-0.12.0.tar.gz | 2.1 MB | With provenance | Details for epirefine-0.12.0.tar.gz |
Built distributions (wheels)
Total release size: 5.7 MB
Release files / epirefine-0.12.0.tar.gz
| Download URL | epirefine-0.12.0.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c4b3508bf4661ab7f1368dcefc505ca3df448a5214c744b7df24c7fa4bba029
|
|
BLAKE2b-256 checksum How to use checksums |
a6121206884cc3ffccf1cc6d7384cb3078c776e1f8608507770afcbf3d1204dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / epirefine-0.12.0-py3-none-any.whl
| Download URL | epirefine-0.12.0-py3-none-any.whl |
|---|---|
| Size | 165.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6ce88fd613aa43ed4f13a6d603bf30c325bdc4304bf8cfb8fe7c25ba1908ff4
|
|
BLAKE2b-256 checksum How to use checksums |
cd92763ec10b170c086ea110f68ab5ecea88e260abbce0e8884eba3ad20c8707
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / epirefine-0.12.0-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | epirefine-0.12.0-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 880.3 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2729734992b13711a15e223d789aa771ab4891e9c32cdd8921af106d0fa02477
|
|
BLAKE2b-256 checksum How to use checksums |
5a4fef83c894b0a1a1f8271871c132cfcab69d7df238c69a55a90863541d64ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / epirefine-0.12.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | epirefine-0.12.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 666.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
afe2dff37eec0b3cf1b614d727d16742acec5289ed1ee0dc4e47783d8907dd0e
|
|
BLAKE2b-256 checksum How to use checksums |
cd18d29097a7eb3708179a07584bf19c933a7880bc826b2e7719f052be7329ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / epirefine-0.12.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | epirefine-0.12.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 666.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ade0d452e356502633359edd55cee338c25fbd94c5d18a0743fed66218893f50
|
|
BLAKE2b-256 checksum How to use checksums |
7d087d6dbe1ab049fae81c63457df456dd1c83413a5f0b13e5bd4dff07e392f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / epirefine-0.12.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | epirefine-0.12.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 606.2 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
01074927d02f58a984278f44dd34037f677bc6e730e64d6b70eb18f11674cbee
|
|
BLAKE2b-256 checksum How to use checksums |
35c800fe2fc09281b422b1d0e69e9db3110180528ccbc73811aa00898d9961a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / epirefine-0.12.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | epirefine-0.12.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 632.4 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
efdbd9aecfe98421f4ccff68a4549edf7216fa8ee8d130028cc620e2faa38414
|
|
BLAKE2b-256 checksum How to use checksums |
15a9083cead205416cdb66a5f44927d06bb9e1bf5d3e30863af315be47d705a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for epirefine 0.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 7 files in this release have been uploaded with provenance metadata.
Attestation for epirefine-0.12.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.