forked from nf-core/modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added contrast limited adaptive histogram equalization module (nf-cor…
…e#5268) * clahe_module * removed todos * Fixed linting, excluded conda tests. * Added conda test skip to workflows/test.yml. --------- Co-authored-by: Florian Wuennemann <[email protected]>
- Loading branch information
Showing
7 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,49 @@ | ||
process MOLKARTGARAGE_CLAHE { | ||
tag "$meta.id" | ||
label 'process_medium' | ||
|
||
container "ghcr.io/schapirolabor/molkart-local:v0.1.1" | ||
|
||
input: | ||
tuple val(meta), path(image) | ||
|
||
output: | ||
tuple val(meta), path("*.tiff") , emit: img_clahe | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
// Exit if running this module with -profile conda / -profile mamba | ||
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { | ||
error "Molkartgarage/clahe module does not support Conda. Please use Docker / Singularity / Podman instead." | ||
} | ||
def args = task.ext.args ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
""" | ||
python /local/scripts/molkart_clahe.py \ | ||
--input ${image} \ | ||
--output ${prefix}.tiff \ | ||
$args | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
molkart_clahe: \$(python /local/scripts/molkart_clahe.py --version) | ||
scikit-image: 0.19.2 | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def args = task.ext.args ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
""" | ||
touch ${prefix}.tiff | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
molkart_clahe: \$(python3 /local/scripts/molkart_clahe.py --version) | ||
scikit-image: 0.19.2 | ||
END_VERSIONS | ||
""" | ||
} |
This file contains 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 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json | ||
name: "molkartgarage_clahe" | ||
description: Contrast-limited adjusted histogram equalization (CLAHE) on single-channel tif images. | ||
keywords: | ||
- clahe | ||
- image_processing | ||
- imaging | ||
- correction | ||
tools: | ||
- "molkartgarage": | ||
description: "One-stop-shop for scripts and tools for processing data for molkart and spatial omics pipelines." | ||
homepage: https://github.com/SchapiroLabor/molkart-local/tree/main | ||
documentation: https://github.com/SchapiroLabor/molkart-local/tree/main | ||
tool_dev_url: https://github.com/SchapiroLabor/molkart-local/blob/main/scripts/molkart_clahe.py | ||
licence: ["MIT"] | ||
|
||
input: | ||
# Only when we have meta | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'sample1']` | ||
- image: | ||
type: file | ||
description: Single-channel tiff file to be corrected. | ||
pattern: "*.{tif,tiff}" | ||
|
||
output: | ||
#Only when we have meta | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'sample1']` | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
|
||
- img_clahe: | ||
type: file | ||
description: CLAHE corrected tiff file. | ||
pattern: "*.{tiff}" | ||
|
||
authors: | ||
- "@kbestak" | ||
maintainers: | ||
- "@kbestak" |
This file contains 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,60 @@ | ||
// test with: nf-core modules test molkartgarage/clahe | ||
nextflow_process { | ||
|
||
name "Test Process MOLKARTGARAGE_CLAHE" | ||
script "../main.nf" | ||
config "./nextflow.config" | ||
process "MOLKARTGARAGE_CLAHE" | ||
|
||
tag "modules" | ||
tag "modules_nfcore" | ||
tag "molkartgarage" | ||
tag "molkartgarage/clahe" | ||
|
||
test("clahe - tiff") { | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] = [ | ||
[ id:'test' ], // meta map | ||
file(params.test_data['imaging']['tiff']['mouse_heart_wga'], checkIfExists: true) | ||
] | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert process.out.img_clahe }, // uuid in metadata changes so md5sums are not the same | ||
{ assert snapshot(process.out.versions).match("versions") } | ||
) | ||
} | ||
|
||
} | ||
|
||
test("clahe - stub") { | ||
|
||
options "-stub" | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] = [ | ||
[ id:'test' ], // meta map | ||
file(params.test_data['imaging']['tiff']['mouse_heart_wga'], checkIfExists: true) | ||
] | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success } | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
modules/nf-core/molkartgarage/clahe/tests/main.nf.test.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 @@ | ||
process { | ||
|
||
withName: "MOLKARTGARAGE_CLAHE" { | ||
ext.args = '--tile-size 368 --tile-size 48 --pixel-size 0.138 --cliplimit 0.01' | ||
} | ||
|
||
} |
This file contains 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,2 @@ | ||
molkartgarage/clahe: | ||
- "modules/nf-core/molkartgarage/clahe/**" |