Skip to content

Simulate experiments

A fitted model can answer "what if". These answers are predictions of the model, only as good as the model. Use them to choose the next experiment in the lab.

Presets

Using the example project from Your first model. An existing output file is never overwritten.

pixi run phoskintime simulate run --model my-project/results --preset knockout --target K2 --out knockout_K2.pke.zip
pixi run phoskintime simulate run --model my-project/results --preset dose_response --target K1 --out dose_K1.pke.zip
1 scenarios: .../knockout_K2.pke.zip
7 scenarios: .../dose_K1.pke.zip
preset question
timecourse the fitted model, unchanged
inhibit (--fraction 0.5) a catalytic inhibitor of a kinase
knockout a kinase with no activity
knockdown less transcription of a gene (like siRNA)
dose_response 0 to 100 % inhibition of a kinase
pulse (--t-off 30) the stimulus is withdrawn
d5 every kinase half inhibited and every gene's transcription halved, one at a time

Look at the result

Save as read_experiment.py:

import io
import sys
import zipfile

import pandas as pd

with zipfile.ZipFile(sys.argv[1]) as z:
    res = pd.read_parquet(io.BytesIO(z.read("results.parquet")))
print(res.head())
print(res.shape, res["scenario"].unique())
pixi run python read_experiment.py knockout_K2.pke.zip
      scenario  time variable  value  fold_change
0  knockout_K2   0.0      R_A   1.00          1.0
1  knockout_K2   0.0      P_A   0.70          1.0
2  knockout_K2   0.0  X_A_S_1   0.15          1.0
3  knockout_K2   0.0  X_A_S_2   0.15          1.0
4  knockout_K2   0.0      R_B   1.00          1.0
(308, 5) ['knockout_K2']

Variables: R_ mRNA, P_ unmodified protein, X_<protein>_<site> phosphorylated form, Ptotal_ all protein.

To compare with the unperturbed model, run --preset timecourse too.

Your own experiment

A kinase inhibitor added at 15 minutes and washed out at 120 minutes. Save as washout.json:

{
  "format": "phoskintime.experiment/1",
  "name": "washout",
  "times": [0, 5, 15, 30, 60, 120, 240],
  "perturbations": [{"kind": "inhibit", "target": "K2", "fraction": 0.8, "t_on": 15, "t_off": 120}]
}
pixi run phoskintime simulate run --model my-project/results --spec washout.json --out washout.pke.zip
pixi run phoskintime simulate show washout.pke.zip

show prints the manifest: which model (by checksum), which engine, which scenarios.

Other kinds of perturbation (knockdown, remove_edge, set, pulse) and all fields: In-silico experiments.

With uncertainty

If the run has posterior draws (the Laplace run):

pixi run phoskintime simulate run --model mymodel/results_unc --draws mymodel/results_unc --source laplace \
  --preset inhibit --target KINA --fraction 0.8 --out inhibit_bands.pke.zip
1 scenarios, bands over 200 laplace draws: .../inhibit_bands.pke.zip

The bundle then has bands.parquet. Fold change of X_SUB_S_10 under 80 % inhibition (rounded):

time (min) 2.5 % median 97.5 %
1 0.47 0.78 0.92
4 0.36 0.64 1.40
30 0.51 1.00 12.4

Early times: the model predicts a reduction. At 30 minutes the range covers both a strong fall and a twelve-fold rise. The honest answer there is "the model does not know".

Next: Save and share.