-
Notifications
You must be signed in to change notification settings - Fork 5
/
np2
executable file
·476 lines (423 loc) · 17.1 KB
/
np2
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
#!/bin/bash
# ========================================================================= #
# | **** USAGE OF NETPROPHET 2.1 **** | #
# ========================================================================= #
usage(){
cat << EOF
netprophet2.1 [options]
INPUT arguments:
--p_in_target : input file for list of target genes
--p_in_reg : input file for list of regulators
--p_in_sample : input file for list of sample (condition) ids
--p_in_expr_target : input file for expression of target genes (target x sample)
--p_in_net_de : input file for network of differential expression
--p_in_binding_event : input file for binding events |REGULATOR|TARGET|
NETPROPHET1 arguments:
--fname_net_np1 : name of generated network for netprophet1 (optional)
NETPROPHET2 arguments:
--fname_net_bart : name of generated network for bart (optional)
--fname_net_np2 : name of generated network for netprophet2 (optional)
--p_in_dbd_pids : path of folder for DBD_PIDS
--p_in_promoter : path of file for promoters
OUTPUT arguments:
--p_out_dir : path of output directory for results
SLURM arguments:
--p_out_logs : output director for log files (.out & .err) for slurm runs
EOF
}
# ========================================================================= #
# | **** END USAGE OF NETPROPHET 2.1 **** | #
# ========================================================================= #
# general input
data=""
seed=747
<<<<<<< HEAD
# LASSO
flag_microarray="ON"
lasso_nbr_fold=10
flag_global_shrinkage="OFF"
flag_local_shrinkage="ON"
# LASSO SLURM
lasso_slurm_mem=10GB
lasso_slurm_nodes=1
lasso_slurm_ntasks=10
# BART SLURM
bart_slurm_mem=20GB
bart_slurm_nodes=1
bart_slurm_ntasks=20
# PWM
=======
# lasso
flag_global_shrinkage="OFF"
flag_local_shrinkage="ON"
flag_microarray="MICROARRAY"
lasso_nbr_fold=10
# bart
bart_nbr_rmpi_slave=2
# pwm
>>>>>>> e78cf4fb5e7d9a5729830a717ed8451f16430db8
p_in_promoter="NONE"
# PWM SLURM
pwm_slurm_nodes=1
pwm_slurm_ntasks=10
# smoothing
p_in_dbd_pids="NONE"
# LOGISTICS
p_src_code="$(cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/"
# SLURM arguments
mail_type=FAIL
mail_user="NONE"
flag_slurm="OFF"
# SINGULARITY arguments
flag_singularity="ON"
p_singularity_img="NONE"
p_singularity_bindpath="NONE"
# initialize flags for specific components runs
flag_run_np1="OFF" # -n
flag_run_bart="OFF" # -b bart
flag_run_combine="OFF" # -c combine
flag_run_combine_np1bart_pwm="OFF" # -k combine
flag_run_pwm="OFF" # -m pwm
flag_run_all="ON" # -a to run all components
# ========================================================================= #
# | **** PARSE ARGUMENTS **** | #
# ========================================================================= #
while getopts ":hpnbvwcismkya-:" OPTION
do
case "${OPTION}" in
n)
flag_run_np1="ON"
flag_run_all="OFF"
;;
b)
flag_run_bart="ON"
flag_run_all="OFF"
;;
c)
flag_run_combine="ON"
flag_run_all="OFF"
;;
m)
flag_run_pwm="ON"
flag_run_all="OFF"
;;
k)
flag_run_combine_np1bart_pwm="ON"
flag_run_all="OFF"
;;
a)
flag_run_all="ON"
;;
h)
usage
exit 2
;;
-)
case "${OPTARG}" in
# Input general param
p_in_expr_target)
p_in_expr_target="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
p_in_expr_reg)
p_in_expr_reg="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
# LASSO
flag_global_shrinkage)
flag_global_shrinkage="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
flag_local_shrinkage)
flag_local_shrinkage="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
lasso_nbr_fold)
lasso_nbr_fold="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
flag_microarray)
flag_microarray="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
p_in_net_de)
p_in_net_de="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
p_in_binding_event)
p_in_binding_event="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
<<<<<<< HEAD
# LASSO SLURM
lasso_slurm_mem)
lasso_slurm_mem="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
lasso_slurm_nodes)
lasso_slurm_nodes="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
lasso_slurm_ntasks)
lasso_slurm_ntasks="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
# BART SLURM
bart_slurm_mem)
bart_slurm_mem="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
bart_slurm_nodes)
bart_slurm_nodes="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
bart_slurm_ntasks)
bart_slurm_ntasks="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
=======
# bart
bart_nbr_rmpi_slave)
bart_nbr_rmpi_slave="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
>>>>>>> e78cf4fb5e7d9a5729830a717ed8451f16430db8
# smoothing
p_in_dbd_pids)
p_in_dbd_pids="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
# PWM
p_in_promoter)
p_in_promoter="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
pwm_slurm_ntasks)
pwm_slurm_ntasks="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
pwm_slurm_nodes)
pwm_slurm_nodes="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
# Logistics
p_src_code)
p_src_code="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
seed)
seed="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
data)
data="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
# Output
p_out_dir)
p_out_dir="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
# SLURM
flag_slurm)
flag_slurm="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
mail_type)
mail_type="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
mail_user)
mail_user="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
p_out_dir_logs)
p_out_dir_logs="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
# Singularity
flag_singularity)
flag_singularity="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
p_singularity_img)
p_singularity_img="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
p_singularity_bindpath)
p_singularity_bindpath="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
;;
esac;;
esac
done
# ========================================================================= #
# | **** END PARSE ARGUMENTS **** | #
# ========================================================================= #
mkdir -p ${p_out_dir}
# ========================================================== #
# | **** Run NETPROPHET1 *** | #
# ========================================================== #
job_id_np1=1
if [ ${flag_run_np1} == "ON" ] || [ ${flag_run_all} == "ON" ]
then
cmd_run_np1=""
if [ ${flag_slurm} == "ON" ]
then
mkdir -p ${p_out_dir_logs}tmp/
cmd_run_np1+="sbatch \
-o ${p_out_dir_logs}build_np1_%J.out \
-e ${p_out_dir_logs}build_np1_%J.err \
-J ${data}_np1 \
--mail-type=${mail_type} \
--mail-user=${mail_user} \
-D ${p_out_dir_logs}tmp/ \
--nodes=1-${lasso_slurm_nodes} \
--ntasks=${lasso_slurm_ntasks} \
--mem=${lasso_slurm_mem} \
--cpus-per-task=3 "
fi
cmd_run_np1+="${p_src_code}src/build_np1/workflow/build_net_np1_and_smooth.sh \
--p_in_expr_target ${p_in_expr_target} \
--p_in_expr_reg ${p_in_expr_reg} \
--flag_global_shrinkage ${flag_global_shrinkage} \
--flag_local_shrinkage ${flag_local_shrinkage} \
--lasso_nbr_fold ${lasso_nbr_fold} \
--flag_microarray ${flag_microarray} \
--p_in_dbd_pids ${p_in_dbd_pids} \
--p_in_net_de ${p_in_net_de} \
--seed ${seed} \
--p_out_dir ${p_out_dir} \
--f_out_name_lasso net_lasso.tsv \
--f_out_name_np1 net_np1.tsv \
--f_out_name_np1_smoothed net_np1_smoothed.tsv \
--p_src_code ${p_src_code} \
--flag_slurm ${flag_slurm} \
--flag_singularity ${flag_singularity} \
--p_singularity_img ${p_singularity_img} \
--p_singularity_bindpath ${p_singularity_bindpath}"
echo "run NP1.."
job_id_np1=$(echo $(eval ${cmd_run_np1}) | awk '{split($0, a, " "); print a[4]}')
fi
# ========================================================== #
# | **** Run BART **** | #
# ========================================================== #
job_id_bart=1
if [ ${flag_run_bart} == "ON" ] || [ ${flag_run_all} == "ON" ]
then
cmd_run_bart=""
if [ ${flag_slurm} == "ON" ]; then
bart_nbr_rmpi_slave=20
mkdir -p ${p_out_dir_logs}tmp/
cmd_run_bart+="sbatch \
-o ${p_out_dir_logs}build_bart_%J.out \
-e ${p_out_dir_logs}build_bart_%J.err \
-J ${data}_bart \
--mail-type=${mail_type} \
--mail-user=${mail_user} \
<<<<<<< HEAD
--nodes=1-${bart_slurm_nodes} \
--ntasks=${bart_slurm_ntasks} \
=======
-n ${bart_nbr_rmpi_slave} \
-N 1 \
>>>>>>> e78cf4fb5e7d9a5729830a717ed8451f16430db8
-D ${p_out_dir_logs}tmp/ \
--mem=${bart_slurm_mem} "
fi
cmd_run_bart+="${p_src_code}src/build_bart/workflow/build_net_bart_and_smooth.sh \
--p_in_expr_target ${p_in_expr_target} \
--p_in_expr_reg ${p_in_expr_reg} \
--nbr_rmpi_slaves ${bart_slurm_ntasks} \
--p_in_dbd_pids ${p_in_dbd_pids} \
--seed ${seed} \
--p_out_dir ${p_out_dir} \
--f_out_name_bart net_bart.tsv \
--f_out_name_bart_smoothed net_bart_smoothed.tsv \
--bart_nbr_rmpi_slave ${bart_nbr_rmpi_slave} \
--p_src_code ${p_src_code} \
--flag_slurm ${flag_slurm} \
--flag_singularity ${flag_singularity} \
--p_singularity_img ${p_singularity_img} \
--p_singularity_bindpath ${p_singularity_bindpath}"
echo "run BART.."
job_id_bart=$(echo $(eval ${cmd_run_bart}) | awk '{split($0, a, " "); print a[4]}')
fi
# ========================================================== #
# | **** Combine NP1 & BART **** | #
# ========================================================== #
job_id_combine=1
if [ ${flag_run_combine} == "ON" ] || [ ${flag_run_all} == "ON" ]
then
if [ ${p_in_dbd_pids} != "NONE" ]; then
p_net_bart=${p_out_dir}net_bart_smoothed.tsv
p_net_np1=${p_out_dir}net_np1_smoothed.tsv
else
p_net_bart=${p_out_dir}net_bart.tsv
p_net_np1=${p_out_dir}net_np1.tsv
fi
# combine np1 & bart
cmd_run_combine=""
if [ ${flag_slurm} == "ON" ]; then
mkdir -p ${p_out_dir_logs}tmp/
cmd_run_combine+="sbatch \
-o ${p_out_dir_logs}combine_np1_bart_%J.out \
-e ${p_out_dir_logs}combine_np1_bart_%J.err \
--dependency=afterok:${job_id_np1}:${job_id_bart} \
-J ${data}_combine_np1_bart \
--mail-type=${mail_type} \
--mail-user=${mail_user} \
--mem=10GB "
fi
cmd_run_combine+="${p_src_code}src/combine_networks/wrapper/quantile_combine_networks.sh \
${p_net_np1} \
${p_net_bart} \
${p_out_dir}net_np1_bart.tsv \
${p_src_code} \
${flag_slurm} \
${flag_singularity} \
${p_singularity_img} \
${p_singularity_bindpath}"
echo "run combine NP1 & BART.."
job_id_combine=$(echo $(eval ${cmd_run_combine}) | awk '{split($0, a, " "); print a[4]}')
fi
# ========================================================== #
# | **** Run PWM **** | #
# ========================================================== #
job_id_pwm=1
if [ ${flag_run_pwm} == "ON" ] || [ ${flag_run_all} == "ON" ]
then
nbr_job_pwm=${nbr_job}
if [ ${flag_slurm} == "ON" ]; then
mkdir -p ${p_out_dir_logs}tmp/
nbr_job_pwm=40
cmd_run_pwm+="sbatch \
-o ${p_out_dir_logs}build_pwm_%J.out \
-e ${p_out_dir_logs}build_pwm_%J.err \
-J ${data}_pwm \
--mail-type=${mail_type} \
--mail-user=${mail_user} \
--nodes=1-${pwm_slurm_nodes} \
--ntasks=${pwm_slurm_ntasks} \
--cpus-per-task=2 \
-D ${p_out_dir_logs}tmp/ \
--dependency=afterok:${job_id_combine} "
fi
cmd_run_pwm+="${p_src_code}src/build_pwm/workflow/build_net_pwm.sh \
--p_in_net ${p_out_dir}net_np1_bart.tsv \
--p_in_promoter ${p_in_promoter} \
--p_out_dir ${p_out_dir} \
--f_out_name net_pwm.tsv \
--flag_slurm ${flag_slurm} \
--flag_singularity ${flag_singularity} \
--p_singularity_img ${p_singularity_img} \
--p_singularity_bindpath ${p_singularity_bindpath} \
--p_src_code ${p_src_code} \
--nbr_job ${nbr_job_pwm}"
echo "run PWM.."
job_id_pwm=$(echo $(eval ${cmd_run_pwm}) | awk '{split($0, a, " "); print a[4]}')
fi
job_id_combine=1
if [ ${flag_run_combine_np1bart_pwm} == "ON" ] || [ ${flag_run_all} == "ON" ]
then
# combine np1_bart & pwm
if [ -f ${p_out_dir}"net_pwm.tsv" ] || [ ${flag_run_pwm} == "ON" ] || [ ${flag_run_all} == "ON" ]
then
cmd_run_combine=""
if [ ${flag_slurm} == "ON" ]; then
mkdir -p ${p_out_dir_logs}tmp/
cmd_run_combine+="sbatch \
-o ${p_out_dir_logs}combine_np1bart_pwm_%J.out \
-e ${p_out_dir_logs}combine_np1bart_pwm_%J.err \
--dependency=afterok:${job_id_pwm} \
-J ${data}_combine_np1bart_pwm \
--mail-type=${mail_type} \
--mail-user=${mail_user} \
--mem=150GB "
fi
cmd_run_combine+="${p_src_code}src/combine_networks/workflow/combine_networks_and_smooth.sh \
--p_in_net_np1_bart ${p_out_dir}net_np1_bart.tsv \
--p_in_net_pwm ${p_out_dir}net_pwm.tsv \
--p_in_dbd_pids ${p_in_dbd_pids} \
--p_out_dir ${p_out_dir} \
--f_out_name_np2 net_np2.tsv \
--f_out_name_np2_smoothed net_np2_smoothed.tsv \
--p_src_code ${p_src_code} \
--flag_slurm ${flag_slurm} \
--flag_singularity ${flag_singularity} \
--p_singularity_img ${p_singularity_img} \
--p_singularity_bindpath ${p_singularity_bindpath}"
echo "run combine NP1_BART & PWM.."
job_id_combine=$(echo $(eval ${cmd_run_combine}) | awk '{split($0, a, " "); print a[4]}')
fi
fi