Skip to content
Closed
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
2 changes: 1 addition & 1 deletion _viash.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
viash_version: 0.7.5
viash_version: 0.8.0

source: src
target: target
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
functionality:
name: demux
namespace: ingestion
namespace: workflows/ingestion
description: |
Convert `.bcl` files to `.fastq` files using bcl2fastq, bcl-convert or Cell Ranger mkfastq.
info:
Expand All @@ -24,13 +24,11 @@ functionality:
description: ID of the sample.
example: foo
- name: "--input"
alternatives: [ "-i" ]
type: file
required: true
description: Input run directory
example: bcl_dir
- name: "--sample_sheet"
alternatives: [ "-s" ]
type: file
required: true
description: Pointer to the sample sheet
Expand All @@ -43,11 +41,38 @@ functionality:
- name: "--ignore_missing"
type: boolean
description: Should the demultiplexer ignore missing entities (filter, ...)
- name: "--output_fastq"
type: file
direction: output
required: true
description: Output directory containig fastq files
example: fastq_dir
- name: "--output_fastqc"
type: file
direction: output
required: false
description: Reports directory produced by FastQC
example: reports_dir
- name: "--output_multiqc"
type: file
direction: output
required: false
description: Reports directory produced by MultiQC
example: reports_dir
resources:
- type: nextflow_script
path: main.nf
entrypoint: run_wf
test_resources:
- type: nextflow_script
path: main.nf
path: test.nf
entrypoint: test_wf
- path: /resources_test/cellranger_tiny_bcl
dependencies:
- name: demux/cellranger_mkfastq
- name: demux/bcl_convert
- name: demux/bcl2fastq
- name: qc/fastqc
- name: qc/multiqc
platforms:
- type: nextflow
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export NXF_VER=21.10.6

nextflow \
run . \
-main-script workflows/ingestion/demux/main.nf \
-main-script src/workflows/ingestion/demux/test.nf \
-entry test_wf \
-resume \
-profile docker,no_publish \
Expand Down
60 changes: 60 additions & 0 deletions src/workflows/ingestion/demux/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
workflow run_wf {
take:
input_ch

main:
output_ch = input_ch

// translate the demultiplexer argument to the component name that needs to be run
| map { id, state ->
def funcNameMapper = [
bclconvert: "bcl_convert",
bcl2fastq: "bcl2fastq",
mkfastq: "cellranger_mkfastq"
]
def funcName = funcNameMapper[state.demultiplexer]
def newState = state + [funcName: funcName]
[id, newState]
}

// run the demultiplexers
| runComponents(
components: [cellranger_mkfastq, bcl_convert, bcl2fastq],
filter: { id, state, config ->
state.funcName == config.functionality.name
},
fromState: { id, state, config ->
def data = [
input: state.input,
sample_sheet: state.sample_sheet,
reports: null // disable reports so they end up in the output dir
]
if (config.functionality.name == "bcl2fastq") {
data.ignore_missing = state.ignore_missing
}
data
},
toState: ["output_fastq": "output"]
)

// run fastqc
| fastqc.run(
fromState: ["input": "output_fastq"],
args: [mode: "dir"],
toState: ["output_fastqc": "output"]
)

// run multiqc
| multiqc.run(
fromState: { id, state ->
["input": [state.output_fastq]]
},
toState: ["output_multiqc": "output"]
)

// subset state to the outputs
| setState(["output_fastq", "output_fastqc", "output_multiqc"])

emit:
output_ch
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ manifest {
}

params {
rootDir = java.nio.file.Paths.get("$projectDir/../../../").toAbsolutePath().normalize().toString()
rootDir = java.nio.file.Paths.get("$projectDir/../../../../").toAbsolutePath().normalize().toString()
}

// include common settings
Expand Down
57 changes: 57 additions & 0 deletions src/workflows/ingestion/demux/test.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
nextflow.enable.dsl=2

// TODO: once viash supports 'viash test' on this workflow,
// - the import will be added automatically
// - access the test resources with `meta.resources_dir' instead of `params.resources_test'

include { demux } from params.rootDir + "/target/nextflow/workflows/ingestion/demux/main.nf"

workflow test_wf {
// TODO: change this to `resources_test = meta.resources_dir`
resources_test = file("${params.rootDir}/resources_test")

// or when running from s3:
Channel.fromList([
[
id: "mkfastq_test",
input: resources_test.resolve("cellranger_tiny_bcl/bcl"),
sample_sheet: resources_test.resolve("cellranger_tiny_bcl/bcl/sample_sheet.csv"),
demultiplexer: "mkfastq"
],
[
id: "bclconvert_test",
input: resources_test.resolve("cellranger_tiny_bcl/bcl2/"),
sample_sheet: resources_test.resolve("cellranger_tiny_bcl/bcl2/sample_sheet.csv"),
demultiplexer: "bclconvert"
],
[
id: "bcl2fastq_test",
input: resources_test.resolve("cellranger_tiny_bcl/bcl"),
sample_sheet: resources_test.resolve("cellranger_tiny_bcl/bcl/sample_sheet.csv"),
demultiplexer: "bcl2fastq",
ignore_missing: true
]
])
| map{ state -> [state.id, state] }
| demux
| view { output ->
assert output.size() == 2 : "outputs should contain two elements; [id, state]"

def id = output[0]
assert id.contains("_test")

def state = output[1]
assert state.containsKey("output_fastq") : "State should contain output_fastq"
assert state.output_fastq.isDirectory() : "output_fastq should be a directory."
assert state.containsKey("output_fastqc") : "State should contain output_fastqc"
assert state.output_fastqc.isDirectory() : "output_fastqc should be a directory."
assert state.containsKey("output_multiqc") : "State should contain output_multiqc"
assert state.output_multiqc.isDirectory() : "output_multiqc should be a directory."

"Output: $output"
}
| toSortedList()
| map { output_list ->
assert output_list.size() == 3 : "There should be three outputs"
}
}
125 changes: 0 additions & 125 deletions workflows/ingestion/demux/main.nf

This file was deleted.