Skip to content

09. Identifiability and the posterior

Download the notebook (executed for this page) · source

What this tutorial shows. What a fit can and cannot say about its parameters. Three tools, all on the run's PEtab problem: profile likelihoods (which parameters the data bound, and the labels of parameter_status.csv), the Laplace posterior (a normal approximation on ln θ at the fit), and MCMC with the zeus ensemble sampler (the posterior of one protein's rates without the normal approximation). At the end, the posterior draws are propagated to dense prediction bands (phoskintime analyze ensemble).

Place in the series. Tutorial 07 fitted the model and tutorial 08 measured how well. This tutorial asks how well the parameters are determined. Tutorial 10 runs the whole chain from the command line.

Data. The synthetic example (phoskintime.networkmodel.example), written to a temporary folder. The curves and weights are invented, and the run is kept small (two starts, one profile, short chains), so the numbers below illustrate the outputs, not converged results.

Contrast with KinOpt and TFOpt

KinOpt and TFOpt check their solutions with the KKT conditions of a constrained least-squares problem (KinOpt 08, TFOpt 08). PhosKinTime's parameters are rates of an ODE system with box bounds only, fitted by sbmlsim (or AMICI and pyPESTO); the question here is not whether the optimizer stopped at a stationary point but whether the data determine the value it stopped at.

# Setup. Find the repository root (the folder with configs/config.toml and phoskintime/), put it on sys.path and work from
# there. A Jupyter kernel started outside pixi does not get pixi's PYTHONPATH, hence the sys.path line.
import json
import logging
import os
import re
import subprocess
import sys
import tempfile
import time
from pathlib import Path

REPO_ROOT = Path.cwd().resolve()
while not ((REPO_ROOT / "configs" / "config.toml").is_file() and (REPO_ROOT / "phoskintime").is_dir()):
    if REPO_ROOT.parent == REPO_ROOT:
        raise RuntimeError("Start this notebook inside the PhosKinTime repository.")
    REPO_ROOT = REPO_ROOT.parent
if str(REPO_ROOT) not in sys.path:
    sys.path.insert(0, str(REPO_ROOT))
os.chdir(REPO_ROOT)

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

pd.set_option("display.width", 160)
pd.set_option("display.max_columns", 30)
logging.disable(logging.INFO)  # hide PhosKinTime's INFO log lines; warnings are still shown

from phoskintime.networkmodel import api

# Everything this tutorial writes goes into a new temporary folder, never into the repository.
WORK = Path(tempfile.mkdtemp(prefix="phoskintime-tutorial-09-"))


def set_toml(conf, values):
    """Set ``key = <TOML literal>`` on the first line of each key in ``conf`` (only this project's config changes)."""
    text = Path(conf).read_text(encoding="utf-8")
    for key, literal in values.items():
        text, n = re.subn(rf"(?m)^{re.escape(key)}\s*=.*$", f"{key} = {literal}", text, count=1)
        if n != 1:
            raise KeyError(key)
    Path(conf).write_text(text, encoding="utf-8")


def show_settings(conf, keys):
    """Print the lines of ``conf`` that set one of ``keys`` (first occurrence each)."""
    seen = set()
    for line in Path(conf).read_text(encoding="utf-8").splitlines():
        key = line.split("=")[0].strip()
        if key in keys and key not in seen:
            seen.add(key)
            print(line)

1. One run with profiles and a posterior

The profiles and the posterior read the objective as a log-likelihood and a log-posterior, so the run uses the likelihood data term of tutorial 06 (observation_model = "log_fc_gaussian", in nats) with the priors file in likelihood mode (priors_likelihood.toml). In config.toml:

  • profile_likelihood = true and profile_indices: which parameters to profile (θ indices; here 0, A_i[A]);
  • [networkmodel.posterior] method = "mcmc": the Laplace posterior, then zeus MCMC started from it ("laplace" stops after the Laplace posterior);
  • [networkmodel.posterior.mcmc]: the sampler. proteins = ["A"] samples protein A's own rates with every other parameter at the best fit (scope = "protein", a conditional posterior; "network" samples all parameters jointly). The chains here are far too short for converged results; the defaults are 1000 to 20000 steps.

