-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflex.nf
163 lines (136 loc) · 4.32 KB
/
flex.nf
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env nextflow
// Enable DSL 2 syntax
nextflow.enable.dsl = 2
// Format the multi config CSVs for each sample
process multi_config {
// Load the appropriate dependencies
label "python"
// Copy all output files to the folder specified by the user with --output
// in a subdirectory named 'config/'
publishDir "${params.output}/", mode: 'copy', overwrite: true
input:
// The samples CSV
path "samples.csv"
// The probe barcodes CSV
path "probe_barcodes.csv"
output:
// Capture any created configurations as outputs
path "configs/*.csv"
script:
// Run the code defined in templates/multi_config_flex.py
template "multi_config_flex.py"
}
// Define the process used to run cellranger multi
process cellranger_flex {
// Load the appropriate dependencies
label "cellranger"
// Copy all output files to the folder specified by the user with --output
publishDir "${params.output}/", mode: 'copy', overwrite: true
input:
// The run configuration is driven by a multi config CSV
path "config.csv"
// Stage the FASTQ folder (by symlink) in the working directory
path "FASTQ_DIR"
// Stage the reference transcriptome (by symlink) in the working directory
path "GEX_REF"
// Stage the probe set CSV reference file
path "cellranger_probe_set.csv"
output:
// Capture any created files as outputs
path "*"
script:
// Run the code defined in templates/flex.sh
template "flex.sh"
}
workflow {
log.info"""
Parameters:
output: ${params.output}
fastq_dir: ${params.fastq_dir}
transcriptome_dir: ${params.transcriptome_dir}
samples: ${params.samples}
probe_barcodes: ${params.probe_barcodes}
dryrun: ${params.dryrun}
cellranger_version: ${params.cellranger_version}
"""
// Check that the user specified the output parameter
if("${params.output}" == "false"){
error "Parameter 'output' must be specified"
}
// Check that the user specified the samples parameter
if("${params.samples}" == "false"){
error "Parameter 'samples' must be specified"
}
// Check that the user specified the probe_barcodes parameter
if("${params.probe_barcodes}" == "false"){
error "Parameter 'probe_barcodes' must be specified"
}
// Check that the user specified the fastq_dir parameter
if("${params.fastq_dir}" == "false"){
error "Parameter 'fastq_dir' must be specified"
}
// Check that the user specified the transcriptome_dir parameter
if("${params.transcriptome_dir}" == "false"){
error "Parameter 'transcriptome_dir' must be specified"
}
// Point to the FASTQ directory
fastq_dir = file(
"${params.fastq_dir}",
checkIfExists: true,
type: "dir",
glob: false
)
// Point to the reference transcriptome
transcriptome_dir = file(
"${params.transcriptome_dir}",
checkIfExists: true,
type: "dir",
glob: false
)
// Point to the probe set CSV
probe_set = file(
"${params.probe_set}",
checkIfExists: true,
type: "dir",
glob: false
)
// Point to the samples CSV provided by the user
samples = file(
"${params.samples}",
checkIfExists: true,
type: "file",
glob: false
)
// Point to the probe barcodes CSV provided by the user
probe_barcodes = file(
"${params.probe_barcodes}",
checkIfExists: true,
type: "file",
glob: false
)
// Build the multi config CSV for each sample
multi_config(samples, probe_barcodes)
// If the user has not set the `dryrun` parameter
if("${params.dryrun}" == "false"){
// Analyze each sample independently
cellranger_flex(
multi_config.out,
fastq_dir,
transcriptome_dir,
probe_set
)
}else{
// Log the location of all output configs
multi_config
.out
.map { it -> it.name }
.toSortedList()
.view {
"""
Multi config CSVs have been written to:
"${params.output}/"
${it}
"""
}
}
}