-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature reinitialization cases. Closes #30 #35
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ef53be5
Different value for B in preeq and sim condition
LeonardSchmiester 958fb4e
Added case for NaN in condition table
LeonardSchmiester 5f51a39
Adapted case 10
LeonardSchmiester 69dae6a
Reinitialize A
LeonardSchmiester f5c0a9a
Update Case 17
LeonardSchmiester File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
conditionId k1 B | ||
preeq_c0 0.3 0 | ||
c0 0.8 0 | ||
c0 0.8 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
observableId preequilibrationConditionId simulationConditionId time simulation | ||
obs_a preeq_c0 c0 1 0.3796559862634692 | ||
obs_a preeq_c0 c0 10 0.28571460248713115 | ||
obs_a preeq_c0 c0 1 0.7025430017170664 | ||
obs_a preeq_c0 c0 10 0.7142856746891086 |
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,18 @@ | ||
# PEtab test case 0017 | ||
|
||
## Objective | ||
|
||
This case tests support for partial preequilibration with `NaN`'s in the | ||
condition file. | ||
|
||
The model is to be simulated for a preequilibration condition and a | ||
simulation condition. | ||
For preequilibration, species `B` is initialized with `0`. For simulation, | ||
`B` is set to `NaN`, meaning that it is initialized with the result from | ||
preequilibration. | ||
For `A` the preequilibration result is to be used. | ||
|
||
## 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,61 @@ | ||
from petabtests import * | ||
from petab.C import * | ||
import petab | ||
|
||
import pandas as pd | ||
|
||
|
||
test_id = 17 | ||
|
||
# problem -------------------------------------------------------------------- | ||
|
||
model = DEFAULT_SBML_FILE | ||
|
||
condition_df = pd.DataFrame(data={ | ||
CONDITION_ID: ['preeq_c0', 'c0'], | ||
'k1': [0.3, 0.8], | ||
'B': [0, 'NaN'], | ||
}).set_index([CONDITION_ID]) | ||
|
||
measurement_df = pd.DataFrame(data={ | ||
OBSERVABLE_ID: ['obs_a', 'obs_a'], | ||
PREEQUILIBRATION_CONDITION_ID: ['preeq_c0', 'preeq_c0'], | ||
SIMULATION_CONDITION_ID: ['c0', 'c0'], | ||
TIME: [1, 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: ['k2'], | ||
PARAMETER_SCALE: [LIN], | ||
LOWER_BOUND: [0], | ||
UPPER_BOUND: [10], | ||
NOMINAL_VALUE: [0.6], | ||
ESTIMATE: [1], | ||
}).set_index(PARAMETER_ID) | ||
|
||
|
||
# solutions ------------------------------------------------------------------ | ||
|
||
simulation_df = measurement_df.copy(deep=True).rename( | ||
columns={MEASUREMENT: SIMULATION}) | ||
# simulate for far time point as steady state | ||
steady_state_a = analytical_a(1000, 1, 0, 0.3, 0.6) | ||
steady_state_b = analytical_b(1000, 1, 0, 0.3, 0.6) | ||
# use steady state as initial state | ||
simulation_df[SIMULATION] = [ | ||
analytical_a(t, steady_state_a, steady_state_b, 0.8, 0.6) | ||
for t in simulation_df[TIME]] | ||
|
||
chi2 = petab.calculate_chi2( | ||
measurement_df, simulation_df, observable_df, parameter_df) | ||
|
||
llh = petab.calculate_llh( | ||
measurement_df, simulation_df, observable_df, parameter_df) | ||
print(llh) |
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: 0.6128279546163969 | ||
llh: -0.7579966825976534 | ||
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,3 @@ | ||
conditionId k1 B | ||
preeq_c0 0.3 0 | ||
c0 0.8 NaN |
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 preequilibrationConditionId simulationConditionId time measurement | ||
obs_a preeq_c0 c0 1 0.7 | ||
obs_a preeq_c0 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,94 @@ | ||
<?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="b0" name="b0" 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> | ||
<initialAssignment symbol="B"> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<ci> b0 </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,2 @@ | ||
parameterId parameterScale lowerBound upperBound nominalValue estimate | ||
k2 lin 0 10 0.6 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,3 @@ | ||
observableId preequilibrationConditionId simulationConditionId time simulation | ||
obs_a preeq_c0 c0 1 0.48728499141466824 | ||
obs_a preeq_c0 c0 10 0.42857162655445696 |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
conditionId k1 B | ||
preeq_c0 0.3 0 | ||
c0 0.8 0 | ||
c0 0.8 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
observableId preequilibrationConditionId simulationConditionId time simulation | ||
obs_a preeq_c0 c0 1 0.3796559862634692 | ||
obs_a preeq_c0 c0 10 0.28571460248713115 | ||
obs_a preeq_c0 c0 1 0.7025430017170664 | ||
obs_a preeq_c0 c0 10 0.7142856746891086 |
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.py |
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: 0.6128279546163969 | ||
llh: -0.7579966825976534 | ||
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,3 @@ | ||
conditionId k1 B | ||
preeq_c0 0.3 0 | ||
c0 0.8 NaN |
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 preequilibrationConditionId simulationConditionId time measurement | ||
obs_a preeq_c0 c0 1 0.7 | ||
obs_a preeq_c0 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,21 @@ | ||
from pysb import Model, Monomer, Parameter, Compartment, Rule, Initial, Observable | ||
|
||
Model() | ||
|
||
Compartment('compartment') | ||
|
||
Monomer('A_') | ||
Monomer('B_') | ||
|
||
Parameter('a0', 1.0) | ||
Parameter('b0', 1.0) | ||
Parameter('k1', 0.0) | ||
Parameter('k2', 0.0) | ||
|
||
Rule('conversion', A_() ** compartment | B_() ** compartment, k1, k2) | ||
|
||
Initial(A_() ** compartment, a0) | ||
Initial(B_() ** compartment, b0) | ||
|
||
Observable("A", A_()) | ||
Observable("B", 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,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,2 @@ | ||
parameterId parameterScale lowerBound upperBound nominalValue estimate | ||
k2 lin 0 10 0.6 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,3 @@ | ||
observableId preequilibrationConditionId simulationConditionId time simulation | ||
obs_a preeq_c0 c0 1 0.48728499141466824 | ||
obs_a preeq_c0 c0 10 0.42857162655445696 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about changing the test to reinitializing A (and continuing B) to ensure, that not just everything is continued from steadystate if there is a NaN somewhere? Looks good otherwise, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I changed it accordingly.