Mercurial > repos > laurenmarazzi > netisce_test
comparison tools/myTools/bin/test-data/pipe.nf @ 1:7e5c71b2e71f draft default tip
Uploaded
author | laurenmarazzi |
---|---|
date | Wed, 22 Dec 2021 16:00:34 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:f24d4892aaed | 1:7e5c71b2e71f |
---|---|
1 #!/usr/bin/env nextflow | |
2 | |
3 params.expressions = "$baseDir/input_data/expressions.csv" | |
4 params.network = "$baseDir/input_data/network.sif" | |
5 params.samples = "$baseDir/input_data/samples.txt" | |
6 params.alpha = 0.9 | |
7 params.internal_control="$baseDir/input_data/internal_control.txt" | |
8 params.undesired = 'resistant' | |
9 params.desired = 'sensitive' | |
10 params.filter ="strict" | |
11 | |
12 | |
13 params.kmeans_min_val = 2 | |
14 params.kmeans_max_val = 10 | |
15 | |
16 | |
17 params.num_nodes = 4 // that have expression data | |
18 params.num_states = 1000 | |
19 | |
20 | |
21 params.mut = false | |
22 | |
23 process sfa_exp { | |
24 publishDir 'results', mode: 'copy', overwrite: true | |
25 input: | |
26 path "expressions.csv" from params.expressions | |
27 path "network.sif" from params.network | |
28 | |
29 output: | |
30 path 'attrs_exp.txt' into records_expattr | |
31 | |
32 script: | |
33 """ | |
34 SFA_exp_attr.py network.sif expressions.csv attrs_exp.txt | |
35 """ | |
36 } | |
37 | |
38 process get_exp_internal_control_nodes { | |
39 publishDir 'results', mode: 'copy', overwrite: true | |
40 | |
41 input: | |
42 path 'attrs_exp.txt' from records_expattr | |
43 path "internal_control.txt" from params.internal_control | |
44 | |
45 output: | |
46 path 'attrs_exp_internal_controls.txt' into records_exp_icns | |
47 | |
48 script: | |
49 """ | |
50 get_RONs.py attrs_exp.txt internal_control.txt | |
51 """ | |
52 | |
53 } | |
54 | |
55 | |
56 | |
57 process insilico_inits { | |
58 | |
59 output: | |
60 path 'init.txt' into records_insilicoinit | |
61 | |
62 script: | |
63 """ | |
64 generate_basal_states.py $params.num_states $params.num_nodes init.txt attr -1,0,1 | |
65 """ | |
66 } | |
67 process insilico { | |
68 publishDir 'results', mode: 'copy', overwrite: true | |
69 input: | |
70 path 'expressions.csv' from params.expressions | |
71 path 'network.sif' from params.network | |
72 path 'samples.txt' from params.samples | |
73 path 'init.txt' from records_insilicoinit | |
74 | |
75 output: | |
76 path 'attrs_insilico*' into records_insilico | |
77 | |
78 script: | |
79 | |
80 """ | |
81 SFA_insilico.py "network.sif" "expressions.csv" "samples.txt" init.txt $params.alpha | |
82 """ | |
83 } | |
84 | |
85 process getFVS { | |
86 publishDir 'results', mode: 'copy', overwrite: true | |
87 | |
88 input: | |
89 path 'network.sif' from params.network | |
90 | |
91 output: | |
92 path 'fvs.txt' into records_fvs | |
93 script: | |
94 """ | |
95 FVS_run.py network.sif | |
96 """ | |
97 } | |
98 process perturbation_inits { | |
99 publishDir 'results', mode: 'copy', overwrite: true | |
100 input: | |
101 path "fvs.txt" from records_fvs | |
102 // path 'fvs.txt' from records3a | |
103 | |
104 output: | |
105 path 'fvs_init.txt' into records_pert_inits | |
106 | |
107 | |
108 script: | |
109 """ | |
110 generate_perts.py fvs.txt fvs_init.txt pert -1,0,1 | |
111 """ | |
112 } | |
113 process sfa_perts { | |
114 publishDir 'results', mode: 'copy', overwrite: true | |
115 input: | |
116 path 'expressions.csv' from params.expressions | |
117 path 'network.sif' from params.network | |
118 path 'samples.txt' from params.samples | |
119 path "fvs.txt" from records_fvs | |
120 path 'fvs_init.txt' from records_pert_inits | |
121 | |
122 output: | |
123 path 'pert*' into records_perts | |
124 | |
125 script: | |
126 """ | |
127 SFA_virtscreen.py network.sif expressions.csv $params.undesired samples.txt fvs.txt fvs_init.txt $params.alpha | |
128 | |
129 """ | |
130 } | |
131 | |
132 process check_icns{ | |
133 publishDir 'results', mode: 'copy', overwrite: true | |
134 input: | |
135 path 'attrs_exp_internal_controls.txt' from records_exp_icns | |
136 path 'samples.txt' from params.samples | |
137 | |
138 output: | |
139 path 'internal_control_nodes_exp_attrs.pdf' into records_icn_check | |
140 | |
141 script: | |
142 """ | |
143 module load R/3.6.3 | |
144 icn_check1.R attrs_exp_internal_controls.txt samples.txt | |
145 """ | |
146 | |
147 } | |
148 | |
149 process kmeans_opt { | |
150 publishDir 'results', mode: 'copy', overwrite: true | |
151 | |
152 input: | |
153 path 'attrs_exp.txt' from records_expattr | |
154 path 'attrs_insilico*' from records_insilico | |
155 | |
156 output: | |
157 env ELBOW into records_elbow | |
158 env SILHOUETTE into records_silhouette | |
159 path '*.pdf' into records_silplots | |
160 path '*.png' into records_elbowplots | |
161 | |
162 shell: | |
163 """ | |
164 datasets=\$(ls -m attr* | sed 's/ //g') | |
165 echo \$datasets | |
166 export SILHOUETTE=\$(silhouette_metric.py \$datasets results/ $params.kmeans_max_val) | |
167 export ELBOW=\$(elbow_metric.py \$datasets results/ $params.kmeans_max_val) | |
168 """ | |
169 } | |
170 process kmeans { | |
171 // this one checks to see if clusters and phenotypes match up | |
172 publishDir 'results', mode: 'copy', overwrite: true | |
173 input: | |
174 val ELBOW from records_elbow | |
175 val SILHOUETTE from records_silhouette | |
176 path 'attrs_exp.txt' from records_expattr | |
177 path 'attrs_insilico*' from records_insilico | |
178 path 'samples.txt' from params.samples | |
179 | |
180 output: | |
181 path 'kmeans.txt' into records_kmeans | |
182 | |
183 script: | |
184 if (ELBOW==SILHOUETTE) | |
185 """ | |
186 datasets=\$(ls -m attr* | sed 's/ //g') | |
187 kmeans.py $ELBOW \$datasets | |
188 """ | |
189 | |
190 else if (ELBOW<SILHOUETTE) | |
191 """ | |
192 datasets=\$(ls -m attr* | sed 's/ //g') | |
193 kmeans.py $ELBOW \$datasets | |
194 """ | |
195 else if (SILHOUETTE<ELBOW) | |
196 """ | |
197 datasets=\$(ls -m attr* | sed 's/ //g') | |
198 kmeans.py $SILHOUETTE \$datasets | |
199 """ | |
200 | |
201 } | |
202 | |
203 process classification { | |
204 publishDir 'results', mode: 'copy', overwrite: true | |
205 input: | |
206 path 'kmeans.txt' from records_kmeans | |
207 path 'pert*' from records_perts | |
208 path 'samples.txt' from params.samples | |
209 path 'attrs_exp.txt' from records_expattr | |
210 path 'attrs_insilico*' from records_insilico | |
211 output: | |
212 path 'class_*' into records_classification | |
213 | |
214 script: | |
215 """ | |
216 export train=\$(ls -m attr* | sed 's/ //g') | |
217 for x in pert* | |
218 do | |
219 NB.py \$train \$x kmeans.txt | |
220 RF.py \$train \$x kmeans.txt | |
221 SVM.py \$train \$x kmeans.txt | |
222 done | |
223 """ | |
224 } | |
225 process consensus { | |
226 | |
227 publishDir 'results', mode: 'copy', overwrite: true | |
228 input: | |
229 path '*' from records_classification | |
230 path 'kmeans.txt' from records_kmeans | |
231 path 'samples.txt' from params.samples | |
232 | |
233 output: | |
234 path 'crit1perts.txt' into records_consensus | |
235 | |
236 script: | |
237 """ | |
238 datasets=\$(ls -m class_* | tr -d '[:space:]') | |
239 | |
240 export desired_sample=\$(grep $params.desired samples.txt | head -1 | sed 's/\t.*//') | |
241 export desired_cluster=\$(grep \$desired_sample kmeans.txt | head -1 | sed 's/.*\s//') | |
242 get_clusterconsensus.py \$datasets \$desired_cluster | |
243 """ | |
244 | |
245 } | |
246 | |
247 process internal_control_node_analysis { | |
248 publishDir 'results', mode: 'copy', overwrite: true | |
249 | |
250 input: | |
251 path 'pert*' from records_perts | |
252 path 'crit1perts.txt' from records_consensus | |
253 path "internal_control.txt" from params.internal_control | |
254 | |
255 output: | |
256 path '*_internal_controls.txt' into records_pert_icns | |
257 | |
258 script: | |
259 """ | |
260 for x in pert* | |
261 do | |
262 echo \$x | |
263 get_RONs_getperts.py \$x "internal_control.txt" 'crit1perts.txt' | |
264 done | |
265 """ | |
266 | |
267 } | |
268 | |
269 | |
270 process filtering_by_icn { | |
271 publishDir 'results', mode: 'copy', overwrite: true | |
272 | |
273 input: | |
274 path 'attrs_exp_internal_controls.txt' from records_exp_icns | |
275 path 'pert_logss*' from records_pert_icns | |
276 path 'samples.txt' from params.samples | |
277 | |
278 output: | |
279 path '*_filtered_perturbations.txt' into records_filtered_perts | |
280 | |
281 script: | |
282 """ | |
283 module load R/3.6.3 | |
284 for x in pert_logss* | |
285 do | |
286 crit2.R attrs_exp_internal_controls.txt samples.txt \$x $params.desired $params.undesired $params.filter | |
287 done | |
288 """ | |
289 | |
290 } | |
291 | |
292 process extract_perts { | |
293 publishDir 'results', mode: 'copy', overwrite: true | |
294 | |
295 input: | |
296 path 'fvs_init.txt' from records_pert_inits | |
297 path "fvs.txt" from records_fvs | |
298 path '*_filtered_perturbations.txt' from records_filtered_perts | |
299 | |
300 | |
301 output: | |
302 path 'extract_perts.txt' into records_extracted_perts | |
303 | |
304 script: | |
305 """ | |
306 for x in *_filtered_perturbations.txt | |
307 do | |
308 get_perts.py fvs_init.txt fvs.txt \$x | |
309 done | |
310 """ | |
311 | |
312 } | |
313 | |
314 process translate_perts { | |
315 publishDir 'results', mode: 'copy', overwrite: true | |
316 | |
317 input: | |
318 path 'extract_perts.txt' from records_extracted_perts | |
319 | |
320 | |
321 output: | |
322 path 'perts_translated.txt' into records_translated_perts | |
323 | |
324 script: | |
325 """ | |
326 module load R/3.6.3 | |
327 pertanalysis.R extract_perts.txt | |
328 """ | |
329 | |
330 } | |
331 | |
332 |