Repository navigation
Add petab1to2(reparametrize=...) - #539
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #539 +/- ##
==========================================
+ Coverage 79.06% 79.47% +0.40%
==========================================
Files 70 70
Lines 8164 8278 +114
Branches 1463 1498 +35
==========================================
+ Hits 6455 6579 +124
+ Misses 1220 1209 -11
- Partials 489 490 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2f22c43 to
bdad27e
Compare
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
4be4d4a to
594265d
Compare
reparametrize_log and petab1to2(reparametrize=...)petab1to2(reparametrize=...)
2ce25b5 to
2b7cb7c
Compare
PEtab v2 has no `parameterScale`. To estimate a parameter `<id>` on log
scale, or to specify a prior for `log10(<id>)`, the v2 spec recommends
replacing `<id>` by a new parameter `log10_<id>` with `<id> =
10^log10_<id>`.
This adds `petab.v2.reparametrize_log(problem, parameter_ids, ...)`,
which does this for the given parameters on a copy of the problem and
returns the copy and the mapping of old to new parameter IDs:
* parameter table: log-transformed bounds (dropped for non-estimated
parameters) and nominal value; priors from the `priors` argument, or
derived from `log-normal`, `log-laplace` and `log-uniform` priors on
`<id>` (other priors on `<id>` raise; priors of non-estimated parameters
raise `NotImplementedError` unless dropped via `priors={<id>: None}`)
* SBML model: new parameter `log10_<id>` and initial assignment `<id> =
10^log10_<id>` (replacing any existing one; `<id>` stays
`constant=true`)
* observable/noise formulas and condition target values: `<id>` →
`10^log10_<id>`
* measurement overrides: replaced by the new IDs, numeric overrides are
log-transformed, and the placeholder `ph` is replaced by `10^ph` in the
formulas
A lower bound of `0` becomes `-inf`, following PEtab-dev/PEtab#682. If
other estimated parameters have priors, such a parameter needs an
explicit prior, since the default `uniform(lb, ub)` would be improper;
otherwise, a `ValueError` is raised. A nominal value of `0` becomes
`-inf`, assuming PEtab-dev/PEtab#685 is accepted, e.g., for parameters
fixed at `0`.
Problems with required extensions are not supported.
Base e (`log_<id>`) is supported as well. The procedure follows the one
described in the proposed v1→v2 migration guide (PEtab-dev/PEtab#680).
Split off from #539, which uses this in `petab1to2(reparametrize=...)`
to preserve v1 parameter-scale priors.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
50322ae to
a458869
Compare
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
a458869 to
54362c3
Compare
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a non-normative page "Upgrading from PEtab v1" to the v2 documentation. It lists the structural changes, explains the numerical consequences of the removal of `parameterScale`, describes how to reparametrize log-scaled parameters (`log10_k` with `k = 10^log10_k`), the `reparametrize` option of `petab1to2`, the other changes affecting objective values (log10 observables, truncated priors, default prior), and how to verify a conversion. References #680. The `petab1to2` section describes PEtab-dev/libpetab-python#539. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
dilpath
left a comment
There was a problem hiding this comment.
gradients agree to ≤ 4e-4 of the largest gradient entry
This error is potentially too large?
if their placeholder can't be log-transformed (e.g., Bachmann has
0offsets)
What is the issue here? So, exp(log_offset) does not work for some reason?
For Bachmann, they differ by a constant
Will mean that e.g. a single metadata file in the benchmark collection is insufficient (...unless the metadata file has version-specific information).
54362c3 to
e5ad8e3
Compare
PEtab v2 has no `parameterScale`. Converting a v1 `parameterScaleNormal` prior on a log10-scaled parameter to `log-normal` keeps the prior distribution, but changes the maximum a posteriori estimate. `petab1to2` and `petab_files_1to2` get a `reparametrize` argument to estimate log-scaled parameters as `log10_<id>`/`log_<id>` using `reparametrize_log`, which preserves the objective function: * `"none"` (default): don't reparametrize; warn about converted `parameterScale*` priors * `"priors"`: parameters with `parameterScale*` priors * `"all"`: all estimated log-scaled parameters without priors on linear scale; this also preserves the v1 default prior Log-scaled parameters that share a placeholder with selected parameters are added; for non-estimated ones, a nominal value of 0 becomes -inf, and their priors are converted to log scale as well. With `"all"`, parameters without parameter-scale priors are skipped if their placeholder can't be log-transformed. Parameters with a lower bound of 0 get a lower bound of -inf on log scale; they are skipped if their prior on log scale would be an improper uniform prior. Also, `petab1to2` no longer adds default `uniform` priors to non-estimated parameters, or if no estimated parameter has a prior. The benchmark collection conversion test now also runs with `"all"`. References Benchmarking-Initiative/Benchmark-Models-PEtab#333 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e5ad8e3 to
652da5a
Compare
Yes, it is large, but this is only Crauste and it seems to be about integration errors at those specific nominal parameters, not conversion issues. At the shifted point, the deviation is several orders of magnitude smaller.
The problem occurs if we have a observableFormula with a placeholder that is sometimes a log-scaled parameter, and sometimes a non-positive number. In this case, we'd have to split the observable into one version with
This is due to the missing observable splitting. This could be built on top, but I am not sure it's worth it. Independently of that, we might have the version-specific-information problem also in the case truncation of the prior by the bounds. Depends on how we handle that for v1, where this was unspecified. But that's a discussion for https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab. |
👍
Why is 0 an issue? Since for v2 we define
Yes agreed, fine for me, was just pointing out. |
Same issue as PEtab-dev/PEtab#687 -- so far, placeholder overrides are restricted to finite values or parameters. Intentionally or not, not sure. I guess there could be use cases. Maybe drop a comment there if you think we should extend that to With PEtab-dev/PEtab#687 pretty much accepted, this can be circumvented by adding a fixed parameter |
Placeholders that are overridden by reparametrized parameters are log-transformed, which requires all their overrides to be on log scale. `0` overrides were rejected so far, since `log(0) = -inf` is not a valid override value. They are now replaced by a new non-estimated parameter `negative_infinity` with nominal value `-inf` (assuming PEtab-dev/PEtab#687 is accepted). Only negative overrides still prevent the transformation. With `petab1to2(reparametrize="all")`, this reparametrizes all log-scaled parameters of Bachmann_MSB2011, so that the v1 and v2 log-priors agree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PEtab v2 has no
parameterScale. Converting a v1parameterScaleNormal(μ, σ)prior on alog10-scaled parameter tolog-normal(μ ln10, σ ln10)keeps the prior distribution, but adds a Jacobian term to the v2 MAP objective, which moves the optimum by−σ² ln10decades. No v2 prior over the unscaled parameter can preserve both the distribution and the optimum.petab1to2andpetab_files_1to2get areparametrizeargument, which usespetab.v2.reparametrize_log(#560) to estimatelog10_<id>(orlog_<id>) instead of<id>:"none"(default): current behaviour, now with a warning for convertedparameterScale*priors"priors": log-scaled parameters withparameterScale*priors"all": all estimated log-scaled parameters without priors on linear scale (i.e., withoutlogNormal,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,0overrides are replaced by a new fixed parameternegative_infinitywith 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 withlowerBound = 0(allowed in v1 for log-scaled parameters with an initialization prior) getlowerBound = -infon 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
petab1to2adding defaultuniformpriors to non-estimated parameters, and to all parameters if the v1 parameter table has anobjectivePriorTypecolumn, 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
0then becomes-inf, assuming PEtab-dev/PEtab#685 / PEtab-dev/PEtab#687 is accepted. TheirparameterScale*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 the0overrides were supported, 6 log-scaled Bachmann parameters couldn't be reparametrized, and their v1 default prior became a linearuniform, which preserves the MAP, but changes the log-prior by a constant.)The default is
"none"for now, to keeppetab1to2uninvasive, 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