Skip to content

Commit

Permalink
Parameterized publishing of non-QC non-provenance files (#530)
Browse files Browse the repository at this point in the history
* Parameterized publishing of non-QC non-provenance files

* Added missing mode:

* Add qc-files:inherit feature

This allows the qc-files setting to "inherit" the value of the
publish_dir_mode pipeline param. inherit is now the default value.

---------

Co-authored-by: Jeremy Muhlich <[email protected]>
  • Loading branch information
ArtemSokolov and jmuhlich authored Dec 21, 2023
1 parent 049baed commit 9d0fb6f
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion config/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
workflow:
start-at: registration
stop-at: quantification
qc-files: copy
qc-files: inherit
tma: false
viz: false
background: false
Expand Down
8 changes: 4 additions & 4 deletions docs/parameters/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ workflow:
```

## `qc-files`
Whether QC files should be copied, moved or symbolically linked from work directories to the project directory
Whether QC files should be copied, moved, hard linked, or symbolically linked from work directories to the project directory. 'inherit' may be specified to use the value of the publish_dir_mode pipeline parameter.
{: .fs-4}
{: .fw-300}

* **Valid values:** `copy`, `move`, `symlink`
* **Default:** `copy`
* **Valid values:** `copy`, `move`, `link`, `symlink`, `inherit`
* **Default:** `inherit`
* **Example:**

``` yaml
Expand Down Expand Up @@ -229,4 +229,4 @@ workflow:
``` yaml
workflow:
background-method: backsub
```
```
6 changes: 5 additions & 1 deletion lib/mcmicro/Opts.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static def cleanParams(pars, mspecs) {

// Protected keywords
def keywords = ['in', 'cont-pfx', 'roadie', 'workflow',
'options', 'modules', 'params']
'options', 'modules', 'params', 'publish_dir_mode']

// Clean up the parameter list
// Separate workflow parameters from module options
Expand Down Expand Up @@ -198,6 +198,10 @@ static def parseParams(gp, fns, fnw) {
mcp.workflow.downstream.contains(it.name)
}

// Implement qc-files=inherit which sets qc-files to the value of
// publish_dir_mode.
if(mcp.workflow['qc-files'] == 'inherit') mcp.workflow['qc-files'] = gp.publish_dir_mode

mcp
}

Expand Down
4 changes: 2 additions & 2 deletions lib/worker.nf
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ process worker {
tag "${module.name}-${task.index}"

// Output files in the pre-configured output format (outfmt) and optional plots
publishDir "${pubDir}", mode: 'copy',
publishDir "${pubDir}", mode: "${params.publish_dir_mode}",
pattern: "$outfmt", saveAs: {fn -> fnOut != '' ? fnOut : fn}
publishDir "${pubDir}", mode: 'copy', pattern: 'plots/**'
publishDir "${pubDir}", mode: "${params.publish_dir_mode}", pattern: 'plots/**'

// QC
publishDir "${Flow.QC(params.in, module.name)}", mode: "${mcp.workflow['qc-files']}",
Expand Down
6 changes: 4 additions & 2 deletions modules/background.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ process backsub {
// Specify the project subdirectory for writing the outputs to
// The pattern: specification must match the output: files below
// Subdirectory: background
publishDir "${params.in}/background", mode: 'copy', pattern: "*.ome.tif"
publishDir "${params.in}/background", mode: 'copy', pattern:'markers_bs.csv'
publishDir "${params.in}/background", mode: "${params.publish_dir_mode}",
pattern: "*.ome.tif"
publishDir "${params.in}/background", mode: "${params.publish_dir_mode}",
pattern:'markers_bs.csv'

// Stores .command.sh and .command.log from the work directory
// to the project provenance
Expand Down
5 changes: 3 additions & 2 deletions modules/dearray.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ process coreograph {
container "${params.contPfx}${module.container}:${module.version}"

// Output -- publish masks only, images need to be pyramidized
publishDir "${params.in}/dearray", mode: 'copy', pattern: '**mask.tif'
publishDir "${params.in}/dearray", mode: "${params.publish_dir_mode}",
pattern: '**mask.tif'

// QC
publishDir "${Flow.QC(params.in, module.name)}",
Expand Down Expand Up @@ -46,7 +47,7 @@ workflow dearray {

// Pass the core images through palom to pyramidize them
inputs = coreograph.out.cores.flatten()
roadie('pyramidize', inputs, '', true, "${params.in}/dearray", 'copy')
roadie('pyramidize', inputs, '', true, "${params.in}/dearray", "${params.publish_dir_mode}")

emit:
cores = roadie.out
Expand Down
3 changes: 2 additions & 1 deletion modules/illumination.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ process illumination {
container "${params.contPfx}${module.container}:${module.version}"

// Output profiles
publishDir "${params.in}/illumination", mode: 'copy', pattern: '*.tif'
publishDir "${params.in}/illumination", mode: "${params.publish_dir_mode}",
pattern: '*.tif'

// Provenance
publishDir "${Flow.QC(params.in, 'provenance')}", mode: 'copy',
Expand Down
3 changes: 2 additions & 1 deletion modules/quantification.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ process mcquant {
container "${params.contPfx}${module.container}:${module.version}"

// Output
publishDir "${params.in}/quantification", mode: 'copy', pattern: '*.csv'
publishDir "${params.in}/quantification", mode: "${params.publish_dir_mode}",
pattern: '*.csv'

// Provenance
publishDir "${Flow.QC(params.in, 'provenance')}", mode: 'copy',
Expand Down
3 changes: 2 additions & 1 deletion modules/registration.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import mcmicro.*

process ashlar {
container "${params.contPfx}${module.container}:${module.version}"
publishDir "${params.in}/registration", mode: 'copy', pattern: '*.tif'
publishDir "${params.in}/registration", mode: "${params.publish_dir_mode}",
pattern: '*.tif'

// Provenance
publishDir "${Flow.QC(params.in, 'provenance')}", mode: 'copy',
Expand Down
4 changes: 2 additions & 2 deletions modules/segmentation.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process s3seg {
container "${params.contPfx}${module.container}:${module.version}"

// Output
publishDir "${pubDir}/$tag",
mode: 'copy', pattern: '*/*.ome.tif', saveAs: {f -> file(f).name}
publishDir "${pubDir}/$tag", mode: "${params.publish_dir_mode}",
pattern: '*/*.ome.tif', saveAs: {f -> file(f).name}

// QC
publishDir "${Flow.QC(params.in, '/s3seg/' + tag)}",
Expand Down
3 changes: 2 additions & 1 deletion modules/template.nf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ process snr {
// The pattern: specification must match the output: files below
// TODO: replace report with the desired output directory
// TODO: replace the pattern to match the output: clause below
publishDir "${params.in}/report", mode: 'copy', pattern: "*.html"
publishDir "${params.in}/report", mode: "${params.publish_dir_mode}",
pattern: "*.html"

// Stores .command.sh and .command.log from the work directory
// to the project provenance
Expand Down
4 changes: 1 addition & 3 deletions modules/viz.nf
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import mcmicro.*

include {roadie} from "$projectDir/roadie"

process autominerva {
container "${params.contPfx}${module.container}:${module.version}"

// Output
publishDir "${params.in}/viz", mode: 'copy', pattern: "$tag/**"
publishDir "${params.in}/viz", mode: "${params.publish_dir_mode}", pattern: "$tag/**"

// Provenance
publishDir "${Flow.QC(params.in, 'provenance')}", mode: 'copy',
Expand Down
3 changes: 3 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Execution environment for miscellaneous tasks
params.roadie = 'ghcr.io/labsyspharm/mcmicro:roadie-2023-10-25'

// The mode for transfering output between work and project directories
params.publish_dir_mode = 'copy'

// Platform-specific profiles
profiles {

Expand Down
10 changes: 6 additions & 4 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@
},
"qc-files": {
"type": "string",
"description": "Should QC files should be copied, moved or symbolically linked from work directories to the project directory",
"description": "Should QC files should be copied, moved, hard linked, or symbolically linked from work directories to the project directory. 'inherit' may be specified to use the value of the publish_dir_mode pipeline parameter.",
"enum": [
"copy",
"move",
"symlink"
"link",
"symlink",
"inherit",
],
"default": "copy"
"default": "inherit"
},
"segmentation-channel": {
"type": "string",
Expand Down Expand Up @@ -219,4 +221,4 @@
"$ref": "#/definitions/parameters_for_individual_modules"
}
]
}
}

0 comments on commit 9d0fb6f

Please sign in to comment.