Skip to content

Commit 2001e08

Browse files
Merge pull request #192 from matthiaskoenig/sbmlsim2
Sensitivity and Uncertainty improvements
2 parents 14e0191 + fa4edcf commit 2001e08

34 files changed

+2816
-266
lines changed

.bumpversion.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ commit_args = ""
1717

1818
[[tool.bumpversion.files]]
1919
filename = "./src/sbmlsim/__init__.py"
20+
filename = "./_docs/_quarto.yml"

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ pip install git+https://github.com/matthiaskoenig/sbmlsim.git@develop
3939
```
4040

4141
## How to cite
42-
[![](https://zenodo.org/badge/55952847.svg)](https://zenodo.org/badge/latestdoi/55952847)
43-
42+
[![DOI](https://zenodo.org/badge/55952847.svg)](https://zenodo.org/badge/latestdoi/55952847)
4443

4544
## License
4645
- Source Code: [MIT](https://opensource.org/license/MIT)

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* update release notes in `release-notes` with commit
55
* make sure all tests run (`tox -p`)
66
* check formating and linting (`ruff check`)
7-
* build documentation
7+
* build documentation (`cd _docs | quartodoc build | quatro render`)
88
* test bump version (`uvx bump-my-version bump [major|minor|patch] --dry-run -vv`)
99
* bump version (`uvx bump-my-version bump [major|minor|patch]`)
1010
* `git push --tags` (triggers release)

_docs/_quarto.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ website:
3232
search: true
3333
contents:
3434
- index.qmd
35-
- section: "Analysis"
35+
# - section: "Analysis"
3636
# contents:
3737
# - text: Sensitivity Analysis
3838
# href: sensitivity.qmd
39-
- section: "API"
39+
- section: "Reference"
4040
contents:
41-
- text: "Sensitivity"
41+
- text: "Overview"
4242
href: api/index.qmd
43-
- text: "`sensitivity`"
43+
44+
- text: "Sensitivity & Uncertainty"
4445
href: api/sensitivity.qmd
4546
- text: "`sensitivity_fast`"
4647
href: api/sensitivity.sensitivity_fast.qmd
@@ -52,6 +53,13 @@ website:
5253
href: api/sensitivity.sensitivity_sobol.qmd
5354
- text: "`sensitivity_sampling`"
5455
href: api/sensitivity.sensitivity_sampling.qmd
56+
- text: "`classification`"
57+
href: api/sensitivity.classification.qmd
58+
59+
60+
- text: "Parameter optimization"
61+
href: api/fit.qmd
62+
5563
- section: "Contributing"
5664
contents:
5765
- href: development.qmd
@@ -99,8 +107,8 @@ quartodoc:
99107
dir: api
100108

101109
sections:
102-
- title: API sensitivity
103-
desc: Sensitivity functionality.
110+
- title: Sensitivity
111+
desc: Functionality related to sensitivity and uncertainty analysis.
104112
contents:
105113
# the functions being documented in the package.
106114
# you can refer to anything: class methods, modules, etc..
@@ -110,6 +118,11 @@ quartodoc:
110118
- name: sensitivity.sensitivity_sobol
111119
- name: sensitivity.sensitivity_morris
112120
- name: sensitivity.sensitivity_sampling
121+
- name: sensitivity.classification
122+
- title: Parameter optimization
123+
desc: Functionality related to parameter optimization.
124+
contents:
125+
- name: fit
113126

114127
filters:
115128
- interlinks

_docs/api/_sidebar.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ website:
99
- api/sensitivity.sensitivity_sobol.qmd
1010
- api/sensitivity.sensitivity_morris.qmd
1111
- api/sensitivity.sensitivity_sampling.qmd
12-
section: API sensitivity
12+
- api/sensitivity.classification.qmd
13+
section: Sensitivity
14+
- contents:
15+
- api/fit.qmd
16+
section: Parameter optimization
1317
id: api
1418
- id: dummy-sidebar

_docs/api/fit.qmd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# fit { #sbmlsim.fit }
2+
3+
`fit`
4+
5+
Package for parameter fitting and parameter optimization.
6+
7+
For additional resources see for instance
8+
https://petab.readthedocs.io/en/latest/index.html
9+
https://pyabc.readthedocs.io/en/latest/index.html

_docs/api/index.qmd

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Function reference {.doc .doc-index}
22

3-
## API sensitivity
3+
## Sensitivity
44

5-
Sensitivity functionality.
5+
Functionality related to sensitivity and uncertainty analysis.
66

77
| | |
88
| --- | --- |
@@ -12,3 +12,12 @@ Sensitivity functionality.
1212
| [sensitivity.sensitivity_sobol](sensitivity.sensitivity_sobol.qmd#sbmlsim.sensitivity.sensitivity_sobol) | Global sensitivity analysis using Sobol indices. |
1313
| [sensitivity.sensitivity_morris](sensitivity.sensitivity_morris.qmd#sbmlsim.sensitivity.sensitivity_morris) | Morris sensitivity analysis. |
1414
| [sensitivity.sensitivity_sampling](sensitivity.sensitivity_sampling.qmd#sbmlsim.sensitivity.sensitivity_sampling) | Sampling-based sensitivity and uncertainty analysis. |
15+
| [sensitivity.classification](sensitivity.classification.qmd#sbmlsim.sensitivity.classification) | Classification of sensitivities and uncertainties. |
16+
17+
## Parameter optimization
18+
19+
Functionality related to parameter optimization.
20+
21+
| | |
22+
| --- | --- |
23+
| [fit](fit.qmd#sbmlsim.fit) | Package for parameter fitting and parameter optimization. |
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# sensitivity.classification { #sbmlsim.sensitivity.classification }
2+
3+
`sensitivity.classification`
4+
5+
Classification of sensitivities and uncertainties.
6+
7+
## Classes
8+
9+
| Name | Description |
10+
| --- | --- |
11+
| [SensitivityClassification](#sbmlsim.sensitivity.classification.SensitivityClassification) | Sensitivity classification. |
12+
| [UncertaintyClassification](#sbmlsim.sensitivity.classification.UncertaintyClassification) | Uncertainty classification. |
13+
14+
### SensitivityClassification { #sbmlsim.sensitivity.classification.SensitivityClassification }
15+
16+
```python
17+
sensitivity.classification.SensitivityClassification()
18+
```
19+
20+
Sensitivity classification.
21+
22+
### UncertaintyClassification { #sbmlsim.sensitivity.classification.UncertaintyClassification }
23+
24+
```python
25+
sensitivity.classification.UncertaintyClassification()
26+
```
27+
28+
Uncertainty classification.
29+
30+
## Functions
31+
32+
| Name | Description |
33+
| --- | --- |
34+
| [sensitivity_classification](#sbmlsim.sensitivity.classification.sensitivity_classification) | Classification of local sensitivity as per WHO IPCS guidance. |
35+
| [sensitivity_classification_symbol](#sbmlsim.sensitivity.classification.sensitivity_classification_symbol) | Calculates symbol for sensitivity classification. |
36+
| [uncertainty_classification](#sbmlsim.sensitivity.classification.uncertainty_classification) | Classification of uncertainty as per WHO IPCS guidance. |
37+
| [uncertainty_classification_symbol](#sbmlsim.sensitivity.classification.uncertainty_classification_symbol) | Calculates symbol for uncertainty classification. |
38+
39+
### sensitivity_classification { #sbmlsim.sensitivity.classification.sensitivity_classification }
40+
41+
```python
42+
sensitivity.classification.sensitivity_classification(s)
43+
```
44+
45+
Classification of local sensitivity as per WHO IPCS guidance.
46+
47+
Classification based on absolute sensitivity:
48+
49+
- High: `|Si,j| >= 0.5`
50+
- Medium: `0.2 <= |Si,j| < 0.5`
51+
- Low: `0.1 <= |Si,j| < 0.2`
52+
- Negligible: `|Si,j| < 0.1`
53+
54+
#### References {.doc-section .doc-section-references}
55+
56+
International Programme on Chemical Safety (IPCS). Characterization and
57+
application of physiologically based pharmacokinetic models in risk assessment.
58+
World Health Organization; 2010. Contract No.: 9.
59+
60+
### sensitivity_classification_symbol { #sbmlsim.sensitivity.classification.sensitivity_classification_symbol }
61+
62+
```python
63+
sensitivity.classification.sensitivity_classification_symbol(s)
64+
```
65+
66+
Calculates symbol for sensitivity classification.
67+
68+
### uncertainty_classification { #sbmlsim.sensitivity.classification.uncertainty_classification }
69+
70+
```python
71+
sensitivity.classification.uncertainty_classification(u)
72+
```
73+
74+
Classification of uncertainty as per WHO IPCS guidance.
75+
76+
- High: `Ui,j >= 2`
77+
- Medium: `0.3 <= |Ui,j| < 2`
78+
- Low: `0 <= |Ui,j| < 0.3`
79+
80+
#### References {.doc-section .doc-section-references}
81+
82+
International Programme on Chemical Safety (IPCS). Characterization and application of physiologically based pharmacokinetic models in risk assessment.
83+
World Health Organization; 2010. Contract No.: 9.
84+
85+
### uncertainty_classification_symbol { #sbmlsim.sensitivity.classification.uncertainty_classification_symbol }
86+
87+
```python
88+
sensitivity.classification.uncertainty_classification_symbol(u)
89+
```
90+
91+
Calculates symbol for uncertainty classification.

_docs/api/sensitivity.sensitivity_local.qmd

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ Normalized sensitivities are defined as:
3131

3232
S_norm = S * (p0 / q(p0))
3333

34+
Here a multistep method is implemented following Najjar et al.
35+
36+
References:
37+
38+
- Najjar A, Hamadeh A, Krause S, Schepky A, Edginton A. Global sensitivity analysis of Open Systems Pharmacology Suite physiologically based pharmacokinetic models. CPT Pharmacometrics Syst Pharmacol. 2024 Dec;13(12):2052-2067. doi: 10.1002/psp4.13256. Epub 2024 Nov 5. PMID: 39498820; PMCID: PMC11646943.
39+
3440
## Classes
3541

3642
| Name | Description |
@@ -49,6 +55,7 @@ sensitivity.sensitivity_local.LocalSensitivityAnalysis(
4955
n_cores=None,
5056
cache_results=False,
5157
difference=0.01,
58+
n_var=3,
5259
)
5360
```
5461