With only two starts the run uses seed = 3; under the log-likelihood some starts of this example end in a failed solve (they are recorded as failed and not selected), and with two starts that can leave too few.

CONF = api.write_example(WORK / "project", n_starts=2, cores=4)
set_toml(CONF, {"seed": "3", "observation_model": '"log_fc_gaussian"',
                "prior_file": f'"{(REPO_ROOT / "configs" / "priors_likelihood.toml").as_posix()}"',
                "profile_likelihood": "true", "profile_indices": '"0"',
                "method": '"mcmc"', "laplace_draws": "500",
                "proteins": '["A"]', "walkers_per_dim": "2", "min_steps": "200", "max_steps": "400",
                "checkpoint_every": "100"})
show_settings(CONF, {"seed", "observation_model", "prior_file", "profile_likelihood", "profile_indices", "method",
                     "laplace_draws", "proteins", "scope", "walkers_per_dim", "chains", "min_steps", "max_steps"})
seed = 3
observation_model = "log_fc_gaussian"
prior_file = "<repository>/configs/priors_likelihood.toml"
profile_likelihood = true
profile_indices = "0"
method = "mcmc"
laplace_draws = 500
proteins = ["A"]
scope = "protein"
walkers_per_dim = 2
chains = 2
min_steps = 200
max_steps = 400

This run takes a few minutes: the fit, one profile, the Laplace posterior and two short chains.

t0 = time.perf_counter()
RUN = api.run(CONF, output_dir=WORK / "run", log=WORK / "run.log")
print(f"run finished in {time.perf_counter() - t0:.0f} s: {RUN}")
meta = json.loads((RUN / "metadata.json").read_text(encoding="utf-8"))
print("fit objective:", meta["multistart"]["objective"], "| posterior method:",
      meta["effective_settings"]["posterior"]["method"])
run finished in 578 s: /tmp/phoskintime-tutorial-09-3n76jw0_/run
fit objective: posterior | posterior method: mcmc

2. Profile likelihoods

A profile fixes one parameter at a time on a grid and re-optimizes all the others; the profile is the best objective at each grid value. If the data bound the parameter, the profile rises on both sides of the optimum. In PhosKinTime (network model page):

  • profiles are data-only: the prior is off, both for the reference optimum and for every refit;
  • the reference f_ref is the best converged data-only refit from the fitted values and from the best kept multistart solutions (profiles/profile_reference.json);
  • the profile itself is sbmlsim's (sbmlsim.fit.identifiability.profile_likelihood: adaptive steps in log parameter space, all other parameters re-optimised at every point);
  • a side is bounded when the data-only objective rises by at least the threshold. Under log_fc_gaussian it is the exact likelihood-ratio threshold χ²(1, 0.95)/2 = 1.92 nats; under the default linear_fc_mse it is the approximation χ²(1, 0.95) · f_ref / n_eff (the objective is then a sum of MSEs, not a likelihood; KNOWN_ISSUES N6);
  • a point below the reference means the reference was not the data-only minimum: the reference is refitted from it and the profiles are recomputed (at most three rounds).

The reference of this run:

ref = json.loads((RUN / "profiles" / "profile_reference.json").read_text(encoding="utf-8"))
for key in ("status", "usable", "f_ref", "f_at_theta_hat", "n_eff", "threshold", "observation_model", "prior", "engine"):
    print(f"{key:18s} {ref.get(key)}")
status             converged
usable             True
f_ref              -248.7490703467247
f_at_theta_hat     -246.36051749732172
n_eff              128
threshold          1.920729410347062
observation_model  log_fc_gaussian
prior              off (data-only objective)
engine             sbmlsim
prof = pd.read_csv(RUN / "profiles" / "profile_likelihood_summary.csv")
name = prof["parameter_name"].iloc[0]
p = prof[prof["parameter_name"] == name].sort_values("grid_value_physical")
display(p[["side", "grid_value_physical", "objective_value", "delta_objective", "convergence_status"]])
fig, ax = plt.subplots(figsize=(5, 3))
for status, g in p.groupby("convergence_status"):
    ax.plot(g["grid_value_physical"], g["delta_objective"], "o", label=status)
