diff --git a/modules/nf-core/stainwarpy/transformsegmask/environment.yml b/modules/nf-core/stainwarpy/transformsegmask/environment.yml new file mode 100644 index 00000000000..94ec10130bd --- /dev/null +++ b/modules/nf-core/stainwarpy/transformsegmask/environment.yml @@ -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::stainwarpy=0.2.3 diff --git a/modules/nf-core/stainwarpy/transformsegmask/main.nf b/modules/nf-core/stainwarpy/transformsegmask/main.nf new file mode 100644 index 00000000000..59e3a9e72be --- /dev/null +++ b/modules/nf-core/stainwarpy/transformsegmask/main.nf @@ -0,0 +1,46 @@ +process STAINWARPY_TRANSFORMSEGMASK { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'oras://community.wave.seqera.io/library/stainwarpy:0.2.3--5966e23f2f7d254a' : + 'community.wave.seqera.io/library/stainwarpy:0.2.3--2c8b18a5e6d93e4a'}" + + input: + tuple val(meta), path(hne_img) + tuple val(meta2), path(multiplx_img) + tuple val(meta3), path(seg_mask) + tuple val(meta4), path(tform_map) + val fixed_img + val final_sz + + output: + tuple val(meta), path("transformed_segmentation_mask.ome.tif") , emit: transformed_seg_mask + tuple val("${task.process}"), val('stainwarpy'), eval("stainwarpy --version | sed 's/.* //'"), emit: versions_stainwarpy_transformsegmask, topic: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + + """ + stainwarpy \\ + transform-seg-mask \\ + ${seg_mask} \\ + ${multiplx_img} \\ + ${hne_img} \\ + . \\ + ${tform_map} \\ + ${fixed_img} \\ + ${final_sz} \\ + ${args} + """ + + stub: + + """ + touch transformed_segmentation_mask.ome.tif + """ +} diff --git a/modules/nf-core/stainwarpy/transformsegmask/meta.yml b/modules/nf-core/stainwarpy/transformsegmask/meta.yml new file mode 100644 index 00000000000..e44a6553342 --- /dev/null +++ b/modules/nf-core/stainwarpy/transformsegmask/meta.yml @@ -0,0 +1,112 @@ +name: "stainwarpy_transformsegmask" +description: Transform segmentation mask of multiplexed or H&E stained tissue images using stainwarpy +keywords: + - image registration + - histology + - hne + - multiplexed + - segmentation mask +tools: + - "stainwarpy": + description: "Register H&E stained and Multiplexed tissue images using feature-based image registration" + homepage: "https://github.com/tckumarasekara/stainwarpy" + documentation: "https://github.com/tckumarasekara/stainwarpy" + tool_dev_url: "https://github.com/tckumarasekara/stainwarpy" + licence: ["MIT License", "Apache-2.0"] + identifier: "" + +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - hne_img: + type: file + description: H&E stained image file + pattern: "*.{ome.tif,ome.tiff,tif,tiff}" + ontologies: + - edam: "http://edamontology.org/format_3727" + - edam: "http://edamontology.org/format_3591" + - - meta2: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - multiplx_img: + type: file + description: Multiplexed image file + pattern: "*.{ome.tif,ome.tiff,tif,tiff}" + ontologies: + - edam: "http://edamontology.org/format_3727" + - edam: "http://edamontology.org/format_3591" + - - meta3: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - seg_mask: + type: file + description: Segmentation mask file + pattern: "*.{ome.tif,ome.tiff,tif,tiff,npy}" + ontologies: + - edam: "http://edamontology.org/format_3727" + - edam: "http://edamontology.org/format_3591" + - - meta4: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - tform_map: + type: file + description: Transformation map file + pattern: "*.npy" + ontologies: [] + - fixed_img: + type: string + description: Which image to use as fixed image for registration. Options - 'hne' or 'multiplexed' + ontologies: [] + - final_sz: + type: string + description: In which pixel size to output the registered image and segmentation mask. Options - 'hne' or 'multiplexed' + ontologies: [] + +output: + transformed_seg_mask: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - "transformed_segmentation_mask.ome.tif": + type: file + description: Transformed segmentation mask in OME-TIFF format + pattern: "transformed_segmentation_mask.ome.tif" + ontologies: + - edam: "http://edamontology.org/format_3727" + versions_stainwarpy_transformsegmask: + - - "${task.process}": + type: string + description: The name of the process + - "stainwarpy": + type: string + description: The name of the tool + - "stainwarpy --version | sed 's/.* //'": + type: eval + description: The expression to obtain the version of the tool + +topics: + versions: + - - ${task.process}: + type: string + description: The name of the process + - stainwarpy: + type: string + description: The name of the tool + - stainwarpy --version | sed 's/.* //': + type: eval + description: The expression to obtain the version of the tool +authors: + - "@tckumarasekara" +maintainers: + - "@tckumarasekara" diff --git a/modules/nf-core/stainwarpy/transformsegmask/tests/main.nf.test b/modules/nf-core/stainwarpy/transformsegmask/tests/main.nf.test new file mode 100644 index 00000000000..0cbc4304377 --- /dev/null +++ b/modules/nf-core/stainwarpy/transformsegmask/tests/main.nf.test @@ -0,0 +1,98 @@ +nextflow_process { + + name "Test Process STAINWARPY_TRANSFORMSEGMASK" + script "../main.nf" + process "STAINWARPY_TRANSFORMSEGMASK" + + tag "modules" + tag "modules_nfcore" + tag "stainwarpy" + tag "stainwarpy/transformsegmask" + + config "./nextflow.config" + + test("colon_tissue_local - ome.tif") { + + when { + params { + modules_args = "" + } + process { + """ + input[0] = [ + [ id:'sample1'], + file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/hne_image_colon.ome.tif', checkIfExists: true) + ] + input[1] = [ + [ id:'sample1'], + file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/multiplexed_single_channel_img.ome.tif', checkIfExists: true) + ] + input[2] = [ + [ id:'sample1'], + file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/hne_segmentation_mask.ome.tif', checkIfExists: true) + ] + input[3] = [ + [ id:'sample1'], + file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/feature_based_transformation_map.npy', checkIfExists: true) + ] + input[4] = 'multiplexed' + input[5] = 'multiplexed' + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + file(process.out.transformed_seg_mask.get(0).get(1)).exists(), + process.out.findAll { key, val -> key.startsWith("versions")} + ).match() + } + ) + } + + } + + test("colon_tissue_local - ome.tif - stub") { + + options "-stub" + + when { + params { + modules_args = null + } + process { + """ + input[0] = [ + [ id:'sample1'], + file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/hne_image_colon.ome.tif', checkIfExists: true) + ] + input[1] = [ + [ id:'sample1'], + file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/multiplexed_single_channel_img.ome.tif', checkIfExists: true) + ] + input[2] = [ + [ id:'sample1'], + file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/hne_segmentation_mask.ome.tif', checkIfExists: true) + ] + input[3] = [ + [ id:'sample1'], + file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/feature_based_transformation_map.npy', checkIfExists: true) + ] + input[4] = 'multiplexed' + input[5] = 'multiplexed' + """ + } + } + + then { + { assert snapshot( + process.out.transformed_seg_mask, + process.out.findAll { key, val -> key.startsWith("versions")} + ).match() } + } + + } + +} diff --git a/modules/nf-core/stainwarpy/transformsegmask/tests/main.nf.test.snap b/modules/nf-core/stainwarpy/transformsegmask/tests/main.nf.test.snap new file mode 100644 index 00000000000..c4c34ef0534 --- /dev/null +++ b/modules/nf-core/stainwarpy/transformsegmask/tests/main.nf.test.snap @@ -0,0 +1,47 @@ +{ + "colon_tissue_local - ome.tif": { + "content": [ + true, + { + "versions_stainwarpy_transformsegmask": [ + [ + "STAINWARPY_TRANSFORMSEGMASK", + "stainwarpy", + "0.2.3" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.2" + }, + "timestamp": "2026-01-20T13:38:10.728598964" + }, + "colon_tissue_local - ome.tif - stub": { + "content": [ + [ + [ + { + "id": "sample1" + }, + "transformed_segmentation_mask.ome.tif:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + { + "versions_stainwarpy_transformsegmask": [ + [ + "STAINWARPY_TRANSFORMSEGMASK", + "stainwarpy", + "0.2.3" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.2" + }, + "timestamp": "2026-01-20T13:38:17.92763081" + } +} \ No newline at end of file diff --git a/modules/nf-core/stainwarpy/transformsegmask/tests/nextflow.config b/modules/nf-core/stainwarpy/transformsegmask/tests/nextflow.config new file mode 100644 index 00000000000..cf7c6a42a25 --- /dev/null +++ b/modules/nf-core/stainwarpy/transformsegmask/tests/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: STAINWARPY_TRANSFORMSEGMASK { + ext.args = params.modules_args ?: '' + } +}