Read the results
The run folder
| open this | for |
|---|---|
timeseries_plots/fit_<protein>.png |
data and model per protein |
goodness_of_fit.png, residuals_table.csv |
how far off, point by point |
model_trajectories.csv |
observed (fc_obs) and predicted (fc_pred) fold change at every measured time |
parameter_status.csv |
every parameter with the label that says what you may claim |
model_parameters_genes.csv, _genes_psites.csv, _kinases.csv |
the same values arranged per gene, site and kinase |
optimization/multistart_summary.csv |
every fit start |
scalar_objective.csv |
the final objective |
network_W_global.csv, network_tf_mat.csv |
the weights the model really used |
model/model.xml |
the fitted SBML model |
metadata.json |
versions, inputs with checksums, settings: your methods section |
results.pkt.zip |
the run bundle |
All files: Run folder layout.
Draw your own fit plot
Save as plot_fit.py in the phoskintime folder:
import sys
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import pandas as pd
run, protein = sys.argv[1], sys.argv[2]
t = pd.read_csv(f"{run}/model_trajectories.csv")
t = t[t.protein == protein].fillna({"psite": ""})
groups = t.groupby(["type", "psite"])
fig, axes = plt.subplots(1, len(groups), figsize=(3.2 * len(groups), 3), sharey=True)
for ax, ((kind, site), g) in zip(axes, groups):
ax.plot(g.time, g.fc_obs, "o", label="data")
ax.plot(g.time, g.fc_pred, "-", label="model")
ax.set_xscale("symlog", linthresh=1)
ax.set_title(f"{protein} {site or kind}")
ax.set_xlabel("minutes")
axes[0].set_ylabel("fold change")
axes[0].legend()
plt.tight_layout()
plt.savefig(f"fit_{protein}.png", dpi=110)
print(f"wrote fit_{protein}.png")
pixi run python plot_fit.py my-project/results A
wrote fit_A.png
The honest part: a fitted number is not a measurement
The computer always returns a number for every parameter. Very often the data would fit just as well with a very different number. Then the number means nothing. This is called non-identifiability, and it is normal in models like these.
So every parameter has a label in parameter_status.csv:
| label | what you may say |
|---|---|
estimate (two-sided) |
the data bound it from below and above. You may report it, with its interval |
upper limit only |
"it is at most ...". The data allow it to be arbitrarily small |
lower limit only |
"it is at least ..." |
not identifiable (flat) |
the data say nothing about it |
not identifiable: no data influence |
nothing measured depends on it; it was fixed |
below resolvable rate / above resolvable rate |
it sits at the limit of what your time points can resolve (too slow, or too fast, to be seen) |
at optimizer bound |
it ran into a search limit |
not assessed |
nobody tested it. This is not "fine". |
After a plain run almost everything is not assessed:
not assessed 28
not identifiable: no data influence 7
above resolvable rate (half-life < 72.2 s) 1
at optimizer bound (upper; not a design bound) 1
Profile likelihoods: the test
For one parameter: fix it at a value, re-fit all the others, and note how much worse the fit is. Repeat for many values. This curve is the profile likelihood. If it rises above a threshold on both sides, the parameter is bounded. The test uses the data only (the prior is switched off).
Profile a few parameters during a run
Parameters are numbered by their row in parameter_status.csv, starting at 0:
awk -F, 'NR>1 {print NR-2, $1}' mymodel/results/parameter_status.csv
0 A_i[SUB]
...
10 c_k[KINA]
11 c_k[KINB]
12 tf_scale
13 Dp_i[SUB_S_10]
...
Make a config that profiles numbers 10, 11 and 13, and run it:
cp mymodel/config.toml mymodel/config_profiles.toml
sed -i.bak -e 's/^profile_likelihood = .*/profile_likelihood = true/' \
-e 's/^profile_indices = .*/profile_indices = "10,11,13"/' \
-e 's#/results"#/results_profiles"#' mymodel/config_profiles.toml
pixi run phoskintime run --conf mymodel/config_profiles.toml
[Profile] walk with restarts: 3 profiles, 576 refits on 4 workers in 95.0 s.
[Identifiability] labels: {'not assessed': 12, 'estimate (two-sided)': 2, 'at optimizer bound (upper; not a design bound)': 1, 'upper limit only': 1}
From mymodel/results_profiles/parameter_status.csv (rounded):
| parameter | label | value_fit | value_data_only | profile_lower | profile_upper |
|---|---|---|---|---|---|
c_k[KINA] |
estimate (two-sided) | 0.073 | 0.265 | 0.039 | 0.398 |
c_k[KINB] |
estimate (two-sided) | 0.018 | 0.023 | 0.0051 | 0.058 |
Dp_i[SUB_S_10] |
upper limit only | 0.0018 | 0.00088 | 0.00088 | 0.014 |
Even the "estimates" are wide: c_k[KINA] is known only to within a factor of ten.
The profiles use profile_walk = "restarts" (the default): every point is re-optimised from the previous point and
from several shaken copies of it (profile_restarts = 8). This costs time and avoids intervals that look narrower
than they are. See Configuration reference.
Profiles are slow on a laptop
Every step is fitted nine times. The work runs in parallel, so the time depends on your number of cores: a model with about 20 parameters takes minutes on a server with many cores, and can take hours on a few.
- Profile only the parameters you care about:
--indices 0,3(orprofile_indicesin the config). - Run it overnight, or on a server; the results do not depend on the number of cores.
--restarts 2is faster for a first look. Repeat with the default before you report intervals: fewer restarts can give intervals that look narrower than they are.
Profile every parameter of a finished run
No refit is needed, and the run is not changed. Results go into <run>/analysis/profiles/:
pixi run phoskintime analyze profiles --runs my-project/results
This is the expensive step
For the 30 free parameters of the small example it took 18 minutes on 32 cores (about 7 core-hours). On a laptop,
start with a few parameters: add --indices 0,1,2.
milestone_profiles.md summarises:
| threshold | f_ref | two-sided | upper only | lower only | flat | data term at θ̂ − f_ref | fit inside interval |
|---|---|---|---|---|---|---|---|
| 0.002132 | 0.07104 | 10 | 9 | 7 | 4 | 0.007171 (3.36 × threshold) | False |
and results_labels.csv has one row per parameter. A few rows (rounded):
| parameter | label | value_fit | value_data_only | lower | upper |
|---|---|---|---|---|---|
B_i[A] |
estimate (two-sided) | 0.074 | 0.054 | 0.015 | 0.53 |
C_i[A] |
upper limit only | 5.57 | 0.000027 | 0.000027 | 0.0028 |
D_i[T3] |
not identifiable (flat) | 0.010 | 0.0079 | 0.00011 | 9.2 |
c_k[K2] |
lower limit only | 3.58 | 5.0 | 1.60 | 5.0 |
Read this carefully:
- Of 30 parameters, 10 are two-sided estimates.
C_i[A]was fitted as 5.57, but the data alone say at most 0.0028. The fitted value came from the prior and from a weaker optimum.fit inside interval: Falsemeans the fitted point is clearly worse, on the data, than the best data-only point. Then no fitted value of this run should be quoted as a point estimate. Quotevalue_data_onlywith its interval, for two-sided parameters only, and consider more starts.
Draw a profile
Save as plot_profile.py:
import json
import sys
import matplotlib
matplotlib.use("Agg") # draw to a file, no window needed
import matplotlib.pyplot as plt
import pandas as pd
folder = sys.argv[1] # .../results/analysis/profiles
name = sys.argv[2] # e.g. "B_i[A]"
points = pd.read_csv(f"{folder}/results/profiles/profile_likelihood_summary.csv")
points = points[(points.parameter_name == name) & (points.convergence_status != "failed")]
points = points.sort_values("grid_value_physical")
with open(f"{folder}/results/profiles/profile_reference.json") as fh:
threshold = json.load(fh)["threshold"]
plt.figure(figsize=(7, 4))
plt.plot(points.grid_value_physical, points.delta_objective, "o-")
plt.axhline(threshold, color="grey", linestyle="--", label="threshold")
plt.ylim(0, 4 * threshold)
plt.xscale("log")
plt.legend()
plt.xlabel(name + " (log scale)")
plt.ylabel("rise of the data-only objective")
plt.tight_layout()
plt.savefig("profile.png", dpi=150)
print(len(points), "points -> profile.png")
pixi run python plot_profile.py my-project/results/analysis/profiles "B_i[A]"

