Skip to content

Commit 787a67e

Browse files
authored
Merge branch 'develop' into require_py311
2 parents 12e0b4e + cd3fa51 commit 787a67e

File tree

15 files changed

+330
-80
lines changed

15 files changed

+330
-80
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/checkout@v5
3333

3434
- name: Prepare python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v5
35+
uses: actions/setup-python@v6
3636
with:
3737
python-version: ${{ matrix.python-version }}
3838

@@ -71,7 +71,7 @@ jobs:
7171
uses: actions/checkout@v5
7272

7373
- name: Prepare python ${{ matrix.python-version }}
74-
uses: actions/setup-python@v5
74+
uses: actions/setup-python@v6
7575
with:
7676
python-version: ${{ matrix.python-version }}
7777

@@ -107,7 +107,7 @@ jobs:
107107
uses: actions/checkout@v5
108108

109109
- name: Prepare python ${{ matrix.python-version }}
110-
uses: actions/setup-python@v5
110+
uses: actions/setup-python@v6
111111
with:
112112
python-version: ${{ matrix.python-version }}
113113

@@ -140,7 +140,7 @@ jobs:
140140
uses: actions/checkout@v5
141141

142142
- name: Prepare python ${{ matrix.python-version }}
143-
uses: actions/setup-python@v5
143+
uses: actions/setup-python@v6
144144
with:
145145
python-version: ${{ matrix.python-version }}
146146

@@ -184,7 +184,7 @@ jobs:
184184
uses: actions/checkout@v5
185185

186186
- name: Prepare python ${{ matrix.python-version }}
187-
uses: actions/setup-python@v5
187+
uses: actions/setup-python@v6
188188
with:
189189
python-version: ${{ matrix.python-version }}
190190

@@ -230,7 +230,7 @@ jobs:
230230
uses: actions/checkout@v5
231231

232232
- name: Prepare python ${{ matrix.python-version }}
233-
uses: actions/setup-python@v5
233+
uses: actions/setup-python@v6
234234
with:
235235
python-version: ${{ matrix.python-version }}
236236

@@ -266,7 +266,7 @@ jobs:
266266
uses: actions/checkout@v5
267267

268268
- name: Prepare python ${{ matrix.python-version }}
269-
uses: actions/setup-python@v5
269+
uses: actions/setup-python@v6
270270
with:
271271
python-version: ${{ matrix.python-version }}
272272

@@ -302,7 +302,7 @@ jobs:
302302
uses: actions/checkout@v5
303303

304304
- name: Prepare python ${{ matrix.python-version }}
305-
uses: actions/setup-python@v5
305+
uses: actions/setup-python@v6
306306
with:
307307
python-version: ${{ matrix.python-version }}
308308

@@ -338,7 +338,7 @@ jobs:
338338
uses: actions/checkout@v5
339339

340340
- name: Prepare python ${{ matrix.python-version }}
341-
uses: actions/setup-python@v5
341+
uses: actions/setup-python@v6
342342
with:
343343
python-version: ${{ matrix.python-version }}
344344

@@ -370,7 +370,7 @@ jobs:
370370
uses: actions/checkout@v5
371371

372372
- name: Prepare python ${{ matrix.python-version }}
373-
uses: actions/setup-python@v5
373+
uses: actions/setup-python@v6
374374
with:
375375
python-version: ${{ matrix.python-version }}
376376

@@ -403,7 +403,7 @@ jobs:
403403
uses: actions/checkout@v5
404404

405405
- name: Prepare python ${{ matrix.python-version }}
406-
uses: actions/setup-python@v5
406+
uses: actions/setup-python@v6
407407
with:
408408
python-version: ${{ matrix.python-version }}
409409

@@ -433,7 +433,7 @@ jobs:
433433
uses: actions/checkout@v5
434434

435435
- name: Prepare python ${{ matrix.python-version }}
436-
uses: actions/setup-python@v5
436+
uses: actions/setup-python@v6
437437
with:
438438
python-version: ${{ matrix.python-version }}
439439

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
run: sed -i '/git+https/d' setup.cfg
2222

