-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New module: modkit/entropy #11283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sahuno
wants to merge
3
commits into
nf-core:master
Choose a base branch
from
sahuno:add-modkit-entropy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
New module: modkit/entropy #11283
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
| channels: | ||
| - conda-forge | ||
| - bioconda | ||
| dependencies: | ||
| - "bioconda::ont-modkit=0.6.1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| process MODKIT_ENTROPY { | ||
| tag "$meta.id" | ||
| label 'process_high' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "${ workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container ? | ||
| 'https://depot.galaxyproject.org/singularity/ont-modkit:0.6.1--hcdda2d0_0': | ||
| 'quay.io/biocontainers/ont-modkit:0.6.1--hcdda2d0_0' }" | ||
|
|
||
| input: | ||
| // stageAs '?/*' prevents filename collisions when multiple BAMs from the | ||
| // same sample (e.g. technical replicates) are passed to a single run. | ||
| tuple val(meta), path(bams, stageAs: "in/?/*"), path(bais, stageAs: "in/?/*") | ||
| tuple val(meta2), path(fasta), path(fai) | ||
| tuple val(meta3), path(regions) | ||
|
|
||
| output: | ||
| tuple val(meta), path("*.bed") , emit: bed , optional: true | ||
| tuple val(meta), path("entropy_regions/*.bed") , emit: regions_bed , optional: true | ||
| tuple val(meta), path("entropy_regions/*.bedgraph") , emit: bedgraph , optional: true | ||
| tuple val(meta), path("entropy_regions/*.tsv") , emit: tsv , optional: true | ||
| tuple val(meta), path("*.log") , emit: log , optional: true | ||
| tuple val("${task.process}"), val('modkit'), eval("modkit --version | sed 's/modkit //'"), emit: versions_modkit, topic: versions | ||
|
|
||
| when: | ||
| task.ext.when == null || task.ext.when | ||
|
|
||
| script: | ||
| def args = task.ext.args ?: '' | ||
| def prefix = task.ext.prefix ?: "${meta.id}" | ||
| def bam_args = bams instanceof List ? bams.collect { "--in-bam ${it}" }.join(' ') : "--in-bam ${bams}" | ||
| // modkit entropy's --out-bed expects a FILE without --regions, and a DIRECTORY with --regions | ||
| def out_arg = regions ? "--regions ${regions} --out-bed entropy_regions --prefix ${prefix}" : "--out-bed ${prefix}.bed" | ||
| def mkdir = regions ? "mkdir -p entropy_regions" : "" | ||
| """ | ||
| ${mkdir} | ||
|
|
||
| modkit \\ | ||
| entropy \\ | ||
| $args \\ | ||
| --threads ${task.cpus} \\ | ||
| --ref ${fasta} \\ | ||
| ${out_arg} \\ | ||
| ${bam_args} | ||
| """ | ||
|
|
||
| stub: | ||
| def prefix = task.ext.prefix ?: "${meta.id}" | ||
| """ | ||
| touch ${prefix}.bed | ||
| """ | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| name: modkit_entropy | ||
| description: | | ||
| Calculate 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. | ||
| When `--regions` is supplied (via `ext.args` or the `regions` input), modkit | ||
| writes per-region BED/bedgraph/tsv files into a directory; otherwise a single | ||
| genome-wide BED file is produced. | ||
| keywords: | ||
| - modkit | ||
| - methylation | ||
| - entropy | ||
| - nanopore | ||
| - ont | ||
| - modbam | ||
| tools: | ||
| - "modkit": | ||
| description: A bioinformatics tool for working with modified bases in Oxford Nanopore | ||
| sequencing data. | ||
| homepage: https://github.com/nanoporetech/modkit | ||
| documentation: https://nanoporetech.github.io/modkit/ | ||
| tool_dev_url: https://github.com/nanoporetech/modkit | ||
| licence: | ||
| - "Oxford Nanopore Technologies PLC. Public License Version 1.0" | ||
| identifier: "" | ||
| input: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`. The output inherits this meta. | ||
| - bams: | ||
| type: list | ||
| description: | | ||
| One or more modBAM files to compute entropy from. Passing more than | ||
| one BAM aggregates counts across them (multi-sample entropy). | ||
| pattern: "*.{bam,cram}" | ||
| ontologies: | ||
| - edam: http://edamontology.org/format_2572 | ||
| - bais: | ||
| type: list | ||
| description: | | ||
| BAM indices (`.bai` or `.csi`) matching each input BAM, one-to-one. | ||
| pattern: "*.{bai,csi}" | ||
| ontologies: [] | ||
| - - meta2: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing reference information | ||
| e.g. `[ id:'mm10' ]`. | ||
| - fasta: | ||
| type: file | ||
| description: Reference FASTA the BAM was aligned to. | ||
| pattern: "*.{fa,fasta,fna}" | ||
| ontologies: | ||
| - edam: http://edamontology.org/format_1929 | ||
| - fai: | ||
| type: file | ||
| description: Samtools FASTA index for `fasta`. | ||
| pattern: "*.fai" | ||
| ontologies: | ||
| - edam: http://edamontology.org/format_3475 | ||
| - - meta3: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing region information | ||
| e.g. `[ id:'promoters' ]`. May be `[[], []]` to skip. | ||
| - regions: | ||
| type: file | ||
| description: | | ||
| Optional BED file of regions over which to compute per-region | ||
| descriptive statistics. When provided, modkit writes per-region | ||
| outputs (`.bed`, `.bedgraph`, `.tsv`) into a directory. | ||
| pattern: "*.{bed,bed.gz}" | ||
| ontologies: | ||
| - edam: http://edamontology.org/format_3003 | ||
| output: | ||
| bed: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`. | ||
| - "*.bed": | ||
| type: file | ||
| description: | | ||
| Genome-wide entropy BED file, produced when `regions` is not | ||
| provided. One row per window. | ||
| pattern: "*.bed" | ||
| ontologies: | ||
| - edam: http://edamontology.org/format_3003 | ||
| regions_bed: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`. | ||
| - "entropy_regions/*.bed": | ||
| type: file | ||
| description: | | ||
| Per-region entropy BED files, produced when `regions` is provided. | ||
| pattern: "*.bed" | ||
| ontologies: | ||
| - edam: http://edamontology.org/format_3003 | ||
| bedgraph: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`. | ||
| - "entropy_regions/*.bedgraph": | ||
| type: file | ||
| description: | | ||
| Per-region entropy bedgraph, produced when `regions` is provided. | ||
| pattern: "*.bedgraph" | ||
| ontologies: | ||
| - edam: http://edamontology.org/format_3583 | ||
| tsv: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`. | ||
| - "entropy_regions/*.tsv": | ||
| type: file | ||
| description: | | ||
| Per-region descriptive statistics TSV, produced when `regions` | ||
| is provided. | ||
| pattern: "*.tsv" | ||
| ontologies: | ||
| - edam: http://edamontology.org/format_3475 | ||
| log: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`. | ||
| - "*.log": | ||
| type: file | ||
| description: | | ||
| Optional modkit debug log (only emitted when `--log-filepath | ||
| <name>.log` is passed via `ext.args`). | ||
| pattern: "*.log" | ||
| ontologies: [] | ||
| versions_modkit: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - modkit: | ||
| type: string | ||
| description: The name of the tool | ||
| - modkit --version | sed 's/modkit //': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| topics: | ||
| versions: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - modkit: | ||
| type: string | ||
| description: The name of the tool | ||
| - modkit --version | sed 's/modkit //': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| authors: | ||
| - "@sahuno" | ||
| maintainers: | ||
| - "@sahuno" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| nextflow_process { | ||
|
|
||
| name "Test Process MODKIT_ENTROPY" | ||
| script "../main.nf" | ||
| process "MODKIT_ENTROPY" | ||
| config "./nextflow.config" | ||
|
|
||
| tag "modules" | ||
| tag "modules_nfcore" | ||
| tag "modkit" | ||
| tag "modkit/entropy" | ||
|
|
||
| test("homo sapiens - nanopore modbam - cpg - stub") { | ||
|
|
||
| options "-stub" | ||
|
|
||
| when { | ||
| process { | ||
| """ | ||
| input[0] = [ | ||
| [ id: 'test' ], | ||
| [ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/nanopore/bam/test.sorted.phased.bam', checkIfExists: true) ], | ||
| [ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/nanopore/bam/test.sorted.phased.bam.bai', checkIfExists: true) ] | ||
| ] | ||
| input[1] = [ | ||
| [ id: 'genome' ], | ||
| file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true), | ||
| file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true) | ||
| ] | ||
| input[2] = [[],[]] | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert process.success }, | ||
| { assert snapshot(process.out).match() } | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| test("homo sapiens - nanopore modbam - cpg") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a test that uses the regions input |
||
|
|
||
| when { | ||
| process { | ||
| """ | ||
| input[0] = [ | ||
| [ id: 'test' ], | ||
| [ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/nanopore/bam/test.sorted.phased.bam', checkIfExists: true) ], | ||
| [ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/nanopore/bam/test.sorted.phased.bam.bai', checkIfExists: true) ] | ||
| ] | ||
| input[1] = [ | ||
| [ id: 'genome' ], | ||
| file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true), | ||
| file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true) | ||
| ] | ||
| input[2] = [[],[]] | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert process.success }, | ||
| { assert process.out.bed }, | ||
| { assert path(process.out.bed[0][1]).exists() }, | ||
| { assert path(process.out.bed[0][1]).size() > 0 }, | ||
| // modkit entropy's BED output isn't byte-deterministic across CPU | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to check anything inside the file (e.g. header line)? |
||
| // counts / architectures (float precision differs). Assert structure | ||
| // only and snapshot just the versions topic. | ||
| { assert snapshot(process.out.versions_modkit).match() } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| { | ||
| "homo sapiens - nanopore modbam - cpg": { | ||
| "content": [ | ||
| [ | ||
| [ | ||
| "MODKIT_ENTROPY", | ||
| "modkit", | ||
| "0.6.1" | ||
| ] | ||
| ] | ||
| ], | ||
| "timestamp": "2026-04-23T23:01:43.40082036", | ||
| "meta": { | ||
| "nf-test": "0.9.5", | ||
| "nextflow": "25.04.6" | ||
| } | ||
| }, | ||
| "homo sapiens - nanopore modbam - cpg - stub": { | ||
| "content": [ | ||
| { | ||
| "0": [ | ||
| [ | ||
| { | ||
| "id": "test" | ||
| }, | ||
| "test.bed:md5,d41d8cd98f00b204e9800998ecf8427e" | ||
| ] | ||
| ], | ||
| "1": [ | ||
|
|
||
| ], | ||
| "2": [ | ||
|
|
||
| ], | ||
| "3": [ | ||
|
|
||
| ], | ||
| "4": [ | ||
|
|
||
| ], | ||
| "5": [ | ||
| [ | ||
| "MODKIT_ENTROPY", | ||
| "modkit", | ||
| "0.6.1" | ||
| ] | ||
| ], | ||
| "bed": [ | ||
| [ | ||
| { | ||
| "id": "test" | ||
| }, | ||
| "test.bed:md5,d41d8cd98f00b204e9800998ecf8427e" | ||
| ] | ||
| ], | ||
| "bedgraph": [ | ||
|
|
||
| ], | ||
| "log": [ | ||
|
|
||
| ], | ||
| "regions_bed": [ | ||
|
|
||
| ], | ||
| "tsv": [ | ||
|
|
||
| ], | ||
| "versions_modkit": [ | ||
| [ | ||
| "MODKIT_ENTROPY", | ||
| "modkit", | ||
| "0.6.1" | ||
| ] | ||
| ] | ||
| } | ||
| ], | ||
| "timestamp": "2026-04-23T23:01:16.647684082", | ||
| "meta": { | ||
| "nf-test": "0.9.5", | ||
| "nextflow": "25.04.6" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| process { | ||
| withName: 'MODKIT_ENTROPY' { | ||
| ext.args = '--cpg' | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get the stub to simulate the bigger output when
regionsis passed?