diff --git a/petabtests/cases/v2.0.0/sbml/0024/0024.py b/petabtests/cases/v2.0.0/sbml/0024/0024.py index d55f430..6548bf1 100644 --- a/petabtests/cases/v2.0.0/sbml/0024/0024.py +++ b/petabtests/cases/v2.0.0/sbml/0024/0024.py @@ -85,7 +85,7 @@ case = PetabV2TestCase.from_problem( id=24, - brief="Prior distributions.", + brief="Truncated prior distributions.", description=DESCRIPTION, model=sbml_file, problem=problem, diff --git a/petabtests/cases/v2.0.0/sbml/0025/0025.py b/petabtests/cases/v2.0.0/sbml/0025/0025.py new file mode 100644 index 0000000..2350c41 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/0025.py @@ -0,0 +1,94 @@ +from inspect import cleandoc +from numpy import inf + +from petab.v2.C import * +from petab.v2 import Problem +from petabtests import ( + PetabV2TestCase, + antimony_to_sbml_str, +) +from pathlib import Path +from petab.v2 import PriorDistribution + +DESCRIPTION = cleandoc(r""" +## Objective + +This case tests different non-truncated prior distributions, as well as +implicit uniform priors and fixed parameters. + +## Model + +A simple model with all constant parameters. +""") + +# problem -------------------------------------------------------------------- + +priors = [ + (PriorDistribution.UNIFORM, (2, 8), 2, 8), + (PriorDistribution.NORMAL, (4, 2), -inf, inf), + (PriorDistribution.LOG_NORMAL, (5, 2), 0.0, inf), + (PriorDistribution.CAUCHY, (3, 5), -inf, inf), + (PriorDistribution.CHI_SQUARED, (4), 0.0, inf), + (PriorDistribution.EXPONENTIAL, (3), 0.0, inf), + (PriorDistribution.GAMMA, (3, 5), 0, inf), + (PriorDistribution.LAPLACE, (3, 5), -inf, inf), + (PriorDistribution.LOG_LAPLACE, (3, 5), 0, inf), + (PriorDistribution.LOG_UNIFORM, (3, 5), 3, 5), + (PriorDistribution.RAYLEIGH, (3), 0, inf), +] + +tested_prior_distrs = {pd for pd, _, _, _ in priors} +untested_distrs = [ + pd.value for pd in PriorDistribution if pd not in tested_prior_distrs +] +if untested_distrs: + print("Untested prior distributions:", untested_distrs) + +sbml_file = Path(__file__).parent / "_model.xml" + +parameters = "\n".join( + f"p_{prior_type.value.replace('-', '_')} = 5;" for prior_type, _, _, _ in priors +) +ant_model = f""" +model petab_test_0025 + {parameters} +end +""" +sbml_file.write_text(antimony_to_sbml_str(ant_model)) + +problem = Problem() +for prior_type, prior_pars, support_lb, support_ub in priors: + problem.add_parameter( + f"p_{prior_type.value.replace('-', '_')}", + estimate=True, + lb=support_lb, + ub=support_ub, + nominal_value=5, + prior_distribution=prior_type, + prior_parameters=prior_pars, + ) +# implicit uniform prior +problem.add_parameter("p1", estimate=True, nominal_value=1, lb=0, ub=2) +# fixed, i.e., no prior +problem.add_parameter("p_fixed", estimate=False, nominal_value=1) +# we need some observable and measurement +problem.add_observable("obs_p1", "p1", noise_formula="p_fixed") +problem.add_measurement("obs_p1", experiment_id="", time=0, measurement=1) + +# solutions ------------------------------------------------------------------ + +simulation_df = problem.measurement_df.copy(deep=True).rename( + columns={MEASUREMENT: SIMULATION} +) +simulation_df[SIMULATION] = [ + 1, +] + +case = PetabV2TestCase.from_problem( + id=25, + brief="Non-truncated prior distributions.", + description=DESCRIPTION, + model=sbml_file, + problem=problem, + simulation_df=simulation_df, +) diff --git a/petabtests/cases/v2.0.0/sbml/0025/README.md b/petabtests/cases/v2.0.0/sbml/0025/README.md new file mode 100644 index 0000000..6680ff4 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/README.md @@ -0,0 +1,10 @@ +# PEtab test case 0025 + +## Objective + +This case tests different non-truncated prior distributions, as well as +implicit uniform priors and fixed parameters. + +## Model + +A simple model with all constant parameters. diff --git a/petabtests/cases/v2.0.0/sbml/0025/_0025.yaml b/petabtests/cases/v2.0.0/sbml/0025/_0025.yaml new file mode 100644 index 0000000..9265994 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/_0025.yaml @@ -0,0 +1,13 @@ +condition_files: [] +experiment_files: [] +format_version: 2.0.0 +measurement_files: +- _measurements.tsv +model_files: + model_0: + language: sbml + location: _model.xml +observable_files: +- _observables.tsv +parameter_files: +- _parameters.tsv diff --git a/petabtests/cases/v2.0.0/sbml/0025/_0025_solution.yaml b/petabtests/cases/v2.0.0/sbml/0025/_0025_solution.yaml new file mode 100644 index 0000000..b46ff38 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/_0025_solution.yaml @@ -0,0 +1,23 @@ +chi2: 0.0 +llh: -0.91893853320467 +log_prior: + p1: -0.69314718055995 + p_cauchy: -2.90258780340177 + p_chisquare: -2.27685644868579 + p_exponential: -2.76527895533478 + p_gamma: -3.30258509299405 + p_laplace: -2.70258509299405 + p_log_laplace: -4.19013542294133 + p_log_normal: -4.65851253490362 + p_log_uniform: -0.93771092034198 + p_normal: -1.73708571376462 + p_rayleigh: -1.97667555379101 + p_uniform: -1.79175946922805 +simulation_files: +- _simulations.tsv +tol_chi2: 0.001 +tol_llh: 0.001 +tol_log_prior: 1.0e-14 +tol_simulations: 0.001 +tol_unnorm_log_posterior: 0.001 +unnorm_log_posterior: -30.85385872214566 diff --git a/petabtests/cases/v2.0.0/sbml/0025/_measurements.tsv b/petabtests/cases/v2.0.0/sbml/0025/_measurements.tsv new file mode 100644 index 0000000..291ff46 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/_measurements.tsv @@ -0,0 +1,2 @@ +modelId observableId experimentId time measurement observableParameters noiseParameters + obs_p1 0.0 1.0 diff --git a/petabtests/cases/v2.0.0/sbml/0025/_model.xml b/petabtests/cases/v2.0.0/sbml/0025/_model.xml new file mode 100644 index 0000000..bc551d8 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/_model.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/petabtests/cases/v2.0.0/sbml/0025/_observables.tsv b/petabtests/cases/v2.0.0/sbml/0025/_observables.tsv new file mode 100644 index 0000000..ca51014 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/_observables.tsv @@ -0,0 +1,2 @@ +observableId observableName observableFormula noiseFormula noiseDistribution observablePlaceholders noisePlaceholders +obs_p1 p1 p_fixed normal diff --git a/petabtests/cases/v2.0.0/sbml/0025/_parameters.tsv b/petabtests/cases/v2.0.0/sbml/0025/_parameters.tsv new file mode 100644 index 0000000..f569070 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/_parameters.tsv @@ -0,0 +1,14 @@ +parameterId lowerBound upperBound nominalValue estimate priorDistribution priorParameters +p_uniform 2.0 8.0 5.0 true uniform 2.0;8.0 +p_normal -inf inf 5.0 true normal 4.0;2.0 +p_log_normal 0.0 inf 5.0 true log-normal 5.0;2.0 +p_cauchy -inf inf 5.0 true cauchy 3.0;5.0 +p_chisquare 0.0 inf 5.0 true chisquare 4.0 +p_exponential 0.0 inf 5.0 true exponential 3.0 +p_gamma 0.0 inf 5.0 true gamma 3.0;5.0 +p_laplace -inf inf 5.0 true laplace 3.0;5.0 +p_log_laplace 0.0 inf 5.0 true log-laplace 3.0;5.0 +p_log_uniform 3.0 5.0 5.0 true log-uniform 3.0;5.0 +p_rayleigh 0.0 inf 5.0 true rayleigh 3.0 +p1 0.0 2.0 1.0 true +p_fixed 1.0 false diff --git a/petabtests/cases/v2.0.0/sbml/0025/_simulations.tsv b/petabtests/cases/v2.0.0/sbml/0025/_simulations.tsv new file mode 100644 index 0000000..aff90e1 --- /dev/null +++ b/petabtests/cases/v2.0.0/sbml/0025/_simulations.tsv @@ -0,0 +1,2 @@ +modelId observableId experimentId time simulation observableParameters noiseParameters + obs_p1 0.0 1 diff --git a/petabtests/cases/v2.0.0/sbml/README.md b/petabtests/cases/v2.0.0/sbml/README.md index 55bcb7b..c76bb72 100644 --- a/petabtests/cases/v2.0.0/sbml/README.md +++ b/petabtests/cases/v2.0.0/sbml/README.md @@ -88,5 +88,9 @@ Events during steady-state simulations. # [0024](0024/) -Prior distributions. +Truncated prior distributions. + +# [0025](0025/) + +Non-truncated prior distributions.