/
NETISCE.nf
executable file
·289 lines (217 loc) · 6.34 KB
/
NETISCE.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#!/usr/bin/env nextflow
params.expressions = "$baseDir/input_data/expression.csv"
params.network = "$baseDir/input_data/network.sif"
params.samples = "$baseDir/input_data/samples.txt"
params.internal_control="$baseDir/input_data/internal-marker-kinoshita.txt"
// params.internal_control="$baseDir/input_data/internal-marker-kinoshita-expanded.txt"
params.alpha = 0.9
params.undesired = 'EpiSC'
params.desired = 'ESC'
params.filter ="strict"
params.kmeans_max_val = 10
params.num_nodes = 23 // that have expression data
params.num_states = 10000
process sfa_exp {
input:
path "expressions.csv" from params.expressions
path "network.sif" from params.network
output:
path 'attrs_exp.txt' into records_expattr
script:
"""
SFA_exp_attr.py network.sif expressions.csv attrs_exp.txt
"""
}
process get_exp_internal_control_nodes {
publishDir 'results', mode: 'copy', overwrite: true
input:
path 'attrs_exp.txt' from records_expattr
path "internal-marker*" from params.internal_control
output:
path 'exp_internalmarkers.txt' into records_exp_icns
script:
"""
get_RONs.py attrs_exp.txt internal-marker*
"""
}
process insilico_inits {
output:
path 'init.txt' into records_insilicoinit
script:
"""
generate_basal_states.py $params.num_states $params.num_nodes init.txt attr -1,0,1
"""
}
process insilico {
input:
path 'expressions.csv' from params.expressions
path 'network.sif' from params.network
path 'samples.txt' from params.samples
path 'init.txt' from records_insilicoinit
output:
path 'attrs_insilico*' into records_insilico
script:
"""
SFA_insilico.py "network.sif" "expressions.csv" "samples.txt" init.txt $params.alpha
"""
}
process getFVS {
publishDir 'results', mode: 'copy', overwrite: true
input:
path 'network.sif' from params.network
output:
path 'fvs.txt' into records_fvs
script:
"""
FVS_run.py network.sif
"""
}
process perturbation_inits {
input:
path "fvs.txt" from records_fvs
// path 'fvs.txt' from records3a
output:
path 'fvs_init.txt' into records_pert_inits
script:
"""
generate_perts.py fvs.txt fvs_init.txt pert -1,0,1
"""
}
process sfa_perts {
input:
path 'expressions.csv' from params.expressions
path 'network.sif' from params.network
path 'samples.txt' from params.samples
path "fvs.txt" from records_fvs
path 'fvs_init.txt' from records_pert_inits
output:
path 'pert*' into records_perts
script:
"""
SFA_virtscreen.py network.sif expressions.csv $params.undesired samples.txt fvs.txt fvs_init.txt $params.alpha
"""
}
process check_icns{
publishDir 'results', mode: 'copy', overwrite: true
input:
path 'exp_internalmarkers.txt' from records_exp_icns
path 'samples.txt' from params.samples
output:
path 'experimental_internalmarkers.pdf' into records_icn_check
script:
"""
module load R/3.6.3
icn_check1.R exp_internalmarkers.txt samples.txt
"""
}
process kmeans {
publishDir 'results', mode: 'copy', overwrite: true
input:
path 'attrs_exp.txt' from records_expattr
path 'attrs_insilico*' from records_insilico
output:
path 'elbow.png' into records_elbowplots
path 'silhouette.png' into records_silplots
path 'kmeans.txt' into records_kmeans
script:
"""
datasets=\$(ls -m attr* | sed 's/ //g')
kmeans_full.py \$datasets $params.kmeans_max_val
"""
}
process classification {
input:
path 'kmeans.txt' from records_kmeans
path 'pert*' from records_perts
path 'samples.txt' from params.samples
path 'attrs_exp.txt' from records_expattr
path 'attrs_insilico*' from records_insilico
output:
path 'class_*' into records_classification
script:
"""
export train=\$(ls -m attr* | sed 's/ //g')
for x in pert*
do
NB.py \$train \$x kmeans.txt
RF.py \$train \$x kmeans.txt
SVM.py \$train \$x kmeans.txt
done
"""
}
process consensus {
publishDir 'results', mode: 'copy', overwrite: true
input:
path '*' from records_classification
path 'kmeans.txt' from records_kmeans
path 'samples.txt' from params.samples
output:
path 'crit1perts.txt' into records_consensus
script:
"""
datasets=\$(ls -m class_* | tr -d '[:space:]')
export desired_sample=\$(grep $params.desired samples.txt | head -1 | sed 's/\t.*//')
export desired_cluster=\$(grep \$desired_sample kmeans.txt | head -1 | sed 's/.*\s//')
get_clusterconsensus.py \$datasets \$desired_cluster
"""
}
process internal_control_node_analysis {
publishDir 'results', mode: 'copy', overwrite: true
input:
path 'pert*' from records_perts
path 'crit1perts.txt' from records_consensus
path "internal-marker*" from params.internal_control
output:
path '*_internal_markers.txt' into records_pert_icns
script:
"""
for x in pert*
do
echo \$x
get_RONs_getperts.py \$x internal-marker* 'crit1perts.txt'
done
"""
}
process filtering_by_icn {
input:
path 'exp_internalmarkers.txt' from records_exp_icns
path 'pert_logss*' from records_pert_icns
path 'samples.txt' from params.samples
output:
path '*_filtered_perturbations.txt' into records_filtered_perts
script:
"""
module load R/3.6.3
for x in pert_logss*
do
crit2.R exp_internalmarkers.txt samples.txt \$x $params.desired $params.undesired $params.filter
done
"""
}
process extract_perts {
input:
path 'fvs_init.txt' from records_pert_inits
path "fvs.txt" from records_fvs
path '*_filtered_perturbations.txt' from records_filtered_perts
output:
path 'extract_perts.txt' into records_extracted_perts
script:
"""
for x in *_filtered_perturbations.txt
do
get_perts.py fvs_init.txt fvs.txt \$x
done
"""
}
process translate_perts {
publishDir 'results', mode: 'copy', overwrite: true
input:
path 'extract_perts.txt' from records_extracted_perts
output:
path 'successful_controlnode_perturbations.txt' into records_translated_perts
script:
"""
module load R/3.6.3
pertanalysis.R extract_perts.txt
"""
}