Skip to main content

EpiRefine

tests PyPI Python License: MIT

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, calibrated on pieces cut from the sample's own bins. Very long contigs remain overconfident (see the FAQ).

What EpiRefine does to a bin

Bacteria methylate short DNA motifs everywhere in the cell: on the chromosome and usually on its plasmids and phages as well. 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. It is not fully independent of them: calls need at least 10x coverage and 5 kb, 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.

EpiRefine is also on Bioconda:

conda install -c conda-forge -c bioconda epirefine

Bioconda can lag behind PyPI by a version. epirefine --version shows which version you have; for the newest release, 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, because the pure wheel fits every platform. 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; its bin cannot be told from a genome without a bin (or too few sites), which is not a sign of contamination; or nothing to compare it with. A binned contig with one of these stays in its bin

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, 311 of 316 flags (98.4%) were true contaminants and 1,096 of 1,180 placements (92.9%) went into the right bin. Of the placements, 98.4% were right in the test set and 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%). These communities are 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). 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 makes no call rather than guess. Contigs below 10x coverage or shorter than 5 kb get no call (the defaults since 0.13; 5x and 1 kb before). Neither do contigs that would stay where they are when their bin cannot be told from a genome without a bin, or when they have too few sites (no_methylation_evidence, which is not a sign of contamination). On a complex fecal sample (a development sample) the 10x and 5 kb limits leave 13% of the contigs and 48% of the assembled sequence to be judged. 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. They also depend on whether genomes without a bin 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 is in benchmarks/, with results per version in benchmarks/results.tsv. Notes on the statistical model and performance are in docs/development/.

Licence: MIT.

Metadata

Release files for epirefine 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for epirefine 0.13.0
File Size Uploaded Provenance Actions
epirefine-0.13.0.tar.gz 2.2 MB With provenance Details for epirefine-0.13.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for epirefine 0.13.0
File Actions
epirefine-0.13.0-py3-none-any.whl Python 3 none any Details for epirefine-0.13.0-py3-none-any.whl
epirefine-0.13.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for epirefine-0.13.0-cp310-abi3-musllinux_1_2_x86_64.whl
epirefine-0.13.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for epirefine-0.13.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
epirefine-0.13.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for epirefine-0.13.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
epirefine-0.13.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for epirefine-0.13.0-cp310-abi3-macosx_11_0_arm64.whl
epirefine-0.13.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for epirefine-0.13.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 6.0 MB

Release files / epirefine-0.13.0.tar.gz

Download URL epirefine-0.13.0.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
0f5ff35edd77958b7a01fe48dda0674e0d11fd0ace3f1cbf8ff9e234c0b8644f
BLAKE2b-256 checksum
How to use checksums
56b5c5069266c8ff8f9b791bde2a554dab3aa8be6ffe09871e5fcc4645e6b333
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 30, 2026.

Transparency log

Release files / epirefine-0.13.0-py3-none-any.whl

Download URL epirefine-0.13.0-py3-none-any.whl
Size 188.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15b6a37a1de43efe26c8334c519e8f034d4a8305fe763823ee5bb29f78318c56
BLAKE2b-256 checksum
How to use checksums
32228a1dab34e9b697a225954fe68790006005b6b952e3d2905f697b3b7e81fd
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 30, 2026.

Transparency log

Release files / epirefine-0.13.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL epirefine-0.13.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 912.7 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
992dae57ef5d842ad1036847d8cbe6ea231d339eb73bb6d9e40aba099168448b
BLAKE2b-256 checksum
How to use checksums
b3b0c218f04c9ef01d6092f5cb791a261be38f016553612313b64e65ff93636a
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 30, 2026.

Transparency log

Release files / epirefine-0.13.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL epirefine-0.13.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 699.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
6f01255d7b7e49f3b40018e17dad1561b7d7e1a90e8afce44778f3eb4f3098c5
BLAKE2b-256 checksum
How to use checksums
04d7d395d005fea0aaded1e433b9980b1c5c6ae12e9dbb1bbcb14ccd31508801
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 30, 2026.

Transparency log

Release files / epirefine-0.13.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL epirefine-0.13.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 698.0 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
f74c6ae85e13d66c11ae59202d3f34fd8f162bbeccab7388f5c6b1da25bb5d4d
BLAKE2b-256 checksum
How to use checksums
11ae2ef6e2414185f7052b56aff9d256346bad1f45858206d203e9fa3d0f6645
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 30, 2026.

Transparency log

Release files / epirefine-0.13.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL epirefine-0.13.0-cp310-abi3-macosx_11_0_arm64.whl
Size 635.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
21503374df429728df52791de40582d86d0ce053ebcd18b2c25889332316220a
BLAKE2b-256 checksum
How to use checksums
1453ed0b15d94f9447cea03fc2a4135741902fb291d81fd92294aac77da60efc
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 30, 2026.

Transparency log

Release files / epirefine-0.13.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL epirefine-0.13.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 666.3 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
110d85cafb44ac40cc5cb3cb0185fdfd8c95741defa1e007f7026f0b7f69f84c
BLAKE2b-256 checksum
How to use checksums
f7bb9062e27c79da8d21e03a77770c10b9df602393dfdecf29b623f424985105
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 30, 2026.

Transparency log

Security for epirefine 0.13.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.

Select from 7 files

Attestation for epirefine-0.13.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 30, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page