-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRMSE-Milnes-selection-n1.py
executable file
·70 lines (57 loc) · 2.41 KB
/
RMSE-Milnes-selection-n1.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
#!/usr/bin/env python3
import sys
sys.path.append('..')
import argparse
import numpy as np
path2fitsfda = '../data/Milnes-data-fits'
path2fits = '../data/Milnes-data-fits-fix_hill'
path2data = '../data/Raw-Milnes-data'
drugs = ['astemizole', 'azimilide', 'bepridil', 'chlorpromazine', 'cisapride', 'clarithromycin', 'clozapine', \
'diltiazem', 'disopyramide', 'dofetilide', 'domperidone', 'droperidol', 'ibutilide', 'loratadine', \
'metoprolol', 'mexiletine', 'nifedipine', 'nitrendipine', 'ondansetron', 'pimozide', 'quinidine', \
'ranolazine', 'risperidone', 'sotalol', 'tamoxifen', 'terfenadine', 'vandetanib', 'verapamil']
# Check input arguments
parser = argparse.ArgumentParser(
description='Select plausible models with experimental data')
parser.add_argument("--n_samples", type=int, help="Number of Bootstrap samples to use", \
default=1000)
args = parser.parse_args()
base_models = ['lei', 'li']
base_models_prefix = ['', 'li-']
models = ['0a', '0b', 1, 2, '2i', 3, 4, 5, '5i', 6, 7, 8, 9, 10, 11, 12, 13]
#func = lambda x, y: x + (x - y) * .7
func = lambda x, y: 1.2 * x
exclude_model_list_template = lambda x, y: [f'{x}m{i}' for i in y]
excluded_list = {}
for b in base_models:
excluded_list[b] = {}
for drug in drugs:
RMSEs = {}
for b in base_models:
RMSEs[b] = {}
for i, m in enumerate(models):
for a, b in enumerate(base_models):
RMSE = np.loadtxt(path2fits + f'/{drug}-{base_models_prefix[a]}m{m}-errors.txt')
if (RMSE.size > 1):
RMSE = RMSE[0]
RMSEs[base_models[a]][m] = RMSE
FDA_RMSE = np.loadtxt(path2fitsfda + '/FDA/' + drug + '-RMSE.txt')
expt_samples = np.loadtxt(path2data + '/' + drug + '-bootstrap-' + str(args.n_samples) + '-samples.txt')
for a, b in enumerate(base_models):
excluded = []
for m in models:
if FDA_RMSE > np.max(expt_samples):
if RMSEs[b][m] > func(FDA_RMSE, np.max(expt_samples)):
excluded.append(m)
else:
if RMSEs[b][m] > np.max(expt_samples):
excluded.append(m)
excluded_list[b][drug] = exclude_model_list_template(base_models_prefix[a], excluded)
# Print it as a dict for methods/parameters.py
print('{')
for b in base_models:
print(f' \'{b}\': {{')
for drug in drugs:
print(f' \'{drug}\': {excluded_list[b][drug]},')
print(' },')
print('}')