ax.plot(p["grid_value_physical"], p["delta_objective"], "-", color="grey", lw=0.8)
ax.axhline(ref["threshold"], color="tab:red", ls="--", lw=0.8, label="threshold")
ax.set_xscale("log")
ax.set_xlabel(f"{name} (physical)")
ax.set_ylabel("data-only objective − f_ref (nats)")
ax.set_title(f"Profile of {name}")
ax.legend(fontsize=7)
plt.tight_layout()
plt.show()
side grid_value_physical objective_value delta_objective convergence_status
10 below 0.010183 -246.821043 1.928028 converged
8 below 0.010421 -247.473693 1.275377 converged
6 below 0.010663 -247.925071 0.824000 converged
4 below 0.010975 -248.262134 0.486937 converged
2 below 0.011625 -248.638070 0.111000 converged
0 reference 0.012314 -248.749070 0.000000 converged
1 above 0.015502 -248.600648 0.148422 converged
3 above 0.017394 -248.307671 0.441399 converged
5 above 0.018424 -247.985852 0.763218 converged
7 above 0.018962 -247.752985 0.996085 converged
9 above 0.019516 -247.447924 1.301146 converged
11 above 0.019971 -247.140476 1.608595 converged
12 above 0.020436 -246.764194 1.984876 converged

png

Only converged refits count for the label: a point whose refit failed is not the minimum over the other parameters.

3. The labels of parameter_status.csv

Every fitted value is listed in parameter_status.csv (and in metadata.json under parameter_status):

status = pd.read_csv(RUN / "parameter_status.csv")
status[["parameter", "value", "lower", "upper", "status", "label", "is_estimate", "value_data_only",
        "profile_lower", "profile_upper", "fit_inside_interval"]].head(12)
parameter value lower upper status label is_estimate value_data_only profile_lower profile_upper fit_inside_interval
0 A_i[A] 0.012585 0.000016 7.523976 interior; fitted value set by the prior estimate (two-sided); fitted value set by the ... False 0.012314 0.010186 0.020356 False
1 A_i[B] 0.026173 0.000016 7.523976 interior; fitted value set by the prior not assessed; fitted value set by the prior False 0.025536 NaN NaN False
2 A_i[K1] 0.043459 0.000016 7.523976 interior; fitted value set by the prior not assessed; fitted value set by the prior False 0.043401 NaN NaN False
3 A_i[T1] 1.000000 1.000000 1.000000 fixed_no_data_influence not identifiable: no data influence False 1.000000 NaN NaN NaN
4 A_i[T2] 0.058092 0.000016 7.523976 interior; fitted value set by the prior not assessed; fitted value set by the prior False 1.430725 NaN NaN False
5 A_i[T3] 0.003903 0.000016 7.523976 interior; fitted value set by the prior not assessed; fitted value set by the prior False 0.003929 NaN NaN False
6 B_i[A] 0.025820 0.000110 0.575646 interior; fitted value set by the prior not assessed; fitted value set by the prior False 0.024721 NaN NaN False
7 B_i[B] 0.012397 0.000110 0.575646 interior; fitted value set by the prior not assessed; fitted value set by the prior False 0.012218 NaN NaN False
8 B_i[K1] 0.117539 0.000110 0.575646 interior; fitted value set by the prior not assessed; fitted value set by the prior False 0.116266 NaN NaN False
9 B_i[T1] 0.050000 0.050000 0.050000 fixed_no_data_influence not identifiable: no data influence False 0.050000 NaN NaN NaN
10 B_i[T2] 0.015450 0.000110 0.575646 interior; fitted value set by the prior not assessed; fitted value set by the prior False 0.019638 NaN NaN False
11 B_i[T3] 0.007944 0.000110 0.575646 interior; fitted value set by the prior not assessed; fitted value set by the prior False 0.008049 NaN NaN False