@@ -72,6 +79,7 @@ decrease) are evaluated in addition to a reference simulation.
7279
| --- | --- |
7380
| [calculate_sensitivity](#sbmlsim.sensitivity.sensitivity_local.LocalSensitivityAnalysis.calculate_sensitivity) | Compute raw and normalized local sensitivities. |
7481
| [create_samples](#sbmlsim.sensitivity.sensitivity_local.LocalSensitivityAnalysis.create_samples) | Create parameter samples for local sensitivity analysis. |
82+
| [dfs_sensitivity](#sbmlsim.sensitivity.sensitivity_local.LocalSensitivityAnalysis.dfs_sensitivity) | Return sensitivity dataframe. |
7583
| [plot](#sbmlsim.sensitivity.sensitivity_local.LocalSensitivityAnalysis.plot) | Generate plots for normalized local sensitivities. |
7684

7785
##### calculate_sensitivity { #sbmlsim.sensitivity.sensitivity_local.LocalSensitivityAnalysis.calculate_sensitivity }
@@ -106,11 +114,20 @@ Create parameter samples for local sensitivity analysis.
106114
For each analysis group, this method constructs a sample matrix
107115
containing:
108116
- One reference parameter vector
109-
- Two perturbed parameter vectors per parameter (±difference)
117+
- n_var perturbed parameter vectors per parameter (+difference)
118+
- n_var perturbed parameter vectors per parameter (-difference)
110119

111120
Samples are stored as an ``xarray.DataArray`` indexed by sample and
112121
parameter identifiers.
113122

123+
##### dfs_sensitivity { #sbmlsim.sensitivity.sensitivity_local.LocalSensitivityAnalysis.dfs_sensitivity }
124+
125+
```python
126+
sensitivity.sensitivity_local.LocalSensitivityAnalysis.dfs_sensitivity()
127+
```
128+
129+
Return sensitivity dataframe.
130+
114131
##### plot { #sbmlsim.sensitivity.sensitivity_local.LocalSensitivityAnalysis.plot }
115132

116133
```python
@@ -121,3 +138,5 @@ Generate plots for normalized local sensitivities.
121138

122139
Produces heatmaps of normalized sensitivities for each analysis group
123140
and saves the figures to the results directory.
141+
142+
Using default cutoff of 0.1 for negligible.

_docs/api/sensitivity.sensitivity_sampling.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ computed, including:
1919
- minimum and maximum
2020
- lower and upper quantiles (5% and 95%)
2121

22+
Uncertainty is calculated as Ui,j = (Percentile97.5(i,j) - Percentile2.5(i,j)) / Percentile50(i,j)
23+
2224
This approach focuses on uncertainty propagation rather than variance-based
2325
sensitivity indices and is therefore complementary to local and Sobol-based
2426
methods.

0 commit comments

Comments
 (0)