A valley that crosses the dashed line on both sides: two-sided. A curve that stays under it on one side: only a limit. A flat line: nothing known.
With the default objective this threshold is approximate (KNOWN_ISSUES N6). With the likelihood
observation_model = "log_fc_gaussian" it is the standard likelihood-ratio threshold.
Optional: a likelihood and an approximate posterior
For uncertainty as probability ranges, use the log fold-change likelihood (it also estimates the noise) with a Laplace approximation:
cp configs/priors_likelihood.toml mymodel/
cp mymodel/config.toml mymodel/config_unc.toml
sed -i.bak -e 's/^observation_model = .*/observation_model = "log_fc_gaussian"/' \
-e 's/^prior_file = .*/prior_file = "priors_likelihood.toml"/' \
-e 's/^method = "none"/method = "laplace"/' \
-e 's#/results"#/results_unc"#' mymodel/config_unc.toml
pixi run phoskintime run --conf mymodel/config_unc.toml
mymodel/results_unc/posterior/posterior_summary.csv (selected rows and columns, rounded):
| parameter | median | q2.5 | q97.5 | identifiability |
|---|---|---|---|---|
c_k[KINB] |
0.073 | 0.028 | 0.19 | data-determined |
c_k[KINA] |
0.135 | 0.040 | 0.45 | partly determined |
B_i[TFA] |
0.0082 | 0.0012 | 0.057 | prior-dominated |
tf_scale |
4.1 | 0.0025 | 6919 | prior-dominated |
prior-dominated means: you mostly got your assumption back. The tf_scale range even leaves the allowed bounds,
because the Laplace method is a bell curve that knows nothing about them. posterior_diagnostics.json lists such
problems; here it says "clean": false. Read it before you report a range. Sampling with MCMC and the details are in
Network model options.
Before you write a sentence about a parameter
- [ ] Is its label
estimate (two-sided)? If not, do not quote a point value. - [ ] Is
fit_inside_intervaltrue? - [ ] Do several fit starts reach the best objective?
- [ ] Does the plot of that protein actually follow the data?
- [ ] Are the weights (KinOpt/TFOpt, or all 1) stated?
- [ ] Do you describe the kinase drive as a protein-level stand-in for activity?
- [ ] Is the claim about the model, and not stated as a measured biological fact?
More: 09. Identifiability and the posterior, KNOWN_ISSUES.md.
Next: Simulate experiments.