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 that is 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, 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

or with conda (Bioconda):

conda install -c conda-forge -c bioconda epirefine

Python 3.10 or newer; Linux and macOS. Check it works with epirefine --version.

Quick start

You need four files for the sample:

Input What it is Made with
assembly.fasta the assembled contigs any assembler (e.g. 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

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

The files bin_contamination.tsv, include_contigs.tsv and decontaminated_contig_bin.tsv have the same format as Nanomotif's, so pipelines built for Nanomotif's refinement can use EpiRefine's output directly. 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 six held-out monoculture communities, built from isolates not used during development (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%). On the development benchmarks every flag and 99.8% of placements were right, and on the six training communities it found 94.8% of the contaminants (benchmarks/results.tsv).
  • It declines rather than guesses. Contigs below 5x coverage, shorter than 1 kb or without informative methylation get no decision. On a complex fecal sample (a development sample) that was 76% of the contigs and 31% of the assembled sequence.
  • Results depend on the motif table. With some motif tables EpiRefine includes nothing at all; see known limitations for how to recognise it in the log.
  • 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). EpiRefine builds on Nanomotif for motif discovery and on modkit for 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

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

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.11.1
File Size Uploaded Provenance Actions
epirefine-0.11.1.tar.gz 347.6 kB With provenance Details for epirefine-0.11.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for epirefine 0.11.1
File Interpreter ABI Platform Actions
epirefine-0.11.1-py3-none-any.whl Python 3 none any Details for epirefine-0.11.1-py3-none-any.whl

Total release size: 475.9 kB

Release files / epirefine-0.11.1.tar.gz

Download URL epirefine-0.11.1.tar.gz
Size 347.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c557460239fefb9198e4e2dd5ac3e7b78b577c28c46a7e1361e0e7efa6b4d7ce
BLAKE2b-256 checksum
How to use checksums
80a2a320eae6a8e75a20b8d7218c7ddcadf380335b976b88a7f1b701bc572e6a
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 13, 2026.

Transparency log

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

Download URL epirefine-0.11.1-py3-none-any.whl
Size 128.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b49b3053146624cd2d5bd46535c095d8a0835183f29c30fc08c84053a1e55ac
BLAKE2b-256 checksum
How to use checksums
5c674176ab07901fde53c0dd03571ec7e3ec19d47c9a8bbe2f0d68e456aacfcc
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 13, 2026.

Transparency log

Security for epirefine 0.11.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for epirefine-0.11.1.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 13, 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