-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_petab.py
102 lines (82 loc) · 3.04 KB
/
compile_petab.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
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
import pypesto.petab
import petab
import os
import sys
import pandas as pd
import numpy as np
PARAMETER_ALIASES = {
'Fujita_SciSignal2010': {
'init_AKT': 'init_Akt',
'scaling_pAkt_tot': 'scaleFactor_pAkt',
'scaling_pEGFR_tot': 'scaleFactor_pEGFR',
'scaling_pS6_tot': 'scaleFactor_pS6'
},
'Zheng_PNAS2012': {
'sigma': 'noise'
},
'Bruno_JExpBot2016': {
'init_b10_1': 'init_b10',
'init_bcry_1': 'init_bcry',
'init_zea_1': 'init_zea',
'init_ohb10_1': 'init_ohb10'
},
'Isensee_JCB2018': {
'rho_pRII_Western': 'sigma_pRII_Western',
'rho_Calpha_Microscopy': 'sigma_Calpha',
'rho_pRII_Microscopy': 'sigma_pRII'
}
}
MODEL_ALIASES = {
'Crauste_CellSystems2017': 'Crauste_ImmuneCells_CellSystems2017',
'Bruno_JExpBot2016': 'Bruno_Carotines_JExpBio2016',
'Schwen_PONE2014': 'Schwen_InsulinMouseHepatocytes_PlosOne2014',
'Beer_MolBioSystems2014': 'Beer_MolBiosyst2014',
'Lucarelli_CellSystems2018': 'Lucarelli_TGFb_2017'
}
folder_base = os.path.join(os.path.dirname(__file__),
'Benchmark-Models-PEtab',
'Benchmark-Models')
def preprocess_problem(problem, model, extend_bounds):
if model in ['Brannmark_JBC2010', 'Fiedler_BMC2016']:
petab.flatten_timepoint_specific_output_overrides(problem)
if np.isfinite(extend_bounds):
problem.parameter_df[petab.LOWER_BOUND] /= extend_bounds
problem.parameter_df[petab.UPPER_BOUND] *= extend_bounds
else:
problem.parameter_df.loc[
problem.parameter_df[petab.PARAMETER_SCALE] == petab.LIN,
petab.LOWER_BOUND
] = - np.inf
problem.parameter_df.loc[
problem.parameter_df[petab.PARAMETER_SCALE] != petab.LIN,
petab.LOWER_BOUND
] = 0
problem.parameter_df[petab.UPPER_BOUND] = np.inf
def load_problem(model, force_compile=False, extend_bounds=1.0):
yaml_config = os.path.join(folder_base, model, model + '.yaml')
petab_problem = petab.Problem.from_yaml(yaml_config)
preprocess_problem(petab_problem, model, extend_bounds)
importer = pypesto.petab.PetabImporter(petab_problem, validate_petab=False)
problem = importer.create_problem(force_compile=force_compile)
matlab_model = MODEL_ALIASES.get(model, model)
for init in ['lsqnonlin', 'fmincon']:
try:
plabel = pd.read_csv(os.path.join(
'Hass2019', f'{matlab_model}_{init}_pLabel.csv'
))
pstart = pd.read_csv(os.path.join(
'Hass2019', f'{matlab_model}_{init}_ps_start.csv'
), names=plabel.columns[:-1])
except:
pass
pnames = problem.x_names
palias = PARAMETER_ALIASES.get(model, {})
pnames = [
palias.get(name, name)
for name in pnames
]
problem.x_guesses_full = pstart[pnames].values
return petab_problem, problem
if __name__ == '__main__':
MODEL_NAME = sys.argv[1]
load_problem(MODEL_NAME, force_compile=True)