Two columns describe a value:

  • status says where the value sits: "interior"; at a bound ("at_bound"); at a bound set by the sampling design ("below_resolvable_rate", "above_resolvable_rate": a rate too slow or too fast for the observation times to resolve); or fixed because the network gives it no effect on the data ("fixed_no_data_influence"). "fitted value set by the prior" is added when the data-only objective at the fit is more than the threshold above f_ref.
  • label is the identifiability label from the profile. Only "estimate (two-sided)" makes a value a point estimate (is_estimate). Every other label marks a model setting that reproduces the fit, not a measurement. Parameters without a profile are "not assessed".

From a profile with a usable reference the labels follow from the two sides:

below the reference above the reference label
bounded bounded estimate (two-sided)
flat bounded upper limit only
bounded flat lower limit only
flat flat not identifiable (flat)
fewer than 2 usable points either not assessed (or "… (other side not assessed)")

The function that labels a run's profiles, phoskintime.networkmodel.utils.identifiability_from_profile, can be applied to hand-made profiles. The four shapes below are invented to show the rule; they come from no fit. They use the likelihood threshold of phoskintime.networkmodel.utils.profile_threshold.

from phoskintime.networkmodel.utils import identifiability_from_profile, profile_threshold

f_ref, n_eff, centre = 0.0, 115, 1.0
threshold = profile_threshold(f_ref, n_eff, observation_model="log_fc_gaussian")
print(f"threshold = chi2(1, 0.95) / 2 = {threshold:.4f} nats")
grid = {"below": centre * 10.0 ** -np.arange(1, 5) / 2, "above": centre * 10.0 ** np.arange(1, 5) / 2}
rise = lambda x: 3.0 * np.log10(x / centre) ** 2  # rises by 3 nats per squared decade
flat = lambda x: 1e-3 * np.ones_like(x)
shapes = {"both sides rise": (rise, rise), "flat below, rises above": (flat, rise),
          "rises below, flat above": (rise, flat), "flat on both sides": (flat, flat)}
fig, axes = plt.subplots(1, 4, figsize=(14, 3), sharey=True)
for ax, (title, (f_below, f_above)) in zip(axes, shapes.items()):
    rows = []
    for side, f in (("below", f_below), ("above", f_above)):
        for x in grid[side]:
            rows.append({"side": side, "grid_value_physical": x, "objective_value": f_ref + float(f(np.array([x]))[0]),
                         "convergence_status": "converged", "parameter_name": "example"})
    profile = pd.DataFrame(rows)
    out = identifiability_from_profile(profile, f_ref, threshold, center_physical=centre, bounds_physical=(1e-4, 1e4))
    q = profile.sort_values("grid_value_physical")
    ax.plot(q["grid_value_physical"], q["objective_value"] - f_ref, "o-")
    ax.axhline(threshold, color="tab:red", ls="--", lw=0.8)
    ax.set_xscale("log")
    ax.set_title(f"{title}\n-> {out['label']}", fontsize=9)
    ax.set_xlabel("parameter value (invented)")
axes[0].set_ylabel("objective - f_ref (nats)")
plt.tight_layout()
plt.show()
threshold = chi2(1, 0.95) / 2 = 1.9207 nats

png

Caveats

  • The labels are provisional (KNOWN_ISSUES N30): a refit can miss the valley the fit found, so an interval can be too narrow and a label too optimistic.
  • The threshold assumes independent residuals. MS series are Gaussian-process-smoothed means, so their residuals are correlated (N36); n_eff_rule = "autocorrelation" corrects for that.
  • Labels and fitted values describe different optima. Profiles are data-only, the fit includes the prior (N29).
  • The inputs are fixed. A label says what the data determine given the KinOpt and TFOpt weights; if those are wrong (N38, N32), every label inherits the error.

4. The Laplace posterior

