InitialAssignment issue
Opened this issue · 6 comments
Hello, there is an issue with InitialAssignment
- The sbml model modelDef_PK_1C_constr_2.txt
When I run:
#With petab
from amici.petab.petab_import import import_petab_problem
amici_model = import_petab_problem(petab_problem,)
simulation_time = 10
number_timepoints = 10
amici_model.setTimepoints(np.linspace(0, simulation_time, number_timepoints))
problem_parameters_ex = {
'Ka_3': 1.14,
'Ka_30': 9.63,
'Ka_100': 9.63,
'Ke_30': 0.64,
'Ke_100': 0.07,
'VdF_3': 2800,
'VdF_30': 25800,
'VdF_100': 32800,
}
simulat_petab_ex = amici.petab.simulations.simulate_petab(petab_problem, amici_model,
problem_parameters=problem_parameters_ex)
It returns:
KeyError Traceback (most recent call last)
File [~/miniconda3/envs/modeling/lib/python3.9/site-packages/petab/parameter_mapping.py:596](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/petab/parameter_mapping.py:596), in _apply_parameter_table(par_mapping, scale_mapping, parameter_df, scaled_parameters, fill_fixed_parameters)
[594](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/petab/parameter_mapping.py:594) try:
[595](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/petab/parameter_mapping.py:595) # the overridee is a model parameter
--> [596](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/petab/parameter_mapping.py:596) par_mapping[problem_par] = par_mapping[sim_par]
[597](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/petab/parameter_mapping.py:597) scale_mapping[problem_par] = scale_mapping[sim_par]
KeyError: 'Ke_3'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
File [~/miniconda3/envs/modeling/lib/python3.9/site-packages/pandas/core/indexes/base.py:3790](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/pandas/core/indexes/base.py:3790), in Index.get_loc(self, key)
[3789](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/pandas/core/indexes/base.py:3789) try:
-> [3790](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/pandas/core/indexes/base.py:3790) return self._engine.get_loc(casted_key)
[3791](https://file+.vscode-resource.vscode-cdn.net/home/aidin/Documents/tum_courses/hiwi_Atefeh/alivexbiotech/projects/igg4_python/notebooks/case_studies_1/~/miniconda3/envs/modeling/lib/python3.9/site-packages/pandas/core/indexes/base.py:3791) except KeyError as err:
File index.pyx:152, in pandas._libs.index.IndexEngine.get_loc()
File index.pyx:181, in pandas._libs.index.IndexEngine.get_loc()
File pandas/_libs/hashtable_class_helper.pxi:7080, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas/_libs/hashtable_class_helper.pxi:7088, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'Ke_3'
The compiled model:
Model parameters: ['Ka', 'Ke', 'VdF', 'Ka_3', 'Ke_100', 'Ke_30', 'Ka_30', 'Ka_100', 'VdF_3', 'VdF_30', 'VdF_100', 'noiseParameter1_C_central']
Model const parameters: ['preequilibration_indicator', 'initial_mu_1_preeq', 'initial_mu_1_sim']
Model outputs: ['C_central']
Model states: ['mu_1', 'mu_2']
But, if I change the InitialAssignment so that there are no other symbols, for example:
<initialAssignment symbol="Ke_3">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<plus/>
<cn type="real"> 1.79 </cn>
<cn type="real"> 2.21 </cn>
</apply>
</math>
</initialAssignment>
It works without errors and the compiled model adds Ke_3 to Model const parameters
I'm using up-to-date versions of packages
Thank you
Is it possible this is a typo of Ke_3
vs Ka_3
. Hard to say anything else without the full PEtab problem
@FFroehlich , unfortunately not
Here are the PEtab tables:
- parameters_modelDef_PK_1C_constr_2.csv
- experimental_conditions_modelDef_PK_1C_constr_2.csv
- measurement_table_PK_1C.csv
- observables_modelDef_PK_1C_constr_2.csv
- problem_PK_1C_constr_2.txt
This is related to ICB-DCM/pyPESTO#1334
I can confirm that overriding some parameter A via the condition table with some parameter B, where B has a parameter-dependent initial assignment is currently not supported in amici. We should either implement that, or produce a more informative error.
@dweindl , thank you, I see.
Then there is no way to specify parameter constraints for parameter estimation.
For example, if I have a parameter vector: (p1, p2, p3, p4). And I want a constraint: p2 <= p3.
See: ICB-DCM/pyPESTO#1334
If both parameters are estimated on a log scale, you can reparametrize the problem as p3 =p2 + r
or p3=p2 * r
with r>0 or r>1 respectively.
@FFroehlich, that's what I did before. Actually, this brought me to this InitialAssignment issue
Please, see ICB-DCM/pyPESTO#1334