Skip to content

Commit 8e5a3bf

Browse files
dweindlclaude
andauthored
Add petab1to2(reparametrize=...) (#539)
PEtab v2 has no `parameterScale`. Converting a v1 `parameterScaleNormal(μ, σ)` prior on a `log10`-scaled parameter to `log-normal(μ ln10, σ ln10)` keeps the prior distribution, but adds a Jacobian term to the v2 MAP objective, which moves the optimum by `−σ² ln10` decades. No v2 prior over the unscaled parameter can preserve both the distribution and the optimum. `petab1to2` and `petab_files_1to2` get a `reparametrize` argument, which uses `petab.v2.reparametrize_log` (#560) to estimate `log10_<id>` (or `log_<id>`) instead of `<id>`: * `"none"` (default): current behaviour, now with a warning for converted `parameterScale*` priors * `"priors"`: log-scaled parameters with `parameterScale*` priors * `"all"`: all estimated log-scaled parameters without priors on linear scale (i.e., without `logNormal`, `uniform`, ...); this also preserves the v1 default prior (uniform on parameter scale) Log-scaled parameters sharing a placeholder with selected parameters are added. Such placeholders are substituted by `10^placeholder`, so numeric overrides are log-transformed. Since overrides must be finite, `0` overrides are replaced by a new fixed parameter `negative_infinity` with nominal value `-inf` (assuming PEtab-dev/PEtab#687 is accepted). With `"all"`, parameters without parameter-scale priors are skipped (with a warning) if their placeholder can't be log-transformed, i.e., if it is also overridden by negative numbers or by parameters that are not reparametrized. Parameters with `lowerBound = 0` (allowed in v1 for log-scaled parameters with an initialization prior) get `lowerBound = -inf` on log scale (PEtab-dev/PEtab#682). They are skipped with a warning if their prior on log scale would be an improper uniform prior, i.e., the v1 default prior if other estimated parameters have priors. Also fixes `petab1to2` adding default `uniform` priors to non-estimated parameters, and to all parameters if the v1 parameter table has an `objectivePriorType` column, but no estimated parameter has a prior. Priors of non-estimated parameters are converted as before. Non-estimated parameters are only reparametrized if they share a placeholder with selected parameters. A nominal value of `0` then becomes `-inf`, assuming PEtab-dev/PEtab#685 / PEtab-dev/PEtab#687 is accepted. Their `parameterScale*` priors are converted to log scale as well, unless they depend on missing bounds (then they are dropped with a warning). Checked on the benchmark collection: all 35 problems convert and pass v2 linting with `"all"` (now also tested in CI); with `"priors"`, 44 parameters are reparametrized in Bachmann, Isensee, Raimundez and Schwen. Checked with AMICI (v1 importer vs. v2 `PetabImporter`, forward sensitivities) on 30 benchmark problems converted with `"all"` (5 large ones excluded), at the nominal parameters and at a shifted point: log-likelihoods agree to a relative difference of ≤ 2e-8, and gradients agree to ≤ 2e-5 of the largest gradient entry, except for Crauste at the nominal parameters (4e-4 at rtol/atol 1e-12/1e-16, decreasing with tighter tolerances; 5e-14 at the shifted point). The remaining deviations are due to integration tolerances. Log-priors are identical for Bachmann, Isensee and Raimundez. (Before the `0` overrides were supported, 6 log-scaled Bachmann parameters couldn't be reparametrized, and their v1 default prior became a linear `uniform`, which preserves the MAP, but changes the log-prior by a constant.) The default is `"none"` for now, to keep `petab1to2` uninvasive, i.e., to not change the parametrization unless requested. Open to change. References Benchmarking-Initiative/Benchmark-Models-PEtab#333, PEtab-dev/PEtab#680, PEtab-dev/PEtab#683 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ce80233 commit 8e5a3bf

5 files changed

Lines changed: 957 additions & 30 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
https://github.com/PEtab-dev/libpetab-python/pull/533,
3434
https://github.com/PEtab-dev/libpetab-python/pull/535, and
3535
https://github.com/PEtab-dev/libpetab-python/pull/536)
36+
* `petab1to2` no longer adds default `uniform` priors to non-estimated
37+
parameters, or if no estimated parameter has an objective prior
38+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/539)
3639
* `petab_math_str` now produces valid PEtab math expressions for boolean
3740
operators, (in)equality, `min`/`max`, powers with negative bases, and
3841
`pi`/`e`, and prints floats without loss of precision. PEtab v2 condition
@@ -98,6 +101,10 @@
98101
* `petab.v2.reparametrize_log` estimates parameters on log scale by replacing
99102
them with new log-transformed parameters
100103
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/560)
104+
* `petab1to2` and `petab_files_1to2` can preserve the objective function of
105+
log-scaled parameters with `parameterScale*` priors via
106+
`reparametrize="priors"` or `reparametrize="all"`
107+
(by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/539)
101108

102109
## 0.9 series
103110

0 commit comments

Comments
 (0)