method = "laplace" (and the first step of "mcmc") approximates the posterior by a normal distribution on ℓ = ln θ at the fit, with the covariance from the Hessian of the negative log posterior (sbmlsim). Draws of this normal, mapped back to θ, are written to posterior/posterior_samples.csv; the summary has their mean, sd and quantiles, and the contraction 1 − var(posterior) / var(prior): near 1 the data determine the parameter, near 0 the prior does.

diag = json.loads((RUN / "posterior" / "posterior_diagnostics.json").read_text(encoding="utf-8"))
print("method:", diag["method"], "| engine:", diag["engine"], "| draws:", diag["draws"])
print("contraction bands:", diag["contraction_bands"])
print("problems:", *diag["problems"][:4], sep="\n  ")
laplace = pd.read_csv(RUN / "posterior" / "posterior_summary.csv")
laplace[["parameter", "mean", "sd", "q2.5", "median", "q97.5", "contraction", "identifiability"]].round(4)
method: laplace | engine: sbmlsim | draws: 500
contraction bands: > 0.9 data-determined, 0.5-0.9 partly, 0.2-0.5 weakly, < 0.2 prior-dominated
problems:
  the 95 % interval of 'ln_A_T2' reaches past a bound, which cuts off the posterior
  the 95 % interval of 'ln_E_A' reaches past a bound, which cuts off the posterior
  the 95 % interval of 'ln_E_B' reaches past a bound, which cuts off the posterior
  the 95 % interval of 'ln_E_K1' reaches past a bound, which cuts off the posterior
parameter mean sd q2.5 median q97.5 contraction identifiability
0 A_i[A] 0.0137 0.0058 0.0056 0.0126 0.0281 0.9796 data-determined
1 A_i[B] 0.0272 0.0076 0.0153 0.0262 0.0447 0.9909 data-determined
2 A_i[K1] 0.0442 0.0085 0.0300 0.0435 0.0630 0.9956 data-determined
3 A_i[T2] 9.3029 1489.7620 0.0001 0.0581 29.9396 -0.2334 prior-dominated
4 A_i[T3] 0.0039 0.0006 0.0029 0.0039 0.0052 0.9975 data-determined
5 B_i[A] 0.0269 0.0079 0.0147 0.0258 0.0455 0.9765 data-determined
6 B_i[B] 0.0127 0.0028 0.0081 0.0124 0.0190 0.9865 data-determined
7 B_i[K1] 0.1209 0.0293 0.0736 0.1175 0.1878 0.9839 data-determined
8 B_i[T2] 0.0332 0.0633 0.0014 0.0155 0.1747 0.5678 partly determined
9 B_i[T3] 0.0083 0.0024 0.0046 0.0079 0.0138 0.9776 data-determined
10 C_i[A] 0.0681 0.0069 0.0555 0.0677 0.0827 0.9990 data-determined
11 C_i[B] 0.0094 0.0024 0.0056 0.0091 0.0149 0.9941 data-determined
12 C_i[K1] 0.3033 0.0330 0.2437 0.3015 0.3730 0.9989 data-determined
13 C_i[T2] 13.1654 4579.0324 0.0000 0.0379 30.9074 -0.0885 prior-dominated
14 C_i[T3] 0.0180 0.0025 0.0136 0.0178 0.0234 0.9982 data-determined
15 D_i[A] 0.0399 0.0073 0.0274 0.0392 0.0560 0.9947 data-determined
16 D_i[B] 0.0174 0.0038 0.0112 0.0170 0.0260 0.9925 data-determined
17 D_i[K1] 0.1346 0.0362 0.0774 0.1300 0.2183 0.9888 data-determined
18 D_i[T2] 0.9354 33.1067 0.0001 0.0264 4.9590 -0.1476 prior-dominated
19 D_i[T3] 0.0091 0.0026 0.0051 0.0087 0.0151 0.9876 data-determined
20 E_i[A] 5.6589 15.4639 0.1109 1.9447 34.1160 0.6563 partly determined
21 E_i[B] 2.4272 2.7557 0.2696 1.6043 9.5473 0.8668 partly determined
22 E_i[K1] 8.2059 13.5388 0.4497 4.2533 40.2319 0.7886 partly determined
23 c_k[K1] 1.2441 3.0962 0.0296 0.4638 7.2789 0.6454 partly determined
24 c_k[K2] 3.6885 5.5594 0.2414 2.0392 17.2261 0.6763 partly determined
25 tf_scale 0.7341 0.7890 0.0897 0.5000 2.7856 -0.7382 prior-dominated
26 Dp_i[A_S_1] 0.0683 1.6350 0.0000 0.0029 0.3986 -0.0219 prior-dominated
27 Dp_i[A_S_2] 0.0646 1.3600 0.0000 0.0031 0.3874 0.0193 prior-dominated
28 Dp_i[B_Y_4] 0.0097 0.0409 0.0001 0.0023 0.0644 0.5288 partly determined
29 Dp_i[K1_T_3] 0.0833 1.9172 0.0000 0.0036 0.4900 -0.0094 prior-dominated
30 sigma[protein] 0.0024 0.0020 0.0004 0.0018 0.0077 0.4646 weakly determined
31 sigma[mrna] 0.4591 0.0962 0.2993 0.4493 0.6744 0.9571 data-determined
32 sigma[phospho] 0.2165 0.0305 0.1628 0.2144 0.2822 0.9803 data-determined

