diff --git a/conf/modules.config b/conf/modules.config index 1311949..76b219a 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -47,15 +47,24 @@ process { withName: "DEEPCELL_MESMER" { ext.prefix = { "mask_${meta.id}" } ext.args = '--image-mpp=0.215 --nuclear-channel 0 --compartment nuclear' + ext.when = {params.segmentation && params.segmentation.split(',').contains('mesmer')} publishDir = [ path: { "${params.outdir}/segmentation/deepcell_mesmer" }, mode: params.publish_dir_mode, ] } + withName: "CELLPOSE" { + ext.when = {params.segmentation && params.segmentation.split(',').contains('cellpose')} + publishDir = [ + path: { "${params.outdir}/segmentation/cellpose" }, + mode: params.publish_dir_mode, + ] + } + withName: MCQUANT { publishDir = [ - path: { "${params.outdir}/quantification/mcquant" }, + path: { "${params.outdir}/quantification/mcquant/${meta2.segmenter}" }, mode: params.publish_dir_mode, ] } diff --git a/modules.json b/modules.json index 3a70128..3329a8f 100644 --- a/modules.json +++ b/modules.json @@ -25,6 +25,12 @@ "cellpose": { "branch": "master", "git_sha": "716ef3019b66772a817b417078edce2f7b337858", + "installed_by": ["modules"], + "patch": "modules/nf-core/cellpose/cellpose.diff" + }, + "coreograph": { + "branch": "master", + "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", "installed_by": ["modules"] }, "deepcell/mesmer": { diff --git a/modules/nf-core/cellpose/cellpose.diff b/modules/nf-core/cellpose/cellpose.diff new file mode 100644 index 0000000..44b9c75 --- /dev/null +++ b/modules/nf-core/cellpose/cellpose.diff @@ -0,0 +1,15 @@ +Changes in module 'nf-core/cellpose' +--- modules/nf-core/cellpose/main.nf ++++ modules/nf-core/cellpose/main.nf +@@ -25,6 +25,9 @@ + def model_command = model ? "--pretrained_model $model" : "" + def VERSION = '2.1.1' + """ ++ export HOME=\$PWD ++ export NUMBA_CACHE_DIR=\$PWD ++ + cellpose \ + --image_path $image \ + --save_tif \ + +************************************************************ diff --git a/modules/nf-core/cellpose/main.nf b/modules/nf-core/cellpose/main.nf index a2b2206..6778e6b 100644 --- a/modules/nf-core/cellpose/main.nf +++ b/modules/nf-core/cellpose/main.nf @@ -25,6 +25,9 @@ process CELLPOSE { def model_command = model ? "--pretrained_model $model" : "" def VERSION = '2.1.1' """ + export HOME=\$PWD + export NUMBA_CACHE_DIR=\$PWD + cellpose \ --image_path $image \ --save_tif \ diff --git a/nextflow.config b/nextflow.config index 5a64850..2f9f598 100644 --- a/nextflow.config +++ b/nextflow.config @@ -13,6 +13,8 @@ params { input_sample = null input_cycle = null marker_sheet = null + segmentation = 'mesmer' + cellpose_model = [] // Illumination correction illumination = null diff --git a/nextflow_schema.json b/nextflow_schema.json index 7b24b69..c0209e5 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -65,6 +65,15 @@ "type": "string", "enum": ["basicpy"], "description": "input that defines type of illumination correction to be performed" + }, + "segmentation": { + "type": "string", + "pattern": "^((cellpose|mesmer)?,?)*(? + img: [meta + [segmenter: 'mesmer'], image] + membrane_img: [[:], []] + } + | DEEPCELL_MESMER + ch_masks = ch_masks.mix(DEEPCELL_MESMER.out.mask) ch_versions = ch_versions.mix(DEEPCELL_MESMER.out.versions) + ch_segmentation_input + .multiMap{ meta, image -> + image: [meta + [segmenter: 'cellpose'], image] + model: params.cellpose_model + } + | CELLPOSE + ch_masks = ch_masks.mix(CELLPOSE.out.mask) + ch_versions = ch_versions.mix(CELLPOSE.out.versions) + // Run Quantification // Generate markers.csv for mcquant with just the marker_name column. @@ -92,16 +119,19 @@ workflow MCMICRO { it.collect{ _1, _2, marker_name, _4, _5, _6 -> '"' + marker_name + '"' } } .collectFile(name: 'markers.csv', sort: false, newLine: true) + ASHLAR.out.tif - .join(DEEPCELL_MESMER.out.mask) + .cross(ch_masks) { it[0]['id'] } + .map{ t_ashlar, t_mask -> [t_mask[0], t_ashlar[1], t_mask[1]] } .combine(ch_mcquant_markers) - .dump(tag: 'MCQUANT in') - .multiMap { it -> - image: [it[0], it[1]] - mask: [it[0], it[2]] - markers: [it[0], it[3]] + .dump(tag: 'MCQUANT IN') + .multiMap{ meta, image, mask, marker -> + image: [meta, image] + mask: [meta, mask] + markers: [meta, marker] } | MCQUANT + ch_versions = ch_versions.mix(MCQUANT.out.versions) /*