Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InitialAssignment issue #2418

Open
aidinbii opened this issue May 1, 2024 · 6 comments
Open

InitialAssignment issue #2418

aidinbii opened this issue May 1, 2024 · 6 comments
Labels
bug PEtab PEtab-import related SBML SBML import related

Comments

@aidinbii
Copy link

aidinbii commented May 1, 2024

Hello, there is an issue with InitialAssignment

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

@FFroehlich
Copy link
Member

Is it possible this is a typo of Ke_3 vs Ka_3. Hard to say anything else without the full PEtab problem

@dweindl
Copy link
Member

dweindl commented May 2, 2024

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.

@aidinbii
Copy link
Author

aidinbii commented May 2, 2024

@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

@FFroehlich
Copy link
Member

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.

@aidinbii
Copy link
Author

aidinbii commented May 6, 2024

@FFroehlich, that's what I did before. Actually, this brought me to this InitialAssignment issue

Please, see ICB-DCM/pyPESTO#1334

@dweindl dweindl added bug PEtab PEtab-import related SBML SBML import related labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug PEtab PEtab-import related SBML SBML import related
Projects
None yet
Development

No branches or pull requests

3 participants