Skip to content

Commit d999df9

Browse files
Update cellranger_mapping workflow to use fromState/toState (#610)
* Update cellranger_mapping workflow to use fromState/toState * Update CHANGELOG
1 parent b6ca0af commit d999df9

File tree

4 files changed

+57
-50
lines changed

4 files changed

+57
-50
lines changed

CHANGELOG.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
## BREAKING CHANGES
44

5-
This project now uses viash version 0.8.0 to build components and workflows. Moving to 0.8.0 involved the following changes:
5+
* This project now uses viash version 0.8.0 to build components and workflows. Moving to 0.8.0 involved the following changes:
66

7-
* Bump viash version to 0.8.0 (PR #598) in the project configuration.
7+
* Bump viash version to 0.8.0 (PR #598) in the project configuration.
8+
* The `concat` component had been deprecated and will be removed in a future release. It's functionality has been copied to the `concatenate_h5mu` component because the name is in conflict with the `concat` operator from nextflow (PR #598).
9+
* All pipelines no longer use the anonymous workflow. Instead, these workflows were given a name which was added to the viash config as the entrypoint to the pipeline (PR #598).
10+
* Removed the `workflows` folder and moved its contents to new locations (PR #605):
11+
1. The `resources_test_scripts` folder now resides in the root of the project.
12+
2. All workflows have been moved to the `src/workflows` folder.
13+
3. Adjust GitHub Actions to account for new workflow paths.
814

9-
* The `concat` component had been deprecated and will be removed in a future release. It's functionality has been copied to the `concatenate_h5mu` component because the name is in conflict with the `concat` operator from nextflow (PR #598).
10-
11-
* All pipelines no longer use the anonymous workflow. Instead, these workflows were given a name which was added to the viash config as the entrypoint to the pipeline (PR #598).
12-
13-
* Removed the `workflows` folder and moved its contents to new locations (PR #605):
14-
1. The `resources_test_scripts` folder now resides in the root of the project.
15-
2. All workflows have been moved to the `src/workflows` folder.
16-
3. Adjust GitHub Actions to account for new workflow paths.
15+
* Renamed `obsm_metrics` to `uns_metrics` for the `cellranger_mapping` workflow because the cellranger metrics are stored in `.uns` and not `.obsm` (PR #610).
1716

1817
## NEW FUNCTIONALITY
1918

@@ -25,6 +24,9 @@ This project now uses viash version 0.8.0 to build components and workflows. Mov
2524

2625
* Refactored `cellranger_multi` workflow to use `fromState` and `toState` functionality (PR #609).
2726

27+
* Refactored `cellranger_mapping` workflow to use `fromState` and `toState` functionality (PR #610).
28+
29+
2830
# openpipelines 0.12.0
2931

3032
## BREAKING CHANGES

src/workflows/ingestion/cellranger_mapping/config.vsh.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ functionality:
4545
description: "The output from Cell Ranger, converted to h5mu."
4646
required: true
4747
example: output.h5mu
48-
- name: "--obsm_metrics"
48+
- name: "--uns_metrics"
4949
type: string
50-
description: Name of the .obsm slot under which to QC metrics (if any).
50+
description: Name of the .uns slot under which to QC metrics (if any).
5151
default: "metrics_summary"
5252
- name: "--output_type"
5353
type: string

src/workflows/ingestion/cellranger_mapping/integration_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export NXF_VER=21.10.6
1212

1313
nextflow \
1414
run . \
15-
-main-script workflows/ingestion/cellranger_mapping/main.nf \
15+
-main-script src/workflows/ingestion/cellranger_mapping/main.nf \
1616
-entry test_wf \
1717
-resume \
1818
-profile docker,no_publish \
19-
-c workflows/utils/labels_ci.config \
19+
-c src/workflows/utils/labels_ci.config \
2020
-with-trace work/trace.txt

src/workflows/ingestion/cellranger_mapping/main.nf

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,54 +29,59 @@ workflow run_wf {
2929
output_ch = input_ch
3030
| preprocessInputs("config": config)
3131
// split params for downstream components
32-
| setWorkflowArguments(
33-
cellranger_count: [
32+
| cellranger_count.run(
33+
fromState: [
3434
"input": "input",
35+
"output": "output_raw",
3536
"expect_cells": "expect_cells",
3637
"chemistry": "chemistry",
3738
"secondary_analysis": "secondary_analysis",
3839
"generate_bam": "generate_bam",
39-
"include_introns": "include_introns"
40+
"include_introns": "include_introns",
41+
"reference": "reference"
4042
],
41-
from_10xh5_to_h5mu: [
42-
"output": "output_h5mu",
43-
"obsm_metrics": "obsm_metrics",
44-
"output_type": "output_type",
45-
]
43+
toState: [
44+
"input": "output",
45+
"output_raw": "output"
46+
],
47+
auto: [ publish: true ]
4648
)
47-
48-
| getWorkflowArguments(key: "cellranger_count")
49-
| cellranger_count.run(auto: [ publish: true ])
50-
| pmap {id, data ->
51-
def new_data = ["input": data.output]
52-
[id, new_data]
53-
}
5449
// split output dir into map
55-
| cellranger_count_split
50+
| cellranger_count_split.run(
51+
fromState: {id, state ->
52+
def stateMapping = [
53+
"input": state.input,
54+
]
55+
outputType = state.output_type == "raw" ? "raw_h5" : "filtered_h5"
56+
stateMapping += [outputType: "\$id.\$key.${outputType}.h5"]
57+
stateMapping += ["metrics_summary": "\$id.\$key.metrics_summary.csv"]
58+
return stateMapping
59+
},
60+
toState: {id, output, state ->
61+
def outputFile = state.output_type == "raw" ? output.raw_h5 : output.filtered_h5
62+
def newState = state + [ "input": outputFile ]
63+
return newState
64+
}
65+
)
5666
// convert to h5mu
57-
| pmap { id, output_data, other_args ->
58-
input_data = other_args.from_10xh5_to_h5mu.output_type == "filtered" ?
59-
output_data.filtered_h5 : output_data.raw_h5
60-
// combine new data for from_10xh5_to_h5mu
61-
new_data =
62-
[
63-
input: input_data,
64-
input_metrics_summary: output_data.metrics_summary
65-
] +
66-
other_args.from_10xh5_to_h5mu
67-
68-
// store output to fourth field to return as output
69-
[ id, new_data, other_args, output_data ]
70-
}
7167
| from_10xh5_to_h5mu.run(
68+
fromState: {id, state ->
69+
[
70+
"input": state.input,
71+
"output_compression": "gzip",
72+
"output": state.output_h5mu,
73+
"uns_metrics": state.uns_metrics,
74+
"input_metrics_summary": state.metrics_summary
75+
]
76+
},
77+
toState: { id, output, state ->
78+
[
79+
"output_raw": state.output_raw,
80+
"output_h5mu": output.output
81+
]
82+
},
7283
auto: [ publish: true ],
73-
args: [ output_compression: "gzip" ]
7484
)
75-
76-
// return output map
77-
| pmap { id, data, other_args, output_data ->
78-
[ id, output_data + [h5mu: data] ]
79-
}
8085

8186
emit:
8287
output_ch

0 commit comments

Comments
 (0)