Skip to content

Validate and fit

Validate first

pixi run phoskintime validate --conf my-project/config.toml

Validation reads everything a run would read and builds the network. It does not fit. It ends with ok (exit code 0) or INVALID (exit code 1).

With --verbose it also prints a count of what was read, dropped and filled in. Read this once for every new dataset. Part of it, for the example:

pixi run phoskintime validate --conf my-project/config.toml --verbose
"kinase_alpha": { "edges": 6, "without_alpha": 0, "policy": "one" },
"ms": { "rows": 10, "time_columns": 14, "missing_values_dropped": 0, "protein_values": 70, "phospho_values": 70 },
"phospho_site_filter": { "rows_before": 70, "rows_after": 56 },

Here 14 phosphosite values were dropped: they belong to the site T1 S_9, which has no kinase in the network. without_alpha counts edges your KinOpt workbook does not cover.

Reading warnings

warning meaning
KinOpt results not found every kinase edge gets weight 1
orphan TF T2 has no mrna data to drive it: fallback its own state T2 is a TF without sites and without mRNA data; it is simulated as its own protein, which no data constrain
observations of data-driven TFs ['T1'] are inputs: 9 rows removed from the loss T1 follows its measured mRNA, so that mRNA is not also fitted
fc_start: ... series have a zero, near-zero or missing baseline those rows are not used

Fit

pixi run phoskintime run --conf my-project/config.toml

(If you already ran this in Your first model, the finished repeats are reused; see Rules for output folders.)

Options after --conf override the file for this one run, for example:

pixi run phoskintime run --conf my-project/config.toml --output-dir my-project/results2

pixi run phoskintime run --help lists all of them.

What happens

  1. The network is built and the SBML model written.
  2. Bounds are chosen for every parameter from your time points and data (logged as [Bounds]).
  3. The fit starts n_starts times from random guesses (reproducible through seed). Each repeat is a least-squares search in sbmlsim.
  4. The repeat with the lowest objective is kept.
  5. Tables, pictures and a run bundle are written.

The default objective is the sum of the mean squared errors of the protein, mRNA and phosphosite fold changes, plus a small prior term that gently pulls parameters towards plausible values.

Did the fit work?

Open my-project/results/optimization/multistart_summary.csv. The example (shortened):

start_id final_objective convergence_status selected_best
0 0.0872 converged False
1 0.1026 converged False
2 0.1077 converged False
3 0.0841 converged True

Every start converged, but to different values. So the search finds local optima, and 4 starts are not enough to trust that 0.0841 is the best. (A data-only search done later for the profiles found even better fits.) What to do:

  • raise n_starts (the repository default is 20),
  • look for the best value being reached by several starts,
  • look at the pictures: a small number can still hide a missed peak.

Rules for output folders

Use a new folder for every run. If you rerun into a used folder with changed inputs or settings, PhosKinTime refuses:

ModelSpecError: .../results/model_spec/spec.json exists with other content; the model specification is written once and never replaced (use a new output folder, or remove ...

An unchanged rerun reuses the finished repeats, so an interrupted fit can be resumed. It then warns that the run bundle already exists and keeps it.

A second fit engine (optional)

AMICI with pyPESTO can do the fit instead. It lives in its own environment (the first use installs it and compiles each model). With the mymodel project, after changing nothing but the engine and the folder:

pixi run -e amici phoskintime run --conf mymodel/config.toml --fit-engine pypesto --output-dir mymodel/results_pypesto
[Fit] pyPESTO: AMICI model ready in 48.9 s (16 free parameters, forward sensitivities).
[Fit] pyPESTO: 4/4 repeats succeeded in 0.9 s; best start 0, objective 0.1405202248.

sbmlsim reached 0.1405202649 on the same problem. Two independent engines agreeing is a good sign.

Try it without your data

Your first model and the tutorials 06 and 07 go through the objective and the fit in detail.

Next: Read the results.