PEtab-dev / PEtab

PEtab - an SBML and TSV based data format for parameter estimation problems in systems biology
https://petab.readthedocs.io
MIT License
56 stars 12 forks source link

Handling of events on parameters that are subject to condition specific values. #583

Closed leodarrigade closed 1 month ago

leodarrigade commented 1 month ago

Hello, I am getting a bit lost on how to deal with an event in my PEtab problem. I have a parameter L_0 in my SBML model, which is an initial concentration of hormone in an experiment. This parameter is defined as such in my SBML :

<parameter metaid="L_0" id="L_0" name="Initial concentration of ligand (experimentally known)" value="0" units="substance_per_volume" constant="false"/>

This parameter is subject to an event : there is a time t_wash in the experiment where the hormone is removed from the media and L_0 is set to 0. The event is defined as follow in the SBML :

<listOfEvents>
<event metaid="ligand_wash" id="ligand_wash">
<trigger metaid="CDMT00024">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<geq/>
<csymbol encoding="text" definitionURL="http://www.sbml.org/sbml/symbols/time"> time </csymbol>
<ci> t_wash </ci>
</apply>
</math>
</trigger>
<listOfEventAssignments>
<eventAssignment metaid="CDMT00025" variable="L_0">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<cn> 0 </cn>
</math>
</eventAssignment>
</listOfEventAssignments>
</event>
</listOfEvents>

Before the event (for time inferior to t_wash), this parameter takes condition specific values which are floats and specified in the condition table.

When I import this model with my Petab problem using pyPESTO PEtab importer and compile to AMICI, it defines L_0 as a StateId of the AMICI model (see here). I don't know if this is an intended behavior, but if I don't set an event on L_0, it does not appear in the StateIds list of the AMICI model.

More importantly, when I set an event on L_0, the condition specific values for L_0 are not taken into account anymore and before t_wash, L_0 takes the dummy value that I specified when I defined the parameter in the SBML model (here it is 0, see above).

Am I missing something and this is intended behavior ? I hope I managed to be clear.

dilpath commented 1 month ago

Hi, I would suggest rewriting your PEtab problem to remove L_0 from the condition table, which should only include values/variables that are constant throughout time.

Instead, rename L_0 to L_0_conc in your condition table, and add an initialAssignmentRule in your SBML model that sets L_0(t=0) = L_0_conc. You will need to add an SBML parameter for L_0_conc. Let me know if the issue persists.

dweindl commented 1 month ago

When I import this model with my Petab problem using pyPESTO PEtab importer and compile to AMICI, it defines L_0 as a StateId of the AMICI model

Hi, that is correct / intended. In AMICI, parameters are constant (unlike in SBML). Any target of an event assignment, assignment rule, or rate rule will be a state variable in the AMICI model.

leodarrigade commented 1 month ago

@dweindl Thanks for the precision.

@dilpath Thank you, it is working fine with your solution. I think it could be useful to include in the PEtab documentation that parameters in the condition table cannot change values over time and be subject of event.

dilpath commented 1 month ago

Great!

Agreed, currently there is ambiguity in the current version of the spec, and behavior could be tool-specific. The spec will be updated to specify how to handle "time-dependent" parameters, in the next version of PEtab. The issue is tracked at https://github.com/PEtab-dev/PEtab/issues/513