-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case with estimated initial conditions specified via the con… (
#63) Add test case with estimated initial conditions specified via the conditions table Closes #62 Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
- Loading branch information
Showing
26 changed files
with
590 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from inspect import cleandoc | ||
|
||
import pandas as pd | ||
from petab.C import * | ||
|
||
from petabtests import PetabTestCase, analytical_a | ||
|
||
DESCRIPTION = cleandoc(""" | ||
## Objective | ||
This case tests handling of initial concentrations that are specified | ||
in the conditions table. For species `A`, the initial concentration is | ||
estimated. For species `B`, the initial concentration is specified in the | ||
parameters table. | ||
## Model | ||
A simple conversion reaction `A <=> B` in a single compartment, following | ||
mass action kinetics. | ||
""") | ||
|
||
# problem -------------------------------------------------------------------- | ||
|
||
condition_df = pd.DataFrame(data={ | ||
CONDITION_ID: ['c0'], | ||
'A': ["initial_A"], | ||
'B': ["initial_B"], | ||
}).set_index([CONDITION_ID]) | ||
|
||
measurement_df = pd.DataFrame(data={ | ||
OBSERVABLE_ID: ['obs_a', 'obs_a'], | ||
SIMULATION_CONDITION_ID: ['c0', 'c0'], | ||
TIME: [0, 10], | ||
MEASUREMENT: [0.7, 0.1] | ||
}) | ||
|
||
observable_df = pd.DataFrame(data={ | ||
OBSERVABLE_ID: ['obs_a'], | ||
OBSERVABLE_FORMULA: ['A'], | ||
NOISE_FORMULA: [0.5] | ||
}).set_index([OBSERVABLE_ID]) | ||
|
||
parameter_df = pd.DataFrame(data={ | ||
PARAMETER_ID: ['k1', 'k2', 'initial_A', 'initial_B'], | ||
PARAMETER_SCALE: [LIN, LIN, LOG10, LIN], | ||
LOWER_BOUND: [0, 0, 1, 0], | ||
UPPER_BOUND: [10] * 4, | ||
NOMINAL_VALUE: [0.8, 0.6, 2, 3], | ||
ESTIMATE: [1] * 3 + [0], | ||
}).set_index(PARAMETER_ID) | ||
|
||
# solutions ------------------------------------------------------------------ | ||
|
||
simulation_df = measurement_df.copy(deep=True).rename( | ||
columns={MEASUREMENT: SIMULATION}) | ||
simulation_df[SIMULATION] = [analytical_a(t, 2, 3, 0.8, 0.6) | ||
for t in simulation_df[TIME]] | ||
|
||
case = PetabTestCase( | ||
id=19, | ||
brief="Simulation. Estimated initial value via conditions table.", | ||
description=DESCRIPTION, | ||
model='conversion_modified.xml', | ||
condition_dfs=[condition_df], | ||
observable_dfs=[observable_df], | ||
measurement_dfs=[measurement_df], | ||
simulation_dfs=[simulation_df], | ||
parameter_df=parameter_df, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# PEtab test case 0019 | ||
|
||
## Objective | ||
|
||
This case tests handling of initial concentrations that are specified | ||
in the conditions table. For species `A`, the initial concentration is | ||
estimated. For species `B`, the initial concentration is specified in the | ||
parameters table. | ||
|
||
## Model | ||
|
||
A simple conversion reaction `A <=> B` in a single compartment, following | ||
mass action kinetics. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
format_version: 1 | ||
parameter_file: _parameters.tsv | ||
problems: | ||
- condition_files: | ||
- _conditions.tsv | ||
measurement_files: | ||
- _measurements.tsv | ||
observable_files: | ||
- _observables.tsv | ||
sbml_files: | ||
- _model.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
chi2: 23.45305928312484 | ||
llh: -12.17811234685187 | ||
simulation_files: | ||
- _simulations.tsv | ||
tol_chi2: 0.001 | ||
tol_llh: 0.001 | ||
tol_simulations: 0.001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
conditionId A B | ||
c0 initial_A initial_B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
observableId simulationConditionId time measurement | ||
obs_a c0 0 0.7 | ||
obs_a c0 10 0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4"> | ||
<model id="conversion_reaction_0" name="Conversion Reaction 0"> | ||
|
||
<listOfUnitDefinitions> | ||
<unitDefinition id="volume" name="volume"> | ||
<listOfUnits> | ||
<unit kind="litre" exponent="1" scale="-3" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
<unitDefinition id="substance" name="substance"> | ||
<listOfUnits> | ||
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
</listOfUnitDefinitions> | ||
|
||
<listOfCompartments> | ||
<compartment id="compartment" name="compartment" spatialDimensions="3" size="1" constant="true"> | ||
</compartment> | ||
</listOfCompartments> | ||
|
||
<listOfSpecies> | ||
<species id="A" name="A" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false"> | ||
</species> | ||
<species id="B" name="B" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false"> | ||
</species> | ||
</listOfSpecies> | ||
|
||
<listOfParameters> | ||
<parameter id="a0" name="a0" value="1" constant="true"> | ||
</parameter> | ||
<parameter id="k1" name="k1" value="0" constant="true"> | ||
</parameter> | ||
<parameter id="k2" name="k2" value="0" constant="true"> | ||
</parameter> | ||
</listOfParameters> | ||
|
||
<listOfInitialAssignments> | ||
<initialAssignment symbol="A"> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<ci> a0 </ci> | ||
</math> | ||
</initialAssignment> | ||
</listOfInitialAssignments> | ||
|
||
<listOfReactions> | ||
<reaction id="fwd" name="fwd" reversible="false"> | ||
<listOfReactants> | ||
<speciesReference species="A" stoichiometry="1"/> | ||
</listOfReactants> | ||
<listOfProducts> | ||
<speciesReference species="B" stoichiometry="1"/> | ||
</listOfProducts> | ||
<kineticLaw> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<apply> | ||
<times/> | ||
<ci> compartment </ci> | ||
<ci> k1 </ci> | ||
<ci> A </ci> | ||
</apply> | ||
</math> | ||
</kineticLaw> | ||
</reaction> | ||
<reaction id="rev" name="rev" reversible="false"> | ||
<listOfReactants> | ||
<speciesReference species="B" stoichiometry="1"/> | ||
</listOfReactants> | ||
<listOfProducts> | ||
<speciesReference species="A" stoichiometry="1"/> | ||
</listOfProducts> | ||
<kineticLaw> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<apply> | ||
<times/> | ||
<ci> compartment </ci> | ||
<ci> k2 </ci> | ||
<ci> B </ci> | ||
</apply> | ||
</math> | ||
</kineticLaw> | ||
</reaction> | ||
</listOfReactions> | ||
|
||
</model> | ||
</sbml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
observableId observableFormula noiseFormula | ||
obs_a A 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
parameterId parameterScale lowerBound upperBound nominalValue estimate | ||
k1 lin 0 10 0.8 1 | ||
k2 lin 0 10 0.6 1 | ||
initial_A log10 1 10 2.0 1 | ||
initial_B lin 0 10 3.0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
observableId simulationConditionId time simulation | ||
obs_a c0 0 2.0 | ||
obs_a c0 10 2.1428570240673257 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4"> | ||
<model id="conversion_reaction_0" name="Conversion Reaction 0"> | ||
|
||
<listOfUnitDefinitions> | ||
<unitDefinition id="volume" name="volume"> | ||
<listOfUnits> | ||
<unit kind="litre" exponent="1" scale="-3" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
<unitDefinition id="substance" name="substance"> | ||
<listOfUnits> | ||
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
</listOfUnitDefinitions> | ||
|
||
<listOfCompartments> | ||
<compartment id="compartment" name="compartment" spatialDimensions="3" size="1" constant="true"> | ||
</compartment> | ||
</listOfCompartments> | ||
|
||
<listOfSpecies> | ||
<species id="A" name="A" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false"> | ||
</species> | ||
<species id="B" name="B" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false"> | ||
</species> | ||
</listOfSpecies> | ||
|
||
<listOfParameters> | ||
<parameter id="a0" name="a0" value="1" constant="true"> | ||
</parameter> | ||
<parameter id="k1" name="k1" value="0" constant="true"> | ||
</parameter> | ||
<parameter id="k2" name="k2" value="0" constant="true"> | ||
</parameter> | ||
</listOfParameters> | ||
|
||
<listOfInitialAssignments> | ||
<initialAssignment symbol="A"> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<ci> a0 </ci> | ||
</math> | ||
</initialAssignment> | ||
</listOfInitialAssignments> | ||
|
||
<listOfReactions> | ||
<reaction id="fwd" name="fwd" reversible="false"> | ||
<listOfReactants> | ||
<speciesReference species="A" stoichiometry="1"/> | ||
</listOfReactants> | ||
<listOfProducts> | ||
<speciesReference species="B" stoichiometry="1"/> | ||
</listOfProducts> | ||
<kineticLaw> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<apply> | ||
<times/> | ||
<ci> compartment </ci> | ||
<ci> k1 </ci> | ||
<ci> A </ci> | ||
</apply> | ||
</math> | ||
</kineticLaw> | ||
</reaction> | ||
<reaction id="rev" name="rev" reversible="false"> | ||
<listOfReactants> | ||
<speciesReference species="B" stoichiometry="1"/> | ||
</listOfReactants> | ||
<listOfProducts> | ||
<speciesReference species="A" stoichiometry="1"/> | ||
</listOfProducts> | ||
<kineticLaw> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<apply> | ||
<times/> | ||
<ci> compartment </ci> | ||
<ci> k2 </ci> | ||
<ci> B </ci> | ||
</apply> | ||
</math> | ||
</kineticLaw> | ||
</reaction> | ||
</listOfReactions> | ||
|
||
</model> | ||
</sbml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from inspect import cleandoc | ||
|
||
import pandas as pd | ||
from petab.C import * | ||
|
||
from petabtests import PetabTestCase, analytical_a | ||
|
||
DESCRIPTION = cleandoc(""" | ||
## Objective | ||
This case tests handling of initial concentrations that are specified | ||
in the conditions table. For species `A`, the initial concentration is | ||
estimated. For species `B`, the initial concentration is specified in the | ||
parameters table. | ||
## Model | ||
A simple conversion reaction `A <=> B` in a single compartment, following | ||
mass action kinetics. | ||
""") | ||
|
||
# problem -------------------------------------------------------------------- | ||
|
||
condition_df = pd.DataFrame(data={ | ||
CONDITION_ID: ['c0'], | ||
'A': ["initial_A"], | ||
'B': ["initial_B"], | ||
}).set_index([CONDITION_ID]) | ||
|
||
measurement_df = pd.DataFrame(data={ | ||
OBSERVABLE_ID: ['obs_a', 'obs_a'], | ||
SIMULATION_CONDITION_ID: ['c0', 'c0'], | ||
TIME: [0, 10], | ||
MEASUREMENT: [0.7, 0.1] | ||
}) | ||
|
||
observable_df = pd.DataFrame(data={ | ||
OBSERVABLE_ID: ['obs_a'], | ||
OBSERVABLE_FORMULA: ['A'], | ||
NOISE_FORMULA: [0.5] | ||
}).set_index([OBSERVABLE_ID]) | ||
|
||
parameter_df = pd.DataFrame(data={ | ||
PARAMETER_ID: ['k1', 'k2', 'initial_A', 'initial_B'], | ||
PARAMETER_SCALE: [LIN, LIN, LOG10, LIN], | ||
LOWER_BOUND: [0, 0, 1, 0], | ||
UPPER_BOUND: [10] * 4, | ||
NOMINAL_VALUE: [0.8, 0.6, 2, 3], | ||
ESTIMATE: [1] * 3 + [0], | ||
}).set_index(PARAMETER_ID) | ||
|
||
# solutions ------------------------------------------------------------------ | ||
|
||
simulation_df = measurement_df.copy(deep=True).rename( | ||
columns={MEASUREMENT: SIMULATION}) | ||
simulation_df[SIMULATION] = [analytical_a(t, 2, 3, 0.8, 0.6) | ||
for t in simulation_df[TIME]] | ||
|
||
case = PetabTestCase( | ||
id=20, | ||
brief="Simulation. Estimated initial value via conditions table.", | ||
description=DESCRIPTION, | ||
model='conversion_modified.xml', | ||
condition_dfs=[condition_df], | ||
observable_dfs=[observable_df], | ||
measurement_dfs=[measurement_df], | ||
simulation_dfs=[simulation_df], | ||
parameter_df=parameter_df, | ||
) |
Oops, something went wrong.