Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/local/ficture/model/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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 \\
Expand Down
1 change: 1 addition & 0 deletions modules/local/spatialdata/write/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions modules/local/spatialdata/write/templates/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +33,19 @@ def main():
cells_labels=True
nucleus_labels=True
else:
cells_as_circles=False
cells_as_circles = False

# set sd 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" ):
Expand Down
1 change: 0 additions & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 )

Expand All @@ -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 ]
Expand Down
5 changes: 4 additions & 1 deletion subworkflows/local/baysor_run_transcripts_parquet/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 )

Expand All @@ -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 ]
Expand Down
17 changes: 13 additions & 4 deletions subworkflows/local/cellpose_baysor_import_segmentation/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ 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()
ch_cellpose_cells_cells = Channel.empty()
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)) : []

Expand Down Expand Up @@ -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 ]
Expand All @@ -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 )

Expand All @@ -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 ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) : []

Expand Down Expand Up @@ -82,7 +83,7 @@ workflow CELLPOSE_RESOLIFT_MORPHOLOGY_OME_TIF {
[],
[],
[],
""
ch_coordinate_space
)
ch_versions = ch_versions.mix( XENIUMRANGER_IMPORT_SEGMENTATION.out.versions )

Expand All @@ -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 )
}
Expand All @@ -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 ]
Expand Down
4 changes: 3 additions & 1 deletion subworkflows/local/proseg_preset_proseg2baysor/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand All @@ -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 )

Expand All @@ -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"] ]

Expand Down
12 changes: 8 additions & 4 deletions subworkflows/local/segger_create_train_predict/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
}
}

Expand All @@ -70,7 +72,7 @@ workflow SEGGER_CREATE_TRAIN_PREDICT {
[],
[],
[],
"pixel"
ch_coordinate_space
)
ch_redefined_bundle = XENIUMRANGER_IMPORT_SEGMENTATION.out.bundle

Expand All @@ -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 ]
Expand Down
10 changes: 7 additions & 3 deletions subworkflows/local/spatialdata_write_meta_merge/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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 )

Expand All @@ -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 )

Expand Down
8 changes: 4 additions & 4 deletions subworkflows/local/utils_nfcore_spatialxe_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -81,7 +81,7 @@ workflow PIPELINE_INITIALISATION {
}
.set { ch_samplesheet }

log.info "INFO Samplesheet validated ✅ "
log.info "INFO Samplesheet fields validated ✅ "

} catch (Exception e) {

Expand Down Expand Up @@ -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."
}

}
Expand Down Expand Up @@ -268,7 +268,7 @@ def validateXeniumBundle(ch_samplesheet) {
}
}
}
log.info "INFO Xenium bundle validated ✅ \n"
log.info "INFO Xenium bundle validated ✅ \n"
}

//
Expand Down
Loading