2323
- name: Prepare python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v5
24+
uses: actions/setup-python@v6
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ to pyPESTO check out
8686
When using pyPESTO in your project, please cite
8787
* Schälte, Y., Fröhlich, F., Jost, P. J., Vanhoefer, J., Pathirana, D., Stapor, P.,
8888
Lakrisenko, P., Wang, D., Raimúndez, E., Merkt, S., Schmiester, L., Städter, P.,
89-
Grein, S., Dudkin, E., Doresic, D., Weindl, D., & Hasenauer, J. (2023). pyPESTO: A
90-
modular and scalable tool for parameter estimation for dynamic models,
91-
Bioinformatics, 2023, btad711, [doi:10.1093/bioinformatics/btad711](https://doi.org/10.1093/bioinformatics/btad711)
89+
Grein, S., Dudkin, E., Doresic, D., Weindl, D., & Hasenauer, J.
90+
pyPESTO: A modular and scalable tool for parameter estimation for dynamic models,
91+
Bioinformatics, Volume 39, Issue 11, 2023, btad711,
92+
[doi:10.1093/bioinformatics/btad711](https://doi.org/10.1093/bioinformatics/btad711)
9293

9394
When presenting work that employs pyPESTO, feel free to use one of the icons in
9495
[doc/logo/](doc/logo):

doc/example/getting_started.ipynb

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"\n",
1515
"<img src=\"https://github.com/ICB-DCM/pyPESTO/raw/main/doc/logo/logo_wordmark.png\" width=\"40%\" alt=\"pyPESTO logo\"/>\n",
1616
"\n",
17-
"pyPESTO is a python package for parameter inference, offering a unified interface to various optimization and sampling methods. \n",
17+
"pyPESTO is a python package for parameter inference, offering a unified interface to various optimization and sampling methods.\n",
1818
"pyPESTO is highly modular and customizable, e.g., with respect to objective function definition and employed inference algorithms."
1919
]
2020
},
@@ -92,9 +92,7 @@
9292
"name": "#%% md\n"
9393
}
9494
},
95-
"source": [
96-
"Define lower and upper parameter bounds and create an optimization problem. "
97-
]
95+
"source": "Define lower and upper parameter bounds and create an optimization problem."
9896
},
9997
{
10098
"cell_type": "code",
@@ -197,9 +195,9 @@
197195
"\n",
198196
"<img src=\"https://github.com/PEtab-dev/PEtab/blob/main/doc/v1/gfx/petab_files.png?raw=true\" width=\"80%\" alt=\"PEtab files\"/>\n",
199197
"\n",
200-
"PyPESTO supports the [PEtab](https://github.com/PEtab-dev/PEtab) standard. PEtab is a data format for specifying parameter estimation problems in systems biology. \n",
198+
"PyPESTO supports the [PEtab](https://github.com/PEtab-dev/PEtab) standard. PEtab is a data format for specifying parameter estimation problems in systems biology.\n",
201199
"\n",
202-
"A PEtab problem consist of an [SBML](https://sbml.org) file, defining the model topology and a set of `.tsv` files, defining experimental conditions, observables, measurements and parameters (and their optimization bounds, scale, priors...). All files that make up a PEtab problem can be structured in a `.yaml` file. The `pypesto.Objective` coming from a PEtab problem corresponds to the negative-log-likelihood/negative-log-posterior distribution of the parameters. \n",
200+
"A PEtab problem consist of an [SBML](https://sbml.org) file, defining the model topology and a set of `.tsv` files, defining experimental conditions, observables, measurements and parameters (and their optimization bounds, scale, priors...). All files that make up a PEtab problem can be structured in a `.yaml` file. The `pypesto.Objective` coming from a PEtab problem corresponds to the negative-log-likelihood/negative-log-posterior distribution of the parameters.\n",
203201
"\n",
204202
"For more details on PEtab, the interested reader is referred to [PEtab's format definition](https://petab.readthedocs.io/en/latest/documentation_data_format.html), for examples, the reader is referred to the [PEtab benchmark collection](https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab). The Model from _[Böhm et al. JProteomRes 2014](https://pubs.acs.org/doi/abs/10.1021/pr5006923)_ is part of the benchmark collection and will be used as the running example throughout this notebook.\n",
205203
"\n",
@@ -237,6 +235,15 @@
237235
"problem = importer.create_problem(verbose=False)"
238236
]
239237
},
238+
{
239+
"cell_type": "code",
240+
"execution_count": null,
241+
"metadata": {},
242+
"outputs": [],
243+
"source": [
244+
"petab_yaml"
245+
]
246+
},
240247
{
241248
"cell_type": "markdown",
242249
"metadata": {
@@ -328,7 +335,7 @@
328335
" * Global optimizer\n",
329336
" * Gradient-free\n",
330337
"* [FIDES](https://github.com/fides-dev/fides/) (`optimize.FidesOptimizer()`)\n",
331-
" * Interior Trust Region optimizer \n",
338+
" * Interior Trust Region optimizer\n",
332339
"* [Particle Swarm](https://github.com/ljvmiranda921/pyswarms) (`optimize.PyswarmsOptimizer()`)\n",
333340
" * Particle swarm algorithm\n",
334341
" * Gradient-free\n",
@@ -364,7 +371,7 @@
364371
"source": [
365372
"The following performs 10 multi-start runs with different optimizers in order to compare their performance. For a faster execution of this notebook, we run only 10 starts. In application, one would use many more optimization starts: around 100-1000 in most cases.\n",
366373
"\n",
367-
"_Note_: `dlib` and `pyswarm` need to be installed for this section to run. Furthermore, the computation time is in the order of minutes, so you might want to skip the execution and jump to the section on large scale models. "
374+
"_Note_: `dlib` and `pyswarm` need to be installed for this section to run. Furthermore, the computation time is in the order of minutes, so you might want to skip the execution and jump to the section on large scale models."
368375
]
369376
},
370377
{
@@ -430,7 +437,7 @@
430437
"### Optimizer Convergence\n",
431438
"\n",
432439
"\n",
433-
"A common visualization of optimizer convergence are waterfall plots. Waterfall plots show the (ordered) results of the individual optimization runs. In general, we hope to obtain clearly visible plateaus, as they indicate optimizer convergence to local minima. "
440+
"A common visualization of optimizer convergence are waterfall plots. Waterfall plots show the (ordered) results of the individual optimization runs. In general, we hope to obtain clearly visible plateaus, as they indicate optimizer convergence to local minima."
434441
]
435442
},
436443
{
@@ -496,11 +503,11 @@
496503
"\n",
497504
"### Efficient gradient computation\n",
498505
"\n",
499-
"As seen in the example above and as can be confirmed from own experience: If fast and reliable gradients can be provided, gradient-based optimizers are favourable with respect to optimizer convergence and run time. \n",
506+
"As seen in the example above and as can be confirmed from own experience: If fast and reliable gradients can be provided, gradient-based optimizers are favourable with respect to optimizer convergence and run time.\n",
500507
"\n",
501508
"It has been shown that adjoint sensitivity analysis is a fast and reliable method to compute gradients for large scale models, since their run time is (asymptotically) independent of the number of parameters ([Fröhlich et al. PlosCB 2017](https://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.1005331&type=printable)).\n",
502509
"\n",
503-
"<img src=\"https://journals.plos.org/ploscompbiol/article/figure/image?size=large&id=10.1371/journal.pcbi.1005331.g002\" width=\"40%\" alt=\"pyPESTO logo\"/> \n",
510+
"<img src=\"https://journals.plos.org/ploscompbiol/article/figure/image?size=large&id=10.1371/journal.pcbi.1005331.g002\" width=\"40%\" alt=\"pyPESTO logo\"/>\n",
504511
"\n",
505512
"(Figure from Fröhlich et al. PlosCB 2017) Adjoint sensitivities are implemented in AMICI."
506513
]
@@ -600,7 +607,6 @@
600607
" problem=problem,\n",
601608
" result=result,\n",
602609
" optimizer=optimizer_scipy_lbfgsb,\n",
603-
" profile_index=[0, 1],\n",
604610
")"
605611
]
606612
},
@@ -639,9 +645,7 @@
639645
}
640646
},
641647
"source": [
642-
"The plot shows that seven parameters are identifiable, since the likelihood is tightly centered around the optimal parameter. Two parameters (`k_exp_hetero` and `k_imp_homo`) cannot be constrained by the data.\n",
643-
"\n",
644-
"Furthermore pyPESTO allows to visualize confidence intervals directly via"
648+
"Furthermore, pyPESTO allows to visualize approximate confidence intervals directly via `profile_cis`. Confidence intervals are computed by finding parameter values for which the log posterior ratio is above the approximate threshold assuming a $\\chi^2$ distribution of the likelihood test statistic. The plot shows that both model parameters are identifiable, since the confidence regions are finite and do not span the whole estimation space (from lower to upper estimation boundary)."
645649
]
646650
},
647651
{
@@ -671,7 +675,7 @@
671675
"source": [
672676
"### Sampling\n",
673677
"\n",
674-
"In pyPESTO, sampling from the posterior distribution can be performed as "
678+
"In pyPESTO, sampling from the posterior distribution can be performed as"
675679
]
676680
},
677681
{
@@ -798,11 +802,12 @@
798802
"source": [
799803
"#### Sampler Choice:\n",
800804
"\n",
801-
"Similarly to parameter optimization, pyPESTO provides a unified interface to several sampler/sampling toolboxes, as well as own implementations of sampler:\n",
805+
"Similarly to parameter optimization, pyPESTO provides a unified interface to several sampler/sampling toolboxes, as well as own implementations of samplers:\n",
802806
"\n",
803-
"* Adaptive Metropolis: `sample.AdaptiveMetropolisSampler()`\n",
804-
"* Adaptive parallel tempering: `sample.ParallelTemperingSampler()`\n",
805-
"* Interface to `pymc3` via `sample.Pymc3Sampler()`"
807+
"* Adaptive Metropolis: `pypesto.sample.AdaptiveMetropolisSampler()`\n",
808+
"* Parallel tempering: `pypesto.sample.ParallelTemperingSampler()`\n",
809+
"* Adaptive parallel tempering: `pypesto.sample.AdaptiveParallelTemperingSampler()`\n",
810+
"* Interface to `pymc` [🔗](https://pypi.org/project/pymc/) via `pypesto.sample.PymcSampler()`"
806811
]
807812
},
808813
{
@@ -918,7 +923,7 @@
918923
],
919924
"metadata": {
920925
"kernelspec": {
921-
"display_name": "Python 3 (ipykernel)",
926+
"display_name": "dev_venv_11",
922927
"language": "python",
923928
"name": "python3"
924929
},
@@ -932,7 +937,7 @@
932937
"name": "python",
933938
"nbconvert_exporter": "python",
934939
"pygments_lexer": "ipython3",
935-
"version": "3.12.3"
940+
"version": "3.11.12"
936941
}
937942
},
938943
"nbformat": 4,