The normal is an approximation. It is poor where the posterior is cut off by a bound (problems lists those parameters) or skewed; MCMC does not need it.

5. MCMC with zeus

The sampler draws from the posterior itself, log p(ℓ) = −objective(e^ℓ) inside the bounds (the objective is the negative log posterior in nats). zeus is an ensemble slice sampler: walkers_per_dim × dimension walkers per chain, started in a small ball around the Laplace mean, independent chains for the split-R̂ check, and the chains are saved to HDF5 so a rerun continues them. With scope = "protein" the posterior is conditional on the other parameters at the fit, so its Laplace counterpart is the conditional normal (narrower than the joint marginal). The job's folder:

job = RUN / "mcmc" / "A"
print(sorted(p.name for p in job.iterdir()))
mc_diag = json.loads((job / "diagnostics.json").read_text(encoding="utf-8"))
print("steps per chain:", meta["posterior_mcmc"]["A"]["steps_per_chain"])
mcmc = pd.read_csv(job / "posterior_summary.csv")
mcmc[["parameter", "mean", "sd", "q2.5", "median", "q97.5", "ess", "act", "split_r"]].round(4)
['chain_0_seg0.h5', 'chain_1_seg0.h5', 'corner.pdf', 'corner.png', 'diagnostics.json', 'laplace_vs_mcmc.csv', 'posterior_samples.csv', 'posterior_summary.csv', 'state.json']
steps per chain: [400, 400]
parameter mean sd q2.5 median q97.5 ess act split_r
0 A_i[A] 0.0128 0.0006 0.0118 0.0128 0.0143 130.1018 43.0432 1.4573
1 B_i[A] 0.0267 0.0021 0.0234 0.0264 0.0322 123.4864 45.3491 1.5344
2 C_i[A] 0.0666 0.0032 0.0592 0.0668 0.0725 131.4083 42.6153 1.2859
3 D_i[A] 0.0381 0.0030 0.0307 0.0384 0.0434 113.0990 49.5141 1.6941
4 E_i[A] 1.9613 0.1212 1.7303 1.9605 2.2005 58.3331 96.0004 1.0550
5 Dp_i[A_S_1] 0.0032 0.0025 0.0004 0.0024 0.0095 32.6355 171.5922 2.4363
6 Dp_i[A_S_2] 0.0027 0.0020 0.0004 0.0021 0.0084 45.4733 123.1491 2.8116
  • act is the integrated autocorrelation time in steps, ess the effective sample size, split_r the split-R̂ over the chains (near 1 for chains that agree). A run stops when the chain is longer than convergence_act times the autocorrelation time, that time is stable, and |R̂ − 1| is below convergence_split_r, or at max_steps.
  • With 200 to 400 steps these numbers are not converged; read them as the layout of the output.

