From 43a0c04242e2b3ae0b1a776fd9702248b5ae9ff9 Mon Sep 17 00:00:00 2001 From: Sameesh Kher Date: Tue, 26 Aug 2025 17:48:17 +0000 Subject: [PATCH 1/2] minor changes to sd handling --- modules/local/spatialdata/write/main.nf | 1 + .../local/spatialdata/write/templates/write.py | 17 +++++++++++++++-- .../cellpose_baysor_import_segmentation/main.nf | 17 +++++++++++++---- .../local/proseg_preset_proseg2baysor/main.nf | 4 +++- .../local/spatialdata_write_meta_merge/main.nf | 10 +++++++--- .../utils_nfcore_spatialxe_pipeline/main.nf | 6 +++--- workflows/spatialxe.nf | 7 ++++++- 7 files changed, 48 insertions(+), 14 deletions(-) diff --git a/modules/local/spatialdata/write/main.nf b/modules/local/spatialdata/write/main.nf index 7ebdb98a..f9bac411 100644 --- a/modules/local/spatialdata/write/main.nf +++ b/modules/local/spatialdata/write/main.nf @@ -8,6 +8,7 @@ process SPATIALDATA_WRITE { tuple val(meta), path(bundle, stageAs: "*") val(outputfolder) val(segmented_object) + val(coordinate_space) output: tuple val(meta), path("${outputfolder}"), emit: spatialdata diff --git a/modules/local/spatialdata/write/templates/write.py b/modules/local/spatialdata/write/templates/write.py index edc10017..31f0f693 100755 --- a/modules/local/spatialdata/write/templates/write.py +++ b/modules/local/spatialdata/write/templates/write.py @@ -13,8 +13,9 @@ def main(): output_path = "." outputfolder = "${outputfolder}" segmented_object = "${segmented_object}" + coordinate_space = "${coordinate_space}" - cells_as_circles=True + cells_as_circles=False cells_boundaries=False nucleus_boundaries=False cells_labels=False @@ -32,7 +33,19 @@ def main(): cells_labels=True nucleus_labels=True else: - cells_as_circles=False + cells_as_circles = False + + # set variables based on the coordinate space + if ( coordinate_space == "pixels" ): + cells_labels = True + nucleus_labels = True + + if ( coordinate_space == "microns" ): + cells_labels = False + cells_boundaries = True + nucleus_boundaries = False + nucleus_labels = False + cells_as_circles = False format = "${params.format}" if ( format == "xenium" ): diff --git a/subworkflows/local/cellpose_baysor_import_segmentation/main.nf b/subworkflows/local/cellpose_baysor_import_segmentation/main.nf index 0ade1a9d..daf6f0c9 100644 --- a/subworkflows/local/cellpose_baysor_import_segmentation/main.nf +++ b/subworkflows/local/cellpose_baysor_import_segmentation/main.nf @@ -24,6 +24,7 @@ workflow CELLPOSE_BAYSOR_IMPORT_SEGMENTATION { ch_image = Channel.empty() ch_polygons = Channel.empty() ch_segmentation = Channel.empty() + ch_transcripts = Channel.empty() ch_filtered_transcripts = Channel.empty() ch_cellpose_cells_mask = Channel.empty() ch_cellpose_nuclei_mask = Channel.empty() @@ -31,6 +32,7 @@ workflow CELLPOSE_BAYSOR_IMPORT_SEGMENTATION { ch_cellpose_nuclei_cells = Channel.empty() ch_cellpose_cells_flows = Channel.empty() ch_cellpose_nuclei_flows = Channel.empty() + ch_coordinate_space = Channel.value("microns") cellpose_model = params.cellpose_model ? (Channel.fromPath(params.cellpose_model, checkIfExists: true)) : [] @@ -98,30 +100,35 @@ workflow CELLPOSE_BAYSOR_IMPORT_SEGMENTATION { ch_versions = ch_versions.mix ( BAYSOR_PREPROCESS_TRANSCRIPTS.out.versions ) ch_filtered_transcripts = BAYSOR_PREPROCESS_TRANSCRIPTS.out.transcripts_parquet + ch_transcripts = ch_filtered_transcripts + } else { + + ch_transcripts = ch_transcripts_parquet } // run baysor with cellpose results if ( params.nucleus_segmentation_only ) { // run baysor with nuclei mask - BAYSOR_RUN ( ch_filtered_transcripts, ch_cellpose_nuclei_mask, ch_config, 30 ) + BAYSOR_RUN ( ch_transcripts, ch_cellpose_nuclei_mask, ch_config, 30 ) ch_versions = ch_versions.mix ( BAYSOR_RUN.out.versions ) } else if ( params.cell_segmentation_only ) { // run baysor with cell mask - BAYSOR_RUN ( ch_filtered_transcripts, ch_cellpose_cells_mask, ch_config, 30 ) + BAYSOR_RUN ( ch_transcripts, ch_cellpose_cells_mask, ch_config, 30 ) ch_versions = ch_versions.mix ( BAYSOR_RUN.out.versions ) } else { // run baysor with cell mask - BAYSOR_RUN ( ch_filtered_transcripts, [], ch_config, 30 ) + BAYSOR_RUN ( ch_transcripts, [], ch_config, 30 ) ch_versions = ch_versions.mix ( BAYSOR_RUN.out.versions ) } + // run import-segmentation with baysor outs ch_segmentation = BAYSOR_RUN.out.segmentation.map { _meta, segmentation -> return [ segmentation ] @@ -136,7 +143,7 @@ workflow CELLPOSE_BAYSOR_IMPORT_SEGMENTATION { [], ch_segmentation, ch_polygons, - "microns" + ch_coordinate_space ) ch_versions = ch_versions.mix ( XENIUMRANGER_IMPORT_SEGMENTATION.out.versions ) @@ -152,6 +159,8 @@ workflow CELLPOSE_BAYSOR_IMPORT_SEGMENTATION { segmentation_mask = ch_segmentation // channel: [ val(meta), [ *segmentation.csv ] ] polygons = ch_polygons // channel: [ val(meta), [ *polygons.json ] ] + coordinate_space = ch_coordinate_space // channel: [ val("microns") ] + redefined_bundle = XENIUMRANGER_IMPORT_SEGMENTATION.out.bundle // channel: [ val(meta), ["redefined-xenium-bundle"] ] versions = ch_versions // channel: [ versions.yml ] diff --git a/subworkflows/local/proseg_preset_proseg2baysor/main.nf b/subworkflows/local/proseg_preset_proseg2baysor/main.nf index b9bda8c4..57b761a8 100644 --- a/subworkflows/local/proseg_preset_proseg2baysor/main.nf +++ b/subworkflows/local/proseg_preset_proseg2baysor/main.nf @@ -17,6 +17,7 @@ workflow PROSEG_PRESET_PROSEG2BAYSOR { main: ch_versions = Channel.empty() + ch_coordinate_space = Channel.value("microns") // run parquet-to-csv PARQUET_TO_CSV ( ch_transcripts_parquet, ".gz" ) @@ -43,7 +44,7 @@ workflow PROSEG_PRESET_PROSEG2BAYSOR { [], ch_metadata, ch_polygons, - "microns" + ch_coordinate_space ) ch_versions = ch_versions.mix( XENIUMRANGER_IMPORT_SEGMENTATION.out.versions ) @@ -53,6 +54,7 @@ workflow PROSEG_PRESET_PROSEG2BAYSOR { xr_polygons = PROSEG2BAYSOR.out.xr_polygons // channel: [ val(meta), [ "xr-cell-polygons.geojson" ] ] xr_metadata = PROSEG2BAYSOR.out.xr_metadata // channel: [ [ "xr-transcript-metadata.csv" ] ] + coordinate_space = ch_coordinate_space // channel: [ "microns" ] redefined_bundle = XENIUMRANGER_IMPORT_SEGMENTATION.out.bundle // channel: [ val(meta), ["redefined-xenium-bundle"] ] diff --git a/subworkflows/local/spatialdata_write_meta_merge/main.nf b/subworkflows/local/spatialdata_write_meta_merge/main.nf index 8daebfe2..6379e85c 100644 --- a/subworkflows/local/spatialdata_write_meta_merge/main.nf +++ b/subworkflows/local/spatialdata_write_meta_merge/main.nf @@ -12,11 +12,13 @@ workflow SPATIALDATA_WRITE_META_MERGE { take: ch_bundle_path // channel: [ val(meta), [ "path-to-xenium-bundle" ] ] ch_redefined_bundle // channel: [ val(meta), [ "redefined-xenium-bundle" ] ] + ch_coordinate_space // channel: [ "pixels" or "microns" ] main: - ch_versions = Channel.empty() + ch_versions = Channel.empty() ch_segmented_object = Channel.empty() + ch_cells_as_circles = Channel.empty() // check segmentation - only nuclei, cells or both cells & nuclei if ( params.mode == 'image') { @@ -56,7 +58,8 @@ workflow SPATIALDATA_WRITE_META_MERGE { SPATIALDATA_WRITE_RAW_BUNDLE ( ch_bundle_path, 'spatialdata_raw', - ch_segmented_object + ch_segmented_object, + ch_coordinate_space ) ch_versions = ch_versions.mix ( SPATIALDATA_WRITE_RAW_BUNDLE.out.versions ) @@ -65,7 +68,8 @@ workflow SPATIALDATA_WRITE_META_MERGE { SPATIALDATA_WRITE_REDEFINED_BUNDLE ( ch_redefined_bundle, 'spatialdata_redefined', - ch_segmented_object + ch_segmented_object, + ch_coordinate_space ) ch_versions = ch_versions.mix ( SPATIALDATA_WRITE_REDEFINED_BUNDLE.out.versions ) diff --git a/subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf b/subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf index 7e696a89..69cc615b 100644 --- a/subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf +++ b/subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf @@ -67,7 +67,7 @@ workflow PIPELINE_INITIALISATION { // Custom validation for pipeline parameters // validateInputParameters() - log.info "INFO Input params validated ✅ " + log.info "INFO Pipeline parameters validated ✅ " // // Create channel from input file provided through params.input @@ -81,7 +81,7 @@ workflow PIPELINE_INITIALISATION { } .set { ch_samplesheet } - log.info "INFO Samplesheet validated ✅ " + log.info "INFO Samplesheet fields validated ✅ " } catch (Exception e) { @@ -268,7 +268,7 @@ def validateXeniumBundle(ch_samplesheet) { } } } - log.info "INFO Xenium bundle validated ✅ \n" + log.info "INFO Xenium bundle validated ✅ \n" } // diff --git a/workflows/spatialxe.nf b/workflows/spatialxe.nf index e7e11069..45943cfe 100644 --- a/workflows/spatialxe.nf +++ b/workflows/spatialxe.nf @@ -64,6 +64,7 @@ workflow SPATIALXE { ch_versions = Channel.empty() ch_input = Channel.empty() + ch_space = Channel.empty() ch_bundle = Channel.empty() ch_config = Channel.empty() ch_features = Channel.empty() @@ -232,6 +233,7 @@ workflow SPATIALXE { ch_config ) ch_redefined_bundle = CELLPOSE_BAYSOR_IMPORT_SEGMENTATION.out.redefined_bundle + ch_space = CELLPOSE_BAYSOR_IMPORT_SEGMENTATION.out.coordinate_space } // check it the provided method is part of the methods list @@ -295,6 +297,7 @@ workflow SPATIALXE { ch_transcripts_parquet ) ch_redefined_bundle = PROSEG_PRESET_PROSEG2BAYSOR.out.redefined_bundle + ch_space = PROSEG_PRESET_PROSEG2BAYSOR.out.coordinate_space } @@ -309,6 +312,7 @@ workflow SPATIALXE { ch_transcripts_parquet ) ch_redefined_bundle = PROSEG_PRESET_PROSEG2BAYSOR.out.redefined_bundle + ch_space = PROSEG_PRESET_PROSEG2BAYSOR.out.coordinate_space } @@ -362,7 +366,8 @@ workflow SPATIALXE { SPATIALDATA_WRITE_META_MERGE ( ch_bundle_path, - ch_redefined_bundle + ch_redefined_bundle, + ch_space ) } From afc1b4ccf0c6f5b39f5a74e5343ee87a638d7e70 Mon Sep 17 00:00:00 2001 From: Sameesh Kher Date: Wed, 27 Aug 2025 13:39:46 +0000 Subject: [PATCH 2/2] changes to handling spatialdata generation based on coordinate space --- modules/local/ficture/model/main.nf | 4 +- .../spatialdata/write/templates/write.py | 2 +- nextflow.config | 1 - .../main.nf | 5 +- .../baysor_run_transcripts_parquet/main.nf | 5 +- .../main.nf | 7 ++- .../local/segger_create_train_predict/main.nf | 12 +++-- .../utils_nfcore_spatialxe_pipeline/main.nf | 2 +- .../main.nf | 13 +++-- .../main.nf | 5 +- workflows/spatialxe.nf | 50 +++++++++++-------- 11 files changed, 67 insertions(+), 39 deletions(-) diff --git a/modules/local/ficture/model/main.nf b/modules/local/ficture/model/main.nf index 104ce844..61221f26 100644 --- a/modules/local/ficture/model/main.nf +++ b/modules/local/ficture/model/main.nf @@ -19,13 +19,13 @@ process FICTURE { script: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def features = features ? "--in-feature ${features}": "" + def features_list = features ? "--in-feature ${features}": "" """ ficture run_together \\ --in-tsv ${transcripts} \\ --in-minmax ${coordinate_minmax} \\ - ${features} \\ + ${features_list} \\ --out-dir results \\ --train-width 12,18 \\ --n-factor 6,12 \\ diff --git a/modules/local/spatialdata/write/templates/write.py b/modules/local/spatialdata/write/templates/write.py index 31f0f693..dd9e9d1e 100755 --- a/modules/local/spatialdata/write/templates/write.py +++ b/modules/local/spatialdata/write/templates/write.py @@ -35,7 +35,7 @@ def main(): else: cells_as_circles = False - # set variables based on the coordinate space + # set sd variables based on the coordinate space if ( coordinate_space == "pixels" ): cells_labels = True nucleus_labels = True diff --git a/nextflow.config b/nextflow.config index dee7c335..141ae759 100644 --- a/nextflow.config +++ b/nextflow.config @@ -270,7 +270,6 @@ dag { manifest { name = 'nf-core/spatialxe' - author = """Florian Heyl""" // The author field is deprecated from Nextflow version 24.10.0, use contributors instead contributors = [ [ name: 'Sameesh Kher', diff --git a/subworkflows/local/baysor_run_prior_segmentation_mask/main.nf b/subworkflows/local/baysor_run_prior_segmentation_mask/main.nf index ce2609a4..7ec34d97 100644 --- a/subworkflows/local/baysor_run_prior_segmentation_mask/main.nf +++ b/subworkflows/local/baysor_run_prior_segmentation_mask/main.nf @@ -27,6 +27,7 @@ workflow BAYSOR_RUN_PRIOR_SEGMENTATION_MASK { ch_htmls = Channel.empty() ch_redefined_bundle = Channel.empty() + ch_coordinate_space = Channel.value("microns") // filter transcripts.parquet based on thresholds if ( params.filter_transcripts ) { @@ -72,7 +73,7 @@ workflow BAYSOR_RUN_PRIOR_SEGMENTATION_MASK { [], ch_just_segmentation, ch_polygons2d, - "microns" + ch_coordinate_space ) ch_versions = ch_versions.mix( XENIUMRANGER_IMPORT_SEGMENTATION.out.versions ) @@ -84,6 +85,8 @@ workflow BAYSOR_RUN_PRIOR_SEGMENTATION_MASK { polygons2d = ch_polygons2d // channel: [ ["segmentation_polygons_2d.json"] ] htmls = ch_htmls // channel: [ ["*.html"] ] + coordinate_space = ch_coordinate_space // channel: [ "microns" ] + redefined_bundle = ch_redefined_bundle // channel: [ val(meta), "redefined-xenium-bundle" ] versions = ch_versions // channel: [ versions.yml ] diff --git a/subworkflows/local/baysor_run_transcripts_parquet/main.nf b/subworkflows/local/baysor_run_transcripts_parquet/main.nf index e7999d6a..09037892 100644 --- a/subworkflows/local/baysor_run_transcripts_parquet/main.nf +++ b/subworkflows/local/baysor_run_transcripts_parquet/main.nf @@ -28,6 +28,7 @@ workflow BAYSOR_RUN_TRANSCRIPTS_PARQUET { ch_htmls = Channel.empty() ch_redefined_bundle = Channel.empty() + ch_coordinate_space = Channel.value("microns") // generate splits @@ -102,7 +103,7 @@ workflow BAYSOR_RUN_TRANSCRIPTS_PARQUET { [], ch_segmentation_csv, ch_polygons2d, - "microns" + ch_coordinate_space ) ch_versions = ch_versions.mix( XENIUMRANGER_IMPORT_SEGMENTATION.out.versions ) @@ -114,6 +115,8 @@ workflow BAYSOR_RUN_TRANSCRIPTS_PARQUET { polygons2d = ch_polygons2d // channel: [ ["segmentation_polygons_2d.json"] ] htmls = ch_htmls // channel: [ ["*.html"] ] + coordinate_space = ch_coordinate_space // channel: [ ["microns"] ] + redefined_bundle = ch_redefined_bundle // channel: [ val(meta), "redefined-xenium-bundle" ] versions = ch_versions // channel: [ versions.yml ] diff --git a/subworkflows/local/cellpose_resolift_morphology_ome_tif/main.nf b/subworkflows/local/cellpose_resolift_morphology_ome_tif/main.nf index d8203039..b41bc334 100644 --- a/subworkflows/local/cellpose_resolift_morphology_ome_tif/main.nf +++ b/subworkflows/local/cellpose_resolift_morphology_ome_tif/main.nf @@ -24,6 +24,7 @@ workflow CELLPOSE_RESOLIFT_MORPHOLOGY_OME_TIF { ch_cellpose_nuclei_cells = Channel.empty() ch_cellpose_cells_flows = Channel.empty() ch_cellpose_nuclei_flows = Channel.empty() + ch_coordinate_space = Channel.value("pixels") cellpose_model = params.cellpose_model ? (Channel.fromPath(params.cellpose_model, checkIfExists: true)) : [] @@ -82,7 +83,7 @@ workflow CELLPOSE_RESOLIFT_MORPHOLOGY_OME_TIF { [], [], [], - "" + ch_coordinate_space ) ch_versions = ch_versions.mix( XENIUMRANGER_IMPORT_SEGMENTATION.out.versions ) @@ -95,7 +96,7 @@ workflow CELLPOSE_RESOLIFT_MORPHOLOGY_OME_TIF { ch_cellpose_cells_mask, [], [], - "" + ch_coordinate_space ) ch_versions = ch_versions.mix( XENIUMRANGER_IMPORT_SEGMENTATION.out.versions ) } @@ -109,6 +110,8 @@ workflow CELLPOSE_RESOLIFT_MORPHOLOGY_OME_TIF { nuclei_flows = ch_cellpose_nuclei_flows // channel: [ val(meta), [ "*flows.tif" ] ] nuclei_cells = ch_cellpose_nuclei_cells // channel: [ val(meta), [ "*seg.npy" ] ] + coordinate_space = ch_coordinate_space // channel: [ ["pixels"] ] + redefined_bundle = XENIUMRANGER_IMPORT_SEGMENTATION.out.bundle // channel: [ val(meta), ["redefined-xenium-bundle"] ] versions = ch_versions // channel: [ versions.yml ] diff --git a/subworkflows/local/segger_create_train_predict/main.nf b/subworkflows/local/segger_create_train_predict/main.nf index ad46ef81..bd80f66c 100644 --- a/subworkflows/local/segger_create_train_predict/main.nf +++ b/subworkflows/local/segger_create_train_predict/main.nf @@ -21,6 +21,7 @@ workflow SEGGER_CREATE_TRAIN_PREDICT { ch_versions = Channel.empty() ch_redefined_bundle = Channel.empty() ch_segger_transcripts = Channel.empty() + ch_coordinate_space = Channel.value("pixels") // create dataset SEGGER_CREATE_DATASET ( ch_basedir ) @@ -52,12 +53,13 @@ workflow SEGGER_CREATE_TRAIN_PREDICT { _meta, transcripts -> return [ transcripts ] } + // replace transcripts.parquet in xenium bundle - ch_updated_bundle = ch_bundle.map { fobj -> - if (fobj.name == 'transcripts.parquet') { + ch_updated_bundle = ch_bundle.map { fileobj -> + if (fileobj.name == 'transcripts.parquet') { ch_segger_transcripts.val } else { - fobj + fileobj } } @@ -70,7 +72,7 @@ workflow SEGGER_CREATE_TRAIN_PREDICT { [], [], [], - "pixel" + ch_coordinate_space ) ch_redefined_bundle = XENIUMRANGER_IMPORT_SEGMENTATION.out.bundle @@ -84,6 +86,8 @@ workflow SEGGER_CREATE_TRAIN_PREDICT { benchmarks = SEGGER_PREDICT.out.benchmarks // channel: [ val(meta), [ benchmarks ] ] segger_transcripts = ch_segger_transcripts // channel: [ [ transcripts.parquet ] ] + coordinate_space = ch_coordinate_space // channel: [ ["pixels"] ] + redefined_bundle = ch_redefined_bundle // channel: [ val(meta), ["redefined-xenium-bundle"] ] versions = ch_versions // channel: [ versions.yml ] diff --git a/subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf b/subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf index 69cc615b..7542b6fb 100644 --- a/subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf +++ b/subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf @@ -198,7 +198,7 @@ def validateInputParameters() { // check if segmentation mask is provided in image mode and baysor method if ( params.mode == 'image' && params.method == 'baysor' ) if (!params.segmentation_mask ) { - log.error "❌ Error: Missing segmentation mask with `--segmentation_mask` when pipeline is run in ${params.mode} and with the ${params.method}." + log.warn "⚠️ Missing segmentation mask with `--segmentation_mask` when pipeline is run in ${params.mode} and with the ${params.method}. Running in coordinate mode." } } diff --git a/subworkflows/local/xeniumranger_import_segmentation_redefine_bundle/main.nf b/subworkflows/local/xeniumranger_import_segmentation_redefine_bundle/main.nf index 461751ef..766e119e 100644 --- a/subworkflows/local/xeniumranger_import_segmentation_redefine_bundle/main.nf +++ b/subworkflows/local/xeniumranger_import_segmentation_redefine_bundle/main.nf @@ -17,13 +17,14 @@ workflow XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE { ch_versions = Channel.empty() ch_redefined_bundle = Channel.empty() + ch_coordinate_space = Channel.empty("pixels") cells = ch_bundle_path.map { _meta, bundle -> return [ bundle + "/cells.zarr.zip" ] } // scenario - 1 change nuclear expansion distance / create a nucleus-only count matrix(--expansion_distance=0) - if ( params.expansion_distance == 0 || params.expansion_distance != 5 ){ + if ( params.expansion_distance == 0 || params.expansion_distance != 5 ) { IMP_SEG_COUNT_MATRIX_EXP_DISTANCE ( ch_bundle_path, @@ -32,7 +33,7 @@ workflow XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE { [], [], [], - "pixel" + ch_coordinate_space ) ch_redefined_bundle = IMP_SEG_COUNT_MATRIX_EXP_DISTANCE.out.bundle @@ -49,7 +50,7 @@ workflow XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE { [], [], [], - "pixel" + ch_coordinate_space ) ch_redefined_bundle = IMP_SEG_POLYGON_GEOJSON_INPUT.out.bundle @@ -64,7 +65,7 @@ workflow XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE { params.qupath_polygons, [], [], - "pixel" + ch_coordinate_space ) ch_redefined_bundle = IMP_SEG_POLYGON_GEOJSON_INPUT.out.bundle @@ -86,7 +87,7 @@ workflow XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE { params.qupath_polygons, [], [], - "pixel" + ch_coordinate_space ) ch_redefined_bundle = IMP_SEG_TRANS_MATRIX_INPUT.out.bundle @@ -96,6 +97,8 @@ workflow XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE { emit: + coordinate_space = ch_coordinate_space // channel: [ ["pixels"] ] + redefined_bundle = ch_redefined_bundle // channel: [ val(meta), ["redefined-xenium-bundle"] ] versions = ch_versions // channel: [ versions.yml ] diff --git a/subworkflows/local/xeniumranger_resegment_morphology_ome_tif/main.nf b/subworkflows/local/xeniumranger_resegment_morphology_ome_tif/main.nf index 6907ff50..c41e8bdb 100644 --- a/subworkflows/local/xeniumranger_resegment_morphology_ome_tif/main.nf +++ b/subworkflows/local/xeniumranger_resegment_morphology_ome_tif/main.nf @@ -15,6 +15,7 @@ workflow XENIUMRANGER_RESEGMENT_MORPHOLOGY_OME_TIF { ch_versions = Channel.empty() ch_redefined_bundle = Channel.empty() + ch_coordinate_space = Channel.value("pixels") // run resegment with changed config values XENIUMRANGER_RESEGMENT ( ch_bundle_path ) @@ -36,7 +37,7 @@ workflow XENIUMRANGER_RESEGMENT_MORPHOLOGY_OME_TIF { [], [], [], - "pixels" + ch_coordinate_space ) ch_versions = ch_versions.mix( XENIUMRANGER_IMPORT_SEGMENTATION.out.versions ) @@ -49,6 +50,8 @@ workflow XENIUMRANGER_RESEGMENT_MORPHOLOGY_OME_TIF { emit: + coordinate_space = ch_coordinate_space // channel: [ ["pixels"] ] + redefined_bundle = ch_redefined_bundle // channel: [ val(meta), ["redefined-xenium-bundle"] ] versions = ch_versions // channel: [ versions.yml ] diff --git a/workflows/spatialxe.nf b/workflows/spatialxe.nf index 45943cfe..f914f98e 100644 --- a/workflows/spatialxe.nf +++ b/workflows/spatialxe.nf @@ -64,7 +64,6 @@ workflow SPATIALXE { ch_versions = Channel.empty() ch_input = Channel.empty() - ch_space = Channel.empty() ch_bundle = Channel.empty() ch_config = Channel.empty() ch_features = Channel.empty() @@ -74,6 +73,7 @@ workflow SPATIALXE { ch_multiqc_files = Channel.empty() ch_morphology_image = Channel.empty() ch_redefined_bundle = Channel.empty() + ch_coordinate_space = Channel.empty() ch_transcripts_parquet = Channel.empty() @@ -216,6 +216,23 @@ workflow SPATIALXE { ) } + + /* + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + SPATIALXE - XENIUMRANGER LAYER + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + // run only xeniumranger import segmentation with changes xr specific params + if ( params.mode == 'image' && params.xeniumranger_only ) { + + XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE ( + ch_bundle_path + ) + ch_redefined_bundle = XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE.out.redefined_bundle + ch_coordinate_space = XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE.out.coordinate_space + } + + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SPATIALXE - IMAGE-BASED SEGMENTATION LAYER @@ -233,7 +250,7 @@ workflow SPATIALXE { ch_config ) ch_redefined_bundle = CELLPOSE_BAYSOR_IMPORT_SEGMENTATION.out.redefined_bundle - ch_space = CELLPOSE_BAYSOR_IMPORT_SEGMENTATION.out.coordinate_space + ch_coordinate_space = CELLPOSE_BAYSOR_IMPORT_SEGMENTATION.out.coordinate_space } // check it the provided method is part of the methods list @@ -246,6 +263,7 @@ workflow SPATIALXE { ch_bundle_path ) ch_redefined_bundle = XENIUMRANGER_RESEGMENT_MORPHOLOGY_OME_TIF.out.redefined_bundle + ch_coordinate_space = XENIUMRANGER_RESEGMENT_MORPHOLOGY_OME_TIF.out.coordinate_space } // run baysor run with morphology_ome.tif @@ -267,6 +285,7 @@ workflow SPATIALXE { ) } ch_redefined_bundle = BAYSOR_RUN_PRIOR_SEGMENTATION_MASK.out.redefined_bundle + ch_coordinate_space = BAYSOR_RUN_PRIOR_SEGMENTATION_MASK.out.coordinate_space } // run cellpose on the morphology_ome.tif @@ -277,6 +296,7 @@ workflow SPATIALXE { ch_bundle_path ) ch_redefined_bundle = CELLPOSE_RESOLIFT_MORPHOLOGY_OME_TIF.out.redefined_bundle + ch_coordinate_space = CELLPOSE_RESOLIFT_MORPHOLOGY_OME_TIF.out.coordinate_space } } @@ -297,7 +317,7 @@ workflow SPATIALXE { ch_transcripts_parquet ) ch_redefined_bundle = PROSEG_PRESET_PROSEG2BAYSOR.out.redefined_bundle - ch_space = PROSEG_PRESET_PROSEG2BAYSOR.out.coordinate_space + ch_coordinate_space = PROSEG_PRESET_PROSEG2BAYSOR.out.coordinate_space } @@ -312,7 +332,7 @@ workflow SPATIALXE { ch_transcripts_parquet ) ch_redefined_bundle = PROSEG_PRESET_PROSEG2BAYSOR.out.redefined_bundle - ch_space = PROSEG_PRESET_PROSEG2BAYSOR.out.coordinate_space + ch_coordinate_space = PROSEG_PRESET_PROSEG2BAYSOR.out.coordinate_space } @@ -321,8 +341,11 @@ workflow SPATIALXE { SEGGER_CREATE_TRAIN_PREDICT ( ch_bundle_path, - ch_transcripts_parquet + ch_transcripts_parquet, + ch_bundle_path ) + ch_redefined_bundle = SEGGER_CREATE_TRAIN_PREDICT.out.redefined_bundle + ch_coordinate_space = SEGGER_CREATE_TRAIN_PREDICT.out.coordinate_space } @@ -335,25 +358,12 @@ workflow SPATIALXE { ch_config ) ch_redefined_bundle = BAYSOR_RUN_TRANSCRIPTS_PARQUET.out.redefined_bundle + ch_coordinate_space = BAYSOR_RUN_TRANSCRIPTS_PARQUET.out.coordinate_space } } } - /* - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - SPATIALXE - XENIUMRANGER LAYER - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ - // run only xeniumranger import segmentation with changes xr specific params - if ( params.xeniumranger_only ) { - - XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE ( - ch_bundle_path - ) - ch_redefined_bundle = XENIUMRANGER_IMPORT_SEGMENTATION_REDEFINE_BUNDLE.out.redefined_bundle - } - /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -367,7 +377,7 @@ workflow SPATIALXE { SPATIALDATA_WRITE_META_MERGE ( ch_bundle_path, ch_redefined_bundle, - ch_space + ch_coordinate_space ) }