-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
64 lines (57 loc) · 2.02 KB
/
main.nf
File metadata and controls
64 lines (57 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
nextflow.enable.dsl=2
// Include subworkflows
include { PREPARE } from './subworkflows/prepare'
include { DECONVOLVE } from './subworkflows/deconvolve'
include { ASSESS } from './subworkflows/assess'
// Main workflow
workflow {
// Convert tool names to canonical case
def mapping = [
'bayesprism':'BayesPrism',
'dwls' :'DWLS',
'grood' :'GrooD',
'music' :'MuSiC',
'scaden' :'Scaden'
]
def toolsList = (params.tools instanceof List) ? params.tools : params.tools?.toString()?.split(/\s*,\s*/)?.findAll { it } ?: []
def displayTools = toolsList.collect { t ->
def s = t?.toString()?.trim()
if (!s) {
s
} else {
mapping.get(s.toLowerCase(), s)
}
}
def tools_str = displayTools.join(',')
// Log parameters
log.info """\
DECONVOLUTION BENCHMARKING PIPELINE
===================================
Input samplesheet : ${params.input}
Output directory : ${params.output_dir}
Tools to benchmark : ${tools_str}
""".stripIndent()
// Parse the samplesheet into a channel of jobs
def jobs_ch = Channel
.fromPath(params.input, checkIfExists: true)
.splitCsv(header:true)
.map { row ->
def bulkPath = file(row.bulk)
def scPath = file(row.sc_ref)
def hasTruth = (row.containsKey('truth') && row.truth)
def truthPath = hasTruth ? file(row.truth) : null
def truthBase = hasTruth ? truthPath.baseName : 'notruth'
[
tag : "${bulkPath.baseName}_${scPath.baseName}_${truthBase}",
bulk : bulkPath,
sc : scPath,
truth: truthPath
]
}
// Run preparation subworkflow
def prepared_ch = PREPARE(jobs_ch)
// Run deconvolution subworkflow
def predictions_ch = DECONVOLVE(prepared_ch)
// Run assessment subworkflow
ASSESS(predictions_ch, prepared_ch)
}