MCMC against the conditional Laplace normal, parameter by parameter (laplace_vs_mcmc.csv), and the corner plot:

cmp = pd.read_csv(job / "laplace_vs_mcmc.csv")
display(cmp[["parameter", "laplace_ln_mean", "mcmc_ln_mean", "laplace_ln_sd", "mcmc_ln_sd",
             "sd_ratio_mcmc_over_laplace"]].round(4))
from IPython.display import Image

Image(filename=str(job / "corner.png"), width=650)
parameter laplace_ln_mean mcmc_ln_mean laplace_ln_sd mcmc_ln_sd sd_ratio_mcmc_over_laplace
0 A_i[A] -4.3753 -4.3563 0.0471 0.0478 1.0465
1 B_i[A] -3.6566 -3.6245 0.0756 0.0777 1.0907
2 C_i[A] -2.6920 -2.7109 0.0455 0.0484 1.0281
3 D_i[A] -3.2391 -3.2717 0.0930 0.0823 0.8275
4 E_i[A] 0.6651 0.6717 0.0682 0.0617 0.9108
5 Dp_i[A_S_1] -5.8597 -6.0706 2.4642 0.8427 0.0020
6 Dp_i[A_S_2] -5.7877 -6.1931 2.4028 0.7654 0.0021

png

6. From draws to predictions: phoskintime analyze ensemble

The ensemble analysis simulates the run's SBML model for posterior draws on a dense time grid and writes quantile bands of the fold changes, phase portraits, flux bands, the smoothing view at the observed times and the protein's equations. Its settings are [analysis.ensemble] in a config file; here protein A, the MCMC draws, 100 draws on 500 points over 24 h, bands and smoothing only.

set_toml(CONF, {"source": '"mcmc"', "horizon_h": "24.0", "n_points": "500", "n_draws": "100",
                "outputs": '["bands", "smoothing"]'})
# The section's own proteins key (the first "proteins =" line of the file is the sampler's).
parts = CONF.read_text(encoding="utf-8").split("[analysis.ensemble]", 1)
parts[1] = re.sub(r'(?m)^proteins\s*=.*$', 'proteins = ["A"]', parts[1], count=1)
CONF.write_text("[analysis.ensemble]".join(parts), encoding="utf-8")

env = {**os.environ, "NO_COLOR": "1", "MPLBACKEND": "Agg"}
done = subprocess.run([sys.executable, "-m", "phoskintime.config.cli", "analyze", "ensemble", "--run", str(RUN),
                       "--conf", str(CONF)], cwd=REPO_ROOT, env=env, capture_output=True, text=True)
print("exit code:", done.returncode)
ens = RUN / "analysis" / "ensemble" / "A"
print(sorted(p.name for p in ens.iterdir()))
exit code: 0
['bands.csv', 'bands.pdf', 'bands.png', 'smoothing.csv', 'smoothing.pdf', 'smoothing.png']
Image(filename=str(ens / "bands.png"), width=900)

png

The bands are the spread of the model over the posterior draws (no observation noise); the smoothing view adds the noise σ_m for the posterior-predictive intervals at the observed times. Beyond the last data time the kinase drive follows the run's extrapolation, so the bands there are model extrapolation, not data.

Summary

  • Profiles are data-only and computed in sbmlsim; only converged refits count; only "estimate (two-sided)" is a point estimate, and all labels are provisional (N30).
  • The Laplace posterior is a normal on ln θ at the fit with a contraction per parameter; problems lists where the normal is cut off by a bound.
  • zeus MCMC samples the posterior without the normal approximation, per protein (conditional) or for the whole network, with ESS, autocorrelation time and split-R̂, resumable from its HDF5 chains.
  • phoskintime analyze ensemble turns posterior draws into dense prediction bands of the SBML model.

Next

10. End-to-end reproducible pipeline: the whole chain from the command line, from the inputs to a run bundle and the exports.