From 7567a43ec47af4846c1945f2ba929f7474c4ca62 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 25 Nov 2023 11:33:47 +0000 Subject: [PATCH 1/7] Add openslide conversion --- modules/convert_to_openslide.nf | 17 +++++++++++++++++ subworkflows/run_histoqc.nf | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 modules/convert_to_openslide.nf diff --git a/modules/convert_to_openslide.nf b/modules/convert_to_openslide.nf new file mode 100644 index 0000000..e4a789a --- /dev/null +++ b/modules/convert_to_openslide.nf @@ -0,0 +1,17 @@ +process CONVERT { + + container 'ghcr.io/mc2-center/histoqc-openslide-converter:latest' + + input: + tuple val(meta), path(images) + + output: + tuple val(meta), path("${images.simpleName}_openslide.tiff") + + script: + + """ + vips im_vips2tiff $images ${images.simpleName}_openslide.tiff:jpeg:75,tile:512x512,pyramid + tifftools set -y -s ImageDescription "Aperio nf-histoqc |AppMag = $params.mag|MPP = $params.mpp" ${images.simpleName}_openslide.tiff + """ +} \ No newline at end of file diff --git a/subworkflows/run_histoqc.nf b/subworkflows/run_histoqc.nf index 6962624..f12380c 100644 --- a/subworkflows/run_histoqc.nf +++ b/subworkflows/run_histoqc.nf @@ -1,4 +1,5 @@ include { HISTOQC } from "../modules/histoqc.nf" +include { CONVERT } from "../modules/convert_to_openslide.nf" workflow RUN { @@ -6,7 +7,8 @@ workflow RUN { images main: - HISTOQC ( images ) + + images | (params.convert ? CONVERT : it) | HISTOQC emit: output = HISTOQC.out.masks From c311f2831f6095a960c460c2288dc8426ed9d749 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 25 Nov 2023 12:00:33 +0000 Subject: [PATCH 2/7] Refine conditional logic --- main.nf | 9 +++++++++ subworkflows/run_histoqc.nf | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/main.nf b/main.nf index dadf6c7..1c44bd2 100644 --- a/main.nf +++ b/main.nf @@ -4,6 +4,15 @@ nextflow.enable.dsl=2 if (params.input) { params.input = file(params.input) } else { exit 1, 'Input samplesheet not specified!' } +params.convert = false + +if (params.convert) { + if (!params.mag || !params.mpp) { + error "Both nominal magnification ('mag') and microns per pixel ('mpp' parameters must be provided when 'params.convert' is set to true." + } +} + + // Set parameters and defaults params.outDir = './outputs' params.config = 'default' diff --git a/subworkflows/run_histoqc.nf b/subworkflows/run_histoqc.nf index f12380c..37ab975 100644 --- a/subworkflows/run_histoqc.nf +++ b/subworkflows/run_histoqc.nf @@ -8,7 +8,7 @@ workflow RUN { main: - images | (params.convert ? CONVERT : it) | HISTOQC + ifparams.convert ? CONVERT(images) | HISTOQC : HISTOQC(images) emit: output = HISTOQC.out.masks From 9199a992157db948490b29af7fd239e7035bf378 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 25 Nov 2023 12:00:59 +0000 Subject: [PATCH 3/7] Typo --- subworkflows/run_histoqc.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/run_histoqc.nf b/subworkflows/run_histoqc.nf index 37ab975..f3621fe 100644 --- a/subworkflows/run_histoqc.nf +++ b/subworkflows/run_histoqc.nf @@ -8,7 +8,7 @@ workflow RUN { main: - ifparams.convert ? CONVERT(images) | HISTOQC : HISTOQC(images) + params.convert ? CONVERT(images) | HISTOQC : HISTOQC(images) emit: output = HISTOQC.out.masks From 9e2b034698ace9f27ca46fcb665f6844cd28e955 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 25 Nov 2023 17:10:37 +0000 Subject: [PATCH 4/7] Add conversion parameters to schema --- nextflow_schema.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nextflow_schema.json b/nextflow_schema.json index 7375c3e..f78ddae 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -38,6 +38,26 @@ "enum": ["default", "ihc", "clinical", "first", "light", "v2.1"] } } + }, + "conversion_options": { + "title": "Conversion options", + "type": "object", + "fa_icon": "fas fa-solid fa-rotate-right", + "description": "Define parameters used during conversion to openslide compatible tiff", + "properties": { + "convert": { + "type": "boolean", + "description": "Should images be converted to an openslide compatible tiff" + }, + "mag": { + "type": "integer", + "description": "Nominal magnification to inject into openslide compatible tiff" + }, + "mpp": { + "type": "number", + "description": "Image resolution (pixels per micron) to inject into openslide compatible tiff" + } + } } }, "allOf": [ From d5e2fdaa4605b6c8e981e83a22cfee2a2a53e031 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 25 Nov 2023 17:15:20 +0000 Subject: [PATCH 5/7] Update schema icon --- nextflow_schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nextflow_schema.json b/nextflow_schema.json index f78ddae..4cfcc5d 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -42,7 +42,7 @@ "conversion_options": { "title": "Conversion options", "type": "object", - "fa_icon": "fas fa-solid fa-rotate-right", + "fa_icon": "fas fa-solid fa-magic", "description": "Define parameters used during conversion to openslide compatible tiff", "properties": { "convert": { From 3be9aaad2c6cf35382392b773eea1a552fa9e414 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 25 Nov 2023 17:16:51 +0000 Subject: [PATCH 6/7] Hide config section --- nextflow_schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nextflow_schema.json b/nextflow_schema.json index 4cfcc5d..f91968b 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -44,6 +44,7 @@ "type": "object", "fa_icon": "fas fa-solid fa-magic", "description": "Define parameters used during conversion to openslide compatible tiff", + "hidden": true, "properties": { "convert": { "type": "boolean", @@ -55,7 +56,7 @@ }, "mpp": { "type": "number", - "description": "Image resolution (pixels per micron) to inject into openslide compatible tiff" + "description": "Image resolution (microns per pixel) to inject into openslide compatible tiff" } } } From 514c9116636431ef850b7b0b759abc57f202249e Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 25 Nov 2023 17:18:06 +0000 Subject: [PATCH 7/7] Fix hidden section --- nextflow_schema.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nextflow_schema.json b/nextflow_schema.json index f91968b..5ebc01d 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -44,19 +44,21 @@ "type": "object", "fa_icon": "fas fa-solid fa-magic", "description": "Define parameters used during conversion to openslide compatible tiff", - "hidden": true, "properties": { "convert": { "type": "boolean", - "description": "Should images be converted to an openslide compatible tiff" + "description": "Should images be converted to an openslide compatible tiff", + "hidden": true }, "mag": { "type": "integer", - "description": "Nominal magnification to inject into openslide compatible tiff" + "description": "Nominal magnification to inject into openslide compatible tiff", + "hidden": true }, "mpp": { "type": "number", - "description": "Image resolution (microns per pixel) to inject into openslide compatible tiff" + "description": "Image resolution (microns per pixel) to inject into openslide compatible tiff", + "hidden": true } } }