forked from aertslab/SCENICprotocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
272 lines (224 loc) · 5.95 KB
/
main.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#!/usr/bin/env nextflow
println( "\n***")
println "Project name: $workflow.manifest.name"
println "Project dir : $workflow.projectDir"
println "Git info: $workflow.repository - $workflow.revision [$workflow.commitId]"
println "Cmd line: $workflow.commandLine"
println "Pipeline version: $workflow.manifest.version"
println( "***\nParameters in use:")
params.each { println "${it}" }
/*
* scenic channel setup
*/
// channel for SCENIC databases resources:
featherDB = Channel
.fromPath( params.db )
.collect() // use all files together in the ctx command
n = Channel.fromPath(params.db).count().get()
if( n==1 ) {
println( "***\nWARNING: only using a single feather database:\n ${featherDB.get()[0]}.\nTo include all database files using pattern matching, make sure the value for the '--db' parameter is enclosed in quotes!" )
} else {
println( "***\nUsing $n feather databases:")
featherDB.get().each {
println " ${it}"
}
}
println( "***\n")
// expr = file(params.expr)
tfs = file(params.TFs)
motifs = file(params.motifs)
/*
* basic filtering
*/
process filter {
cache 'deep'
container params.pyscenic_container
input:
file loomUnfiltered from file( params.loom_input )
output:
file params.loom_filtered into expr
file 'anndata.h5ad' into SCfilter
"""
filtering-basic.py \
--loom_input ${loomUnfiltered} \
--loom_filtered ${params.loom_filtered} \
--thr_min_genes ${params.thr_min_genes} \
--thr_min_cells ${params.thr_min_cells} \
--thr_n_genes ${params.thr_n_genes} \
--thr_pct_mito ${params.thr_pct_mito}
"""
}
expr.last().collectFile(storeDir:params.outdir)
/*
* end of basic filtering
*/
/*
* preprocess, visualize, project, cluster processing steps
*/
process preprocess {
cache 'deep'
container params.pyscenic_container
input:
file 'anndata.h5ad' from SCfilter
output:
file 'anndata.h5ad' into SCpreprocess
"""
preprocess_visualize_project_scanpy.py \
preprocess \
--loom_filtered ${params.loom_filtered} \
--anndata anndata.h5ad \
--threads ${params.threads}
"""
}
process pca {
cache 'deep'
container params.pyscenic_container
input:
file 'anndata.h5ad' from SCpreprocess
output:
file 'anndata.h5ad' into SCpca
"""
preprocess_visualize_project_scanpy.py \
pca \
--anndata anndata.h5ad \
--threads ${params.threads}
"""
}
process visualize {
cache 'deep'
container params.pyscenic_container
input:
file 'anndata.h5ad' from SCpca
output:
file 'anndata.h5ad' into SCvisualize
"""
preprocess_visualize_project_scanpy.py \
visualize \
--anndata anndata.h5ad \
--threads ${params.threads}
"""
}
process cluster {
cache 'deep'
container params.pyscenic_container
input:
file 'anndata.h5ad' from SCvisualize
output:
file 'anndata.h5ad' into SCcluster
"""
preprocess_visualize_project_scanpy.py \
cluster \
--anndata anndata.h5ad \
--threads ${params.threads}
"""
}
/*
* End of preprocess, visualize, project, cluster processing steps
*/
/*
* SCENIC steps
*/
process GRNinference {
cache 'deep'
container params.pyscenic_container
input:
file TFs from tfs
file params.loom_filtered from expr
// file exprMat from expr
output:
file 'adj.tsv' into GRN
"""
arboreto_with_multiprocessing.py \
${params.loom_filtered} \
${TFs} \
--method ${params.grn} \
--num_workers ${params.threads} \
-o adj.tsv \
${(params.containsKey('sparse')) ? '--sparse' : ''} \
${(params.containsKey('seed')) ? "--seed ${params.seed}" : ""} \
--cell_id_attribute ${params.cell_id_attribute} \
--gene_attribute ${params.gene_attribute} \
"""
}
process cisTarget {
cache 'deep'
container params.pyscenic_container
input:
file exprMat from expr
file 'adj.tsv' from GRN
file feather from featherDB
file motif from motifs
output:
file 'reg.csv' into regulons
"""
pyscenic ctx \
adj.tsv \
${feather} \
--annotations_fname ${motif} \
--expression_mtx_fname ${exprMat} \
--cell_id_attribute ${params.cell_id_attribute} \
--gene_attribute ${params.gene_attribute} \
--mode "dask_multiprocessing" \
--output reg.csv \
--num_workers ${params.threads} \
"""
}
process AUCell {
cache 'deep'
container params.pyscenic_container
input:
file exprMat from expr
file 'reg.csv' from regulons
output:
file params.pyscenic_output into scenicAUC1, scenicAUC2
"""
pyscenic aucell \
$exprMat \
reg.csv \
-o ${params.pyscenic_output} \
--cell_id_attribute ${params.cell_id_attribute} \
--gene_attribute ${params.gene_attribute} \
--num_workers ${params.threads}
"""
}
process visualizeAUC {
cache 'deep'
container params.pyscenic_container
input:
file params.pyscenic_output from scenicAUC1
output:
file 'scenic_umap.txt' into aucDRumap
file 'scenic_tsne.txt' into aucDRtsne
"""
preprocess_visualize_project_scanpy.py \
visualizeAUC \
--loom_pyscenic ${params.pyscenic_output} \
"""
}
/*
* end of SCENIC steps
*/
/*
* results integration
*/
process integrateOutput {
cache 'deep'
container params.pyscenic_container
input:
file params.pyscenic_output from scenicAUC2
file 'anndata.h5ad' from SCcluster
file 'scenic_umap.txt' from aucDRumap
file 'scenic_tsne.txt' from aucDRtsne
output:
file params.loom_output into finalLoom
"""
integrateOutput.py \
--anndata anndata.h5ad \
--loom_pyscenic ${params.pyscenic_output} \
--loom_output ${params.loom_output} \
"""
}
finalLoom.last().collectFile(storeDir:params.outdir)
/*
* end of results integration
*/