|
a |
|
b/intelligenes/intelligenes.py |
|
|
1 |
import argparse |
|
|
2 |
import subprocess |
|
|
3 |
import pkg_resources |
|
|
4 |
|
|
|
5 |
def main(): |
|
|
6 |
parser = argparse.ArgumentParser() |
|
|
7 |
parser.add_argument('-i', '--cgit_file', required=True) |
|
|
8 |
parser.add_argument('-o', '--output_dir', required=True) |
|
|
9 |
|
|
|
10 |
parser.add_argument('--random_state', type=int, default=42) |
|
|
11 |
parser.add_argument('--test_size', type=float, default=0.3) |
|
|
12 |
parser.add_argument('--n_splits', type=int, default=5) |
|
|
13 |
|
|
|
14 |
parser.add_argument('--normalize', action='store_true') |
|
|
15 |
parser.add_argument('--no_rfe', action='store_true') |
|
|
16 |
parser.add_argument('--no_pearson', action='store_true') |
|
|
17 |
parser.add_argument('--no_chi2', action='store_true') |
|
|
18 |
parser.add_argument('--no_anova', action='store_true') |
|
|
19 |
|
|
|
20 |
parser.add_argument('--voting', type=str, default='soft') |
|
|
21 |
parser.add_argument('--no_rf', action='store_true') |
|
|
22 |
parser.add_argument('--no_svm', action='store_true') |
|
|
23 |
parser.add_argument('--no_xgb', action='store_true') |
|
|
24 |
parser.add_argument('--no_knn', action='store_true') |
|
|
25 |
parser.add_argument('--no_mlp', action='store_true') |
|
|
26 |
parser.add_argument('--tune', action='store_true') |
|
|
27 |
parser.add_argument('--no_igenes', action='store_true') |
|
|
28 |
parser.add_argument('--no_visualization', action='store_true') |
|
|
29 |
|
|
|
30 |
args = parser.parse_args() |
|
|
31 |
|
|
|
32 |
selection_path = pkg_resources.resource_filename('intelligenes', 'selection.py') |
|
|
33 |
selection_args = [ |
|
|
34 |
'python', selection_path, |
|
|
35 |
'-i', args.cgit_file, |
|
|
36 |
'-o', args.output_dir, |
|
|
37 |
'--random_state', str(args.random_state), |
|
|
38 |
'--test_size', str(args.test_size), |
|
|
39 |
] |
|
|
40 |
|
|
|
41 |
if args.normalize: |
|
|
42 |
selection_args.append('--normalize') |
|
|
43 |
if args.no_rfe: |
|
|
44 |
selection_args.append('--no_rfe') |
|
|
45 |
if args.no_pearson: |
|
|
46 |
selection_args.append('--no_pearson') |
|
|
47 |
if args.no_chi2: |
|
|
48 |
selection_args.append('--no_chi2') |
|
|
49 |
if args.no_anova: |
|
|
50 |
selection_args.append('--no_anova') |
|
|
51 |
|
|
|
52 |
selection = subprocess.run(selection_args, capture_output=True, text=True) |
|
|
53 |
print(selection.stdout) |
|
|
54 |
selection_output = selection.stdout.strip().split('\n') |
|
|
55 |
for line in selection_output: |
|
|
56 |
if line.startswith(" Selected Features:"): |
|
|
57 |
features_file = line.split(":")[1].strip() |
|
|
58 |
break |
|
|
59 |
|
|
|
60 |
classification_path = pkg_resources.resource_filename('intelligenes', 'classification.py') |
|
|
61 |
classification_args = [ |
|
|
62 |
'python', classification_path, |
|
|
63 |
'-i', args.cgit_file, |
|
|
64 |
'-f',features_file, |
|
|
65 |
'-o', args.output_dir, |
|
|
66 |
'--random_state', str(args.random_state), |
|
|
67 |
'--test_size', str(args.test_size), |
|
|
68 |
'--n_splits', str(args.n_splits), |
|
|
69 |
'--voting', args.voting, |
|
|
70 |
] |
|
|
71 |
|
|
|
72 |
if args.no_rf: |
|
|
73 |
classification_args.append('--no_rf') |
|
|
74 |
if args.no_svm: |
|
|
75 |
classification_args.append('--no_svm') |
|
|
76 |
if args.no_xgb: |
|
|
77 |
classification_args.append('--no_xgb') |
|
|
78 |
if args.no_knn: |
|
|
79 |
classification_args.append('--no_knn') |
|
|
80 |
if args.no_mlp: |
|
|
81 |
classification_args.append('--no_mlp') |
|
|
82 |
if args.tune: |
|
|
83 |
classification_args.append('--tune') |
|
|
84 |
if args.normalize: |
|
|
85 |
classification_args.append('--normalize') |
|
|
86 |
if args.no_igenes: |
|
|
87 |
classification_args.append('--no_igenes') |
|
|
88 |
if args.no_visualization: |
|
|
89 |
classification_args.append('--no_visualization') |
|
|
90 |
|
|
|
91 |
subprocess.check_call(classification_args) |
|
|
92 |
|
|
|
93 |
if __name__ == '__main__': |
|
|
94 |
main() |