Skip to content

New module: modkit/entropy - #11283

Open
sahuno wants to merge 5 commits into
nf-core:masterfrom
sahuno:add-modkit-entropy
Open

New module: modkit/entropy#11283
sahuno wants to merge 5 commits into
nf-core:masterfrom
sahuno:add-modkit-entropy

Conversation

@sahuno

@sahuno sahuno commented Apr 24, 2026

Copy link
Copy Markdown

PR checklist

  • This comment contains a description of changes (with reason).
  • Tests added (stub + real, both --cpg mode).
  • New tool follows module conventions.
  • Versions broadcast via topic: versions.
  • Naming/parameter/I-O conventions followed.
  • Resource label set (process_high).
  • BioConda + BioContainers used.
  • `nf-core modules lint modkit/entropy` — 50/0/0.
  • `nf-test test --profile conda` — 2/2 passed.

Summary

Adds a new nf-core module wrapping `modkit entropy`, which computes methylation entropy over genomic windows from one or more mod-BAMs. Entropy is a per-window measure of the diversity of methylation patterns across reads covering the window and is complementary to mean methylation.

The module supports modkit's file-vs-directory output dichotomy: when `--regions` is supplied (either via `ext.args` or the third input channel), modkit writes per-region BED / bedgraph / TSV into a directory (emitted via `regions_bed`, `bedgraph`, `tsv` outputs); otherwise a single genome-wide BED is produced (emitted via `bed`).

Accepts multiple input BAMs (passed as repeated `--in-bam`) for multi-sample entropy.

Why

`modkit entropy` is the canonical tool for quantifying methylation heterogeneity in ONT methylation data and is not currently in nf-core/modules. It complements the existing `modkit/pileup` (mean methylation) for heterogeneity-aware analyses.

Test data

Uses the existing `test.sorted.phased.bam` from nf-core/test-datasets (modules branch, `genomics/homo_sapiens/nanopore/bam/`). No new test data required.

🤖 Generated with Claude Code

@sahuno
sahuno force-pushed the add-modkit-entropy branch from cc8a7f2 to e0004d3 Compare April 24, 2026 02:44
@sahuno
sahuno requested review from a team as code owners April 24, 2026 02:44
@sahuno
sahuno force-pushed the add-modkit-entropy branch from e0004d3 to d95d97b Compare April 24, 2026 02:44
Add new nf-core module wrapping `modkit entropy`, which computes
methylation entropy over genomic windows from one or more mod-BAMs.
Supports an optional BED of regions for per-region descriptive
statistics; emits a genome-wide BED otherwise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sahuno
sahuno force-pushed the add-modkit-entropy branch from d95d97b to 0978565 Compare April 24, 2026 03:02

@itrujnara itrujnara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the high-quality submission. I have left a handful of comments.

Comment thread modules/nf-core/modkit/entropy/main.nf Outdated
Comment thread modules/nf-core/modkit/entropy/tests/main.nf.test Outdated
Comment thread modules/nf-core/modkit/entropy/tests/main.nf.test Outdated
@atrigila atrigila added the awaiting-changes will be closed after 30 days label Jul 2, 2026
@github-actions

Copy link
Copy Markdown

This PR has been tagged as awaiting-changes or awaiting-feedback by an @nf-core/modules contributor. Remove stale label or add a comment if it is still useful.

@github-actions github-actions Bot added the stale Stale label Aug 16, 2026
…ions

Addresses @itrujnara's review:

- Stub now simulates the `--regions` layout. `modkit entropy --regions` writes
  a directory containing `<prefix>_regions.bed` and `<prefix>_windows.bedgraph`
  instead of the single genome-wide BED, so the stub branches on `regions`.
- Added a real and a stub test that exercise the `regions` input, asserting the
  exact output filenames and that `bed` is not emitted when `regions` is set.
- Tests now check file contents. `--header` is passed via `ext.args` so the
  header line and row structure can be asserted for all three output flavours.

Also removed the `tsv` output channel: `modkit entropy --regions` emits only
`_regions.bed` and `_windows.bedgraph` (verified against modkit 0.6.1), so the
emit never fired. The `meta.yml` description claiming a `.tsv` output was
corrected to match.

The entropy column is not byte-deterministic across thread counts, so the
non-stub tests continue to snapshot only the versions topic.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E7RSvpouxbMBdimYSwJ5ZP
@sahuno

sahuno commented Sep 6, 2026

Copy link
Copy Markdown
Author

Thanks for the review @itrujnara — all three points addressed.

1. Stub now simulates the --regions output. modkit entropy --regions
writes a directory containing <prefix>_regions.bed and
<prefix>_windows.bedgraph instead of the single genome-wide BED, so the stub
branches on whether regions is present and creates the matching layout.

While confirming the filenames against modkit 0.6.1 I found the tsv output
channel never fires — modkit entropy --regions emits only the _regions.bed
and _windows.bedgraph files, no TSV. Removed that emit and corrected the
meta.yml description, which claimed a .tsv was produced.

2. Added tests that use the regions input — one real and one stub. The
real one asserts the exact output filenames, that bed is not emitted when
regions is passed, and that the region_name column echoes the interval
from the input BED.

3. Yes — now checking file contents. modkit entropy has a --header
flag, so the test config passes --cpg --header and the tests assert on the
header line and the row structure:

  • genome-wide BED and per-window bedgraph:
    #chrom start end entropy strand num_reads
  • per-region BED: chrom start end region_name mean_entropy ...
  • every data row has all six columns and a parseable numeric entropy value

Still snapshotting only the versions topic for the non-stub tests: the entropy
column is not byte-deterministic across CPU counts (I get 0.69360054 vs
0.6936004 for the same window between runs with different thread counts), so
an md5 snapshot would be flaky in CI.

@sahuno sahuno removed the stale Stale label Sep 6, 2026
`nf-core lint` (tools@dev) checks that the string "versions" appears in each
snapshot entry via `test_snap_versions`. The two non-stub tests snapshotted
`process.out.versions_modkit` as a bare list, so the serialised content held
only the values ("MODKIT_ENTROPY", "modkit", "0.6.1") and the check failed.

Snapshotting `[versions: process.out.versions_modkit]` keeps the same content
and satisfies the check. Verified with nf-core/tools 4.1.0: 64 passed, 0 failed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E7RSvpouxbMBdimYSwJ5ZP
@sahuno sahuno mentioned this pull request Sep 7, 2026
9 tasks
sahuno and others added 2 commits September 9, 2026 14:17
Ports the review changes from nf-core#11286 to this module.

- `assert process.success` moved out of `assertAll` and to the top of each
  `then` block — ahead of the `path(...).readLines()` calls, which would
  otherwise throw on a failed run before any assertion reported.
- The two stub tests snapshot `sanitizeOutput(process.out)`, which drops the
  duplicated numbered output keys. Requires nft-utils 1.x, which is why
  master is merged in first.
- The two non-stub tests still snapshot only the versions topic: entropy's
  floating-point columns are not byte-deterministic across CPU counts, so
  those outputs stay asserted on structure rather than md5.
- tests/nextflow.config is kept: it sets a real `ext.args = '--cpg --header'`.
- Bump ont-modkit 0.6.1 -> 0.6.4 (clears the `bioconda_latest` lint warning);
  container tag `0.6.4--h7f49ad2_0` verified on the Galaxy depot and quay.io.

The header and column-count assertions pass unchanged at 0.6.4, so the
entropy BED/bedgraph layout is stable across the bump.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAsT7dzCcLSicJxFRWJozr
@sahuno
sahuno requested a review from itrujnara September 11, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-changes will be closed after 30 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants