forked from varnivey/ipanda
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ipanda.py
executable file
·78 lines (51 loc) · 1.84 KB
/
ipanda.py
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
### This file is a part of iPANDA package
### (in silico Pathway Activation Network Decomposition Analysis)
### The package is distributed under iPANDA license
### Version 0.0.1
###
### Copyright © 2016 Insilico Medicine Inc.
###
### USA, Johns Hopkins University, ETC B301,
### 1101 East 33rd St. Baltimore, MD 21218
import PAS_calc as pc
import os
import optparse
parser = optparse.OptionParser()
parser.add_option('-i', dest='expr_file', help='Input file')
parser.add_option('-o', dest='outfile', help='Outfile')
parser.add_option('-p', dest='pw_dir', help='Pathway_set')
(options, args) = parser.parse_args()
if options.pw_dir == None:
parser.print_help()
exit()
if options.outfile == None:
parser.print_help()
exit()
if options.expr_file == None:
parser.print_help()
exit()
pw_dir = options.pw_dir
gene_list_file = os.path.join(pw_dir,'gene_list.txt')
modules_file = os.path.join(pw_dir,'modules.txt')
pathway_contents = os.path.join(pw_dir,'pathway_contents.txt')
pathway_file = os.path.join(pw_dir,'pathway_list.txt')
calc_alg = 'oncofinder_like'
gene_file = os.path.join(pw_dir,'pathway_contents.txt')
arr_file = os.path.join(pw_dir,'pathway_akk.txt')
expr_file=options.expr_file
outfile=options.outfile
a = pc.expr_data()
a.calculate_CNRs_from_expr_file(expr_file,delimiter='\t',remove_quotes=True)
a.take_genes_from_list_only(gene_list_file)
a.filter_CNRs_by_ttest_continious()
a.calc_CNRs_for_modules(modules_file)
b = pc.PAS_calculation(pathway_file,pathway_contents)
gene_dict = b.get_pw_vals_dict(gene_file)
arr_dict = b.get_pw_vals_dict( arr_file)
arr_alg = 'original'
arr_alg_args = {'gene_dict':gene_dict,'arr_dict':arr_dict}
pas_alg_args = {'ARR_alg':arr_alg,'ARR_alg_args':arr_alg_args,
'normalize':True}
b.write_PAS_to_file(a,outfile,calc_alg,pas_alg_args)