-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
210 lines (160 loc) · 4.07 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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
println \
"""
=================================
K I N C - P Y P I P E L I N E
=================================
Workflow Information:
---------------------
Launch Directory: ${workflow.launchDir}
Work Directory: ${workflow.workDir}
Config Files: ${workflow.configFiles}
Profiles: ${workflow.profile}
Execution Parameters:
---------------------
input:
n_samples: ${params.n_samples}
n_genes: ${params.n_genes}
n_classes: ${params.n_classes}
emx_file: ${params.emx_file}
output:
dir: ${params.output_dir}
similarity
clusmethod: ${params.similarity_clusmethod}
corrmethod: ${params.similarity_corrmethod}
threshold:
method: ${params.threshold_method}
plots:
dir: ${params.plots_dir}
"""
workflow {
// generate a synthetic dataset
emx_files = Channel.fromList([ params.emx_file ])
make_input(emx_files)
emx_files = make_input.out.emx_files
// compute similarity matrix
similarity(emx_files)
cmx_files = similarity.out.cmx_files
// compute similarity threshold
threshold(emx_files, cmx_files)
rmt_files = threshold.out.rmt_files
// extract co-expression network
extract(emx_files, cmx_files, rmt_files)
net_files = extract.out.net_files
// visualize pairwise scatter plots
make_plots(emx_files, net_files)
}
/**
* The make_input process generates an input expression matrix with
* random expression values.
*/
process make_input {
publishDir "${params.output_dir}", mode: "copy"
input:
val(emx_file)
output:
path(emx_file), emit: emx_files
script:
"""
make-input.py \
--n-samples ${params.n_samples} \
--n-genes ${params.n_genes} \
--n-classes ${params.n_classes} \
--dataset ${emx_file} \
--transpose
"""
}
/**
* The similiarity process computes a similarity matrix for the input emx file.
*/
process similarity {
publishDir "${params.output_dir}", mode: "copy"
input:
path(emx_file)
output:
path(params.cmx_file), emit: cmx_files
script:
"""
kinc-similarity.py \
--input ${emx_file} \
--output ${params.cmx_file} \
--clusmethod ${params.similarity_clusmethod} \
--corrmethod ${params.similarity_corrmethod} \
--minexpr=${params.similarity_minexpr} \
--minclus ${params.similarity_minclus} \
--maxclus ${params.similarity_maxclus} \
--criterion ${params.similarity_criterion} \
${params.similarity_preout ? "--preout" : ""} \
${params.similarity_postout ? "--postout" : ""} \
--mincorr ${params.similarity_mincorr} \
--maxcorr ${params.similarity_maxcorr}
"""
}
/**
* The threshold process takes the correlation matrix from similarity
* and attempts to find a suitable correlation threshold.
*/
process threshold {
publishDir "${params.output_dir}", mode: "copy"
input:
path(emx_file)
path(cmx_file)
output:
path(params.rmt_file), emit: rmt_files
script:
"""
NUM_GENES=`tail -n +1 ${emx_file} | wc -l`
kinc-threshold.py \
--input ${cmx_file} \
--n-genes \${NUM_GENES} \
--method ${params.threshold_method} \
--tstart ${params.threshold_tstart} \
--tstep ${params.threshold_tstep} \
--tstop ${params.threshold_tstop} \
&> ${params.rmt_file}
"""
}
/**
* The extract process takes the correlation matrix from similarity and
* extracts a network with a given threshold.
*/
process extract {
publishDir "${params.output_dir}", mode: "copy"
input:
path(emx_file)
path(cmx_file)
path(rmt_file)
output:
path(params.net_file), emit: net_files
script:
"""
THRESHOLD=`tail -n 1 ${rmt_file}`
kinc-extract.py \
--emx ${emx_file} \
--cmx ${cmx_file} \
--output ${params.net_file} \
--mincorr \${THRESHOLD}
"""
}
/**
* The make_plots process takes extracted network files and saves the
* pairwise scatter plots as a directory of images.
*/
process make_plots {
publishDir "${params.plots_dir}", mode: "copy"
input:
path(emx_file)
path(net_file)
output:
path("*.png")
script:
"""
make-plots.py \
--emx ${emx_file} \
--netlist ${net_file} \
--output-dir . \
--corrdist \
--pairwise
"""
}