Repository navigation
assignments_to_experiments: convert values that ramp with time, via a rate rule - #557
FFroehlich wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #557 +/- ##
==========================================
+ Coverage 78.07% 78.12% +0.05%
==========================================
Files 68 68
Lines 7823 7846 +23
Branches 1399 1403 +4
==========================================
+ Hits 6108 6130 +22
- Misses 1227 1228 +1
Partials 488 488 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a9279e1 to
d8b0bbf
Compare
|
see also discussion in #556 |
… rate rule A condition change is applied once at the start of its period, with `time` set to the period's start, so a value that changes with time within a period cannot be a condition change on a constant target, and such assignments were rejected. Fujita_SciSignal2010's EGF input is one: `piecewise(EGF_rate * time + EGF_0, time <= EGF_end, 0)`, steps in training and ramps in its held-out data. A value may now change linearly with time. The target then becomes a differential entity, with the rate rule `d target/dt = <target>_slope` and a new constant parameter for the slope, and each period sets both the target's value at the period start and its slope. During preequilibration the value is held at its value at time 0 with slope zero, and the first period after preequilibration sets the slope again. An assignment that only switches between constant values converts exactly as before, as a constant parameter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MNJePorYs9zmPYMam6g4EP
…ifferential The slope parameter is a placeholder at 0; every ramp's start value and slope, including at time 0, are set through the condition table. Constant model parameters in changes at an experiment's start take their model values, since those changes may only refer to parameter table symbols. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MNJePorYs9zmPYMam6g4EP
d8b0bbf to
e960510
Compare
dweindl
left a comment
There was a problem hiding this comment.
Looks good.
Since that function is getting longer and longer, how about converting that into a class and moving some parts to some private helpers (find available ID, add parameter, add RateRule, ...) and encapsulating the currently free non-reusable helpers like _changes? So far, this is unreleased and wouldn't really break much. (Independent of this PR to keep the diff more readable.)
| ): | ||
| additions.append( | ||
| (experiment, period.time, target_id, start_value) | ||
| if i == 0: |
There was a problem hiding this comment.
rename to i_period? i don't recall what i was 50 lines further up.
|
On second thought, turning that into a class is probably not really helpful, because it's just one operation with one result. Slimming down that function would still be good. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| slope.setId(slope_id) | ||
| slope.setConstant(False) | ||
| slope.setValue(0.0) | ||
| rate_rule = sbml_model.createRateRule() |
There was a problem hiding this comment.
There is petab.v2.models._sbml_utils.add_sbml_parameter which already does some more error handling.
Stacked on #556 (merge that first).
assignments_to_experimentsrejects an assignment whose value changes with time within a period, because a condition change is applied once at the start of its period, withtimeset to the period's start: on a constant target it can only step. Fujita_SciSignal2010's EGF input is such an assignment,steps in the training data and ramps (
EGF_0 = 0,EGF_rate > 0) in its held-out data.What. A value may now change linearly with time (its rate of change must not itself depend on time;
time^2,exp(time)are still rejected). The only change to the model is to make the target a differential entity, as the v2 condition table allows targets to be constant or differential entities:d target/dt = <target>_slope, with a new parameter for the slope, a placeholder at 0. Everything else goes through the condition and experiment tables: every period that starts a piece, including the first at time 0, sets both the target's value at the period start and its slope:EGFEGF_slopeEGF_0EGF_endEGF_rateEGF_endThe slope parameter stands in for a
setRateoperation, which earlier v2 drafts had (PEtab-dev/PEtab#581) and which was dropped before release. If it returns, the rate rule becomesd target/dt = 0and the slopes becomesetRaterows.Changes at the start of an experiment may only refer to parameter table symbols, so constant model parameters in them take their model values.
During preequilibration the value is held at its value at time 0 with slope zero (consistent with the existing preequilibration semantics and warning), and the first period after preequilibration sets the slope again. An assignment that only switches between constant values converts exactly as before, as a constant parameter; the rate rule is only introduced where a piece actually ramps.
Checked
Tests: a ramp ending at a switch, Fujita-style pulses and ramps set by the condition table, a ramp after preequilibration;
time^2andexp(time)values rejected.Fujita, PEtab v1 against the v2 upgrade converted by this branch, AMICI at the nominal parameters:
(The test-data problems were loaded without their visualization table, which they share with the training problem and which names datasets their measurement tables lack; the lint rejects them otherwise.)
Brannmark_JBC2010, Isensee_JCB2018 and Raimundez_PCB2020 convert with log-likelihoods identical to assignments_to_experiments: convert assignments that switch more than once #556 (Raimundez with ExperimentsToSbmlConverter: write one flat initial assignment per target #546 merged in, which it needs to import at all).
🤖 Generated with Claude Code
https://claude.ai/code/session_01MNJePorYs9zmPYMam6g4EP