EpiRefine
Epigenetics + refine: it refines metagenome bins using the methylation every genome carries. Formerly pbinner.
Bin refinement from nanopore methylation, built on Nanomotif output:
- contamination detection: flags binned contigs whose methylation doesn't fit their bin;
- contig inclusion: places unbinned contigs into the bin they belong to.
Every decision comes with a calibrated posterior, including an explicit "unbinned genome" class, so
contigs of genomes that have no bin stay out of bins. Outputs include Nanomotif-compatible files
(bin_contamination.tsv, include_contigs.tsv, new_contig_bin.tsv,
decontaminated_contig_bin.tsv). Calibration is estimated inside each sample from pseudo-contigs
cut from binned contigs.
- Method: docs/method.md.
- Performance work: docs/scalability.md.
- Changes per version: CHANGELOG.md.
- Development rules: CLAUDE.md.
Repository layout
| Folder | Content |
|---|---|
src/epirefine/ |
The package: methylation-based contamination detection and contig inclusion, nothing else |
tests/ |
Unit tests (.venv/bin/python -m pytest -q tests) |
benchmarks/ |
Monoculture benchmark: suite runner, the scripts that build the sets, the evaluator; results of every version in benchmarks/results.tsv |
dev/ |
Development tooling: git hooks, speed prototypes |
docs/ |
Method and performance notes |
Install
pip install epirefine # from PyPI
conda install -c bioconda epirefine # from Bioconda (once the recipe is accepted)
From source, for development:
git clone https://github.com/SorenHeidelbach/epirefine.git && cd epirefine
uv venv && uv pip install -e ".[dev]"
.venv/bin/pytest -q
Python 3.10-3.15 (tested on every push, together with the lowest dependency versions allowed: numpy 1.26, scipy 1.11, polars 1.2).
Running EpiRefine
| Flag | File | Notes |
|---|---|---|
--assembly |
assembly FASTA | |
--pileup |
modkit pileup bedMethyl (.bed/.bed.gz) |
Space-separated (older modkit) or all-tab formats. Only rows at motif sites are kept while streaming. |
--contig-bin |
contig<TAB>bin, no header |
The bins to refine |
--motifs |
Nanomotif bin-motifs.tsv |
Only the union of motifs is used (+ motif_complement). Which bin carries which motif is re-estimated from the data. |
epirefine run --assembly asm.fasta --pileup pileup.bed --contig-bin contig_bin.tsv \
--motifs nanomotif/bin-motifs.tsv --out epirefine_out --workers 16
Decision thresholds:
--contamination-threshold(0.5): flag a binned contig when P(foreign) is at least this,--min-methylome-difference(0.3): ... and its 95% credible interval for some motif group's methylated fraction lies at least this far from its bin's level (an effect size, so that many weak site-level differences don't add up to a flag);--include-threshold(0.95): include an unbinned contig when one bin's posterior is at least this;--max-redundancy(0.3): don't include a contig when this share of its k-mers is already in the bin (assembly duplicates; statusredundant).
Model options: --variation beta|logit (how a contig's methylation varies around its bin's;
--tau overrides the calibrated value), --temperature, --allow-sharpening (default: the
temperature is clipped at ≥ 1), --p-unknown, --contam-eps, --chunk-size.
--regional-inclusion (experimental, off by default) also includes long unbinned contigs whose
50 kb windows match a bin when the whole contig doesn't.
Running:
--workers Nsets the processes for the pileup and table passes (default: CPUs, at most 16).--cache-dirholds the site cache (default<out>/cache). A rerun with the same assembly, pileup and motifs reuses it and skips the pileup pass.--frag-budget(default 6000) is the total number of calibration fragments, spread over bins and lengths with at most--frags-per-bineach.--motif-fitalso writes each contig's methylated fraction per motif group next to its bin's.
The pileup must have each contig's rows together (as modkit writes it). Uncompressed pileups are read in parallel byte ranges; gzipped ones by a single worker.
Outputs
| File | Content |
|---|---|
contig_decisions.tsv |
Per contig: status, given and new bin, p_contaminant, methylome_difference, redundancy_with_bin, best alternative bin and its posterior, MAP, p_unknown, 95% credible set |
bin_contamination.tsv, include_contigs.tsv, new_contig_bin.tsv, decontaminated_contig_bin.tsv |
Nanomotif-compatible results |
host_profiles.tsv |
Per bin × motif group: methylated fraction (posterior mean, 95% interval) |
host_chunk_outliers.tsv |
P(chunk is foreign to its bin) for every 50 kb chunk of a binned contig |
detection_model.tsv |
Learned caller behaviour per motif group (μ0, μ1, κ0, κ1) |
motif_groups.tsv |
Which motifs were merged into which feature, with site and read counts |
motif_fit.tsv |
With --motif-fit: per contig × motif group, observed methylated fraction (95% CI) and the bin's |
calibration/ |
Pseudo-contig calibration: accuracy, ECE, credible-set coverage per length, temperature and τ fits |
params.json |
Fitted parameters and settings |
Status in contig_decisions.tsv:
| Status | Meaning |
|---|---|
kept |
Binned contig that fits its bin |
contaminant |
Binned contig flagged as foreign; removed from its bin |
moved |
Flagged contaminant that confidently belongs to another bin; moved there |
sole_contig_of_bin |
Only contig of its bin: no leave-one-out profile, not judged |
included |
Unbinned contig placed into a bin |
redundant |
Would be included, but its sequence is already in the bin |
unbinned |
Unbinned contig left out (uncertain, or its genome has no bin) |
Workflow and evaluation
The Snakemake workflow (Nanomotif, EpiRefine, CheckM2), the Hi-C validation and the benchmarks beyond the
monocultures (ZymoOral pieces, simulated look-alikes, chimeras) live in a separate repository that calls this
tool (epirefine_workflow; moved out in 0.9.1).
Benchmarks
benchmarks/benchmark_suite.py --note "<change>" runs the monoculture benchmark (benchmarks/suite_monocultures.json):
communities built from isolates sequenced alone, so the origin of every contig is known, with planted errors
(contaminants, removed members, genomes without a bin). By default it runs the six training communities
(about 5 minutes); --all adds the held-out test and validation communities, for final evaluation only. Every
run appends one row per benchmark group and version to benchmarks/results.tsv:
contaminants found, flag precision, contigs put back, contigs of bin-less genomes placed, bin completeness and
contamination after refinement, wall time and peak memory. benchmarks/monoculture_sets.py rebuilds the sets.
Known limitations
- One bin per contig. A contig assembled across two genomes is not split.
- Robust profiles assume a contaminant looks like a "random community genome". A bin that is a 50/50 merge of two genomes is not resolved.
- Motif groups are treated as independent. A site matched by several groups counts in the most specific one, so one methyltransferase can show up in several partly methylated groups and count more than once.
- No coverage, co-abundance or taxonomy evidence: methylation only.
- Dropped constant: the binomial coefficient is omitted from likelihoods, so reported log-likelihoods are relative. Bayes factors and posteriors are unaffected.
Metadata
Release files for epirefine 0.10.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.10.0.tar.gz | 97.8 kB | With provenance | Details for epirefine-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| epirefine-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for epirefine-0.10.0-py3-none-any.whl |
Total release size: 163.6 kB
Release files / epirefine-0.10.0.tar.gz
| Download URL | epirefine-0.10.0.tar.gz |
|---|---|
| Size | 97.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dee39ac6c73ec0a69057869c3e09ee414f019511b69328e6e923dd5d5c62a872
|
|
BLAKE2b-256 checksum How to use checksums |
bbd99de37d8559c63b178e2ba58c181817c0cd48f79e3ccea8c449ba8c472519
|
| 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 2, 2026.
Transparency logRelease files / epirefine-0.10.0-py3-none-any.whl
| Download URL | epirefine-0.10.0-py3-none-any.whl |
|---|---|
| Size | 65.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6af2f10e6f8906f82756e5575eef41cdff04055e9a339fe94dd3cfc6a71a520
|
|
BLAKE2b-256 checksum How to use checksums |
5975d25085e70b7740de9e692ca10e3673ba04a445c8d484a7530fd382d40045
|
| 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 2, 2026.
Transparency logSecurity for epirefine 0.10.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
Both files in this release have been uploaded with provenance metadata.
Attestation for epirefine-0.10.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 2, 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.