Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Coreograph #49

Merged
merged 17 commits into from
Aug 12, 2024
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
9 changes: 9 additions & 0 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ process {
]
}

withName: "COREOGRAPH" {
ext.args = { "--downsampleFactor ${Math.round(Math.log(0.65 * 32 / params.pixel_size) / Math.log(2))}" }
publishDir = [
path: { "${params.outdir}/tma_dearray" },
mode: params.publish_dir_mode,
]

}

/*
withName: SCIMAP_MCMICRO {
containerOptions = '-e NUMBA_CACHE_DIR=/tmp'
Expand Down
12 changes: 12 additions & 0 deletions modules/nf-core/coreograph/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions modules/nf-core/coreograph/environment.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions modules/nf-core/coreograph/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions modules/nf-core/coreograph/meta.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ params {
input_sample = null
input_cycle = null
marker_sheet = null
tma_dearray = false
pixel_size = null
segmentation = 'mesmer'
cellpose_model = []

Expand Down
9 changes: 9 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"enum": ["basicpy"],
"description": "input that defines type of illumination correction to be performed"
},
"tma_dearray": {
"type": "boolean",
"description": "If the sample is a tissue microarray (TMA), set this to 'true' to generate a separate output for each tissue core for pipeline steps beginning with cell segmentation. This also tends to speed up processing and reduce RAM usage."
},
"segmentation": {
"type": "string",
"pattern": "^((cellpose|mesmer)?,?)*(?<!,)$",
Expand All @@ -74,6 +78,11 @@
"cellpose_model": {
"type": "string",
"description": "optional model file for cellpose segmentation"
},
"pixel_size": {
"type": "number",
"description": "Pixel width of input image data, in microns",
"help_text": "You must set this parameter when enabling TMA de-arraying with the `tma_dearray` parameter. This is required for the de-arraying module to correctly process the image."
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions subworkflows/local/utils_nfcore_mcmicro_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ def validateInputParameters() {
error "You can only provide a cellpose model if you have selected cellpose as one of your segmentation methods"
}

if (params.tma_dearray && !params.pixel_size) {
error "You must also provide the pixel_size parameter (image pixel width in microns) when enabling tma_dearray."
}
}

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,25 @@ nextflow_workflow {

},

test("Error on tma_dearray without pixel_size") {
when {
params {
input_cycle = "${projectDir}/assets/samplesheet-test.csv"
marker_sheet = "${projectDir}/assets/markers_1_sp.csv"
tma_dearray = true

}
workflow {
"""
input = [false, false, false, false, [], '$outputDir', params.input_cycle, [], params.marker_sheet]
"""
}
}
then {
assert workflow.failed
assert workflow.stdout*.contains("pixel_size").any()
}
},

]
}
41 changes: 41 additions & 0 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -523,5 +523,46 @@ nextflow_workflow {

},

test("cycle: no illumination correction, coreograph") {

when {
params {
segmentation = "mesmer"
tma_dearray = true
pixel_size = 0.7
}
workflow {
"""
input[0] = Channel.of(
[
[id:"TEST1", cycle_number:1, channel_count:4],
"https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/imaging/core_detection/single_core_dapi.tif",
RobJY marked this conversation as resolved.
Show resolved Hide resolved
[],
[],
],
)
input[1] = Channel.of(
[
[1,1,'DNA_6',[],[],[]],
],
)
"""
}
}

then {
assertAll (
{
assert snapshot (
path("$outputDir/registration/ashlar/TEST1.ome.tif"),
path("$outputDir/segmentation/deepcell_mesmer/mask_TEST1_1.tif"),
CsvUtils.summarizeCsv("$outputDir/quantification/mcquant/mesmer/1_mask_TEST1_1.csv"),
).match()
},
{ assert workflow.success }
)
}
},

]
}
27 changes: 27 additions & 0 deletions tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -452,5 +452,32 @@
"nextflow": "23.10.1"
},
"timestamp": "2024-04-22T15:59:42.197064018"
},
"cycle: no illumination correction, coreograph": {
"content": [
"TEST1.ome.tif:md5,755b8a7782f9c561bb9fd6bf5e19f798",
"mask_TEST1_1.tif:md5,525d07ef2a89a8323474ff3017737ac2",
{
"headers": [
"CellID",
"DNA_6",
"X_centroid",
"Y_centroid",
"Area",
"MajorAxisLength",
"MinorAxisLength",
"Eccentricity",
"Solidity",
"Extent",
"Orientation"
],
"rowCount": 4804
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-08-01T17:44:21.535294636"
}
}
14 changes: 13 additions & 1 deletion workflows/mcmicro.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include { BASICPY } from '../modules/nf-core/basicpy/main'
include { ASHLAR } from '../modules/nf-core/ashlar/main'
include { BACKSUB } from '../modules/nf-core/backsub/main'
include { CELLPOSE } from '../modules/nf-core/cellpose/main'
include { COREOGRAPH } from '../modules/nf-core/coreograph/main'
include { DEEPCELL_MESMER } from '../modules/nf-core/deepcell/mesmer/main'
include { MCQUANT } from '../modules/nf-core/mcquant/main'
include { SCIMAP_MCMICRO } from '../modules/nf-core/scimap/mcmicro/main'
Expand Down Expand Up @@ -88,6 +89,17 @@ workflow MCMICRO {
}
*/

// Run Coreograph
if (params.tma_dearray) {
COREOGRAPH(ASHLAR.out.tif)
COREOGRAPH.out.cores
.transpose()
RobJY marked this conversation as resolved.
Show resolved Hide resolved
.map { meta, img -> [[id: meta.id + '_' + img.fileName.toString().tokenize('.')[0]], img]}
.set { ch_segmentation_input }
} else {
ch_segmentation_input = ASHLAR.out.tif
}

// Run Segmentation

ch_masks = Channel.empty()
Expand Down Expand Up @@ -120,7 +132,7 @@ workflow MCMICRO {
}
.collectFile(name: 'markers.csv', sort: false, newLine: true)

ASHLAR.out.tif
ch_segmentation_input
.cross(ch_masks) { it[0]['id'] }
.map{ t_ashlar, t_mask -> [t_mask[0], t_ashlar[1], t_mask[1]] }
.combine(ch_mcquant_markers)
Expand Down