doc/using_pypesto.bib

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,4 +439,34 @@ @Article{PathiranaBer2025
439439
url = {https://www.biorxiv.org/content/early/2025/05/15/2025.05.12.653312},
440440
}
441441

442+
@Article{WielandHas2025,
443+
author = {Wieland, Vincent and Hasenauer, Jan},
444+
journal = {Journal of Mathematical Biology},
445+
title = {A stochastic modelling framework for cancer patient trajectories: combining tumour growth, metastasis, and survival},
446+
year = {2025},
447+
issn = {1432-1416},
448+
month = may,
449+
number = {6},
450+
volume = {90},
451+
creationdate = {2025-06-02T08:42:13},
452+
doi = {10.1007/s00285-025-02229-6},
453+
modificationdate = {2025-06-02T08:42:13},
454+
publisher = {Springer Science and Business Media LLC},
455+
}
456+
457+
@Article{ErnstBan2025,
458+
author = {Ernst, Ariane and Bankowski, Anastasia and Jusyte, Meida and Okunola, Toluwani and Petrov, Tino and Walter, Alexander M. and Winkelmann, Stefanie},
459+
journal = {Bulletin of Mathematical Biology},
460+
title = {Parameter Optimization for a Neurotransmission Recovery Model},
461+
year = {2025},
462+
issn = {1522-9602},
463+
month = jul,
464+
number = {8},
465+
volume = {87},
466+
creationdate = {2025-07-14T06:35:14},
467+
doi = {10.1007/s11538-025-01486-2},
468+
modificationdate = {2025-07-14T06:35:14},
469+
publisher = {Springer Science and Business Media LLC},
470+
}
471+
442472
@Comment{jabref-meta: databaseType:bibtex;}

pypesto/ensemble/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
get_umap_representation_parameters,
1717
get_umap_representation_predictions,
1818
)
19-
from .ensemble import Ensemble, EnsemblePrediction, get_percentile_label
19+
from .ensemble import (
20+
Ensemble,
21+
EnsemblePrediction,
22+
calculate_cutoff,
23+
get_percentile_label,
24+
)
2025
from .util import (
2126
read_ensemble_prediction_from_h5,
2227
read_from_csv,

pypesto/ensemble/ensemble.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,13 +1222,22 @@ def calculate_cutoff(
12221222
percentile: float = 95,
12231223
cr_option: str = SIMULTANEOUS,
12241224
):
1225-
"""
1226-
Calculate the cutoff of the ensemble.
1225+
r"""
1226+
Calculate the cutoff of the objective function values of the ensemble.
12271227
12281228
Based on the number of parameters of the problem. Based on the
12291229
assumption that the difference of the nllh's of the true and optimal
12301230
parameter is chi^2 distributed with n_theta degrees of freedom.
12311231
1232+
The ensemble is created based on
1233+
:math:`-2\log(\mathcal{L}(\theta)/\mathcal{L}(\hat{\theta})) =
1234+
-2\log(\mathcal{L}(\theta)) - (-2\log(\mathcal{L}(\hat{\theta}))) =
1235+
2(J(\theta) - J(\hat{\theta}))) \leq \Delta_{\alpha}`, where :math:`\mathcal{L}` is the likelihood,
1236+
:math:`J` is the negative log-likelihood, :math:`\Delta_{\alpha}` is a percentile of the
1237+
:math:`\chi^2` distribution and :math:`J(\hat{\theta})` is the smallest objective function value
1238+
found during optimization. The ensemble contains all the parameter vectors :math:`\theta` that satisfy
1239+
:math:`J(\theta)\leq J(\hat{\theta}) + \Delta_{\alpha}/2`.
1240+
12321241
Parameters
12331242
----------
12341243
result:
@@ -1264,7 +1273,7 @@ def calculate_cutoff(
12641273
# degrees of freedom is equal to 1
12651274
df = 1
12661275

1267-
range = chi2.ppf(q=percentile / 100, df=df)
1276+
range = chi2.ppf(q=percentile / 100, df=df) / 2
12681277
return fval_opt + range
12691278

12701279

pypesto/petab/objective_creator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ def __init__(
623623
if rr is None:
624624
if roadrunner is None:
625625
raise ImportError(
626-
"The `roadrunner` package is required for this objective "
627-
"function."
626+
"The `roadrunner` package (on PyPI: `libroadrunner`) "
627+
"is required for this objective function."
628628
)
629629
rr = roadrunner.RoadRunner()
630630
self.rr = rr

0 commit comments

Comments
 (0)