Skip to content

App, command line or Python

All three run the same code on the same files: a config.toml and a run folder. You can switch at any time.

way good for
app the first contact; no commands after starting it
command line repeatable work, servers, every option
Python many runs, your own plots and analysis

1. The app

pixi run app --workspace ~/phoskintime-projects
PhosKinTime app, workspace /home/you/phoskintime-projects
Open (the link contains this session's token; do not share it): http://127.0.0.1:8765/?token=...
Stop with Ctrl+C (a run still running is stopped too).

Your browser opens the page (add --no-browser and copy the link yourself if not). It only listens on your own computer. The five steps on the left:

  1. Project: "From the synthetic example", or "For my own files".
  2. Inputs and settings: upload files, change the main settings, "Save the settings".
  3. Validation: "Check the inputs".
  4. Run: "Start the run" and watch the log.
  5. Results and bundle: tables and labels, "Create and check the bundle", experiments and analyses.

For your own files, also check the time points in the project's config.toml. More, with a video: The PhosKinTime app.

2. The command line

command step
pixi run phoskintime example my-project a practice project
pixi run phoskintime validate --conf my-project/config.toml check
pixi run phoskintime run --conf my-project/config.toml fit
pixi run phoskintime analyze profiles --runs my-project/results identifiability
pixi run phoskintime simulate run --model my-project/results --preset knockout --target K2 --out ko.pke.zip experiment
pixi run phoskintime bundle verify my-project/results/results.pkt.zip check a bundle
pixi run phoskintime export standards --run my-project/results --out export share

--help works after every command. pixi run phoskintime analyze --list lists the analyses. Reference: Command line.

3. Python

Save as my_workflow.py in the phoskintime folder:

from phoskintime.networkmodel import api


def main():
    conf = api.write_example("script-project")          # 1. a synthetic example project
    report = api.validate_inputs(conf)                  # 2. check the inputs without fitting
    print("valid:", report.ok, report.errors)

    run_dir = api.run(conf, log="script-run.log")       # 3. fit (log goes to a file)
    print("run folder:", run_dir)

    tables = api.read_results(run_dir)                  # 4. results as pandas tables
    par = tables["parameters"].query("sample_id == 'best'")
    print(par[["name", "value", "identifiability_label"]].head(8).to_string(index=False))
    print(par["identifiability_label"].value_counts())
    traj = tables["trajectories"]
    print(traj.query("protein == 'B' and psite == 'Y_4'")[["time", "value_obs", "value_pred"]].head().to_string(index=False))
    print(tables["metrics"].query("protein.isna() and layer.isna()")[["metric", "value"]].to_string(index=False))

    check = api.check_bundle(api.bundle_path(run_dir))  # 5. check the saved bundle
    print("bundle ok:", check.ok)

    sim = api.simulate(run_dir, preset="inhibit", target="K1", fraction=0.5, out="inhibit_K1.pke.zip")  # 6. experiment
    print(sim.trajectories.query("variable == 'X_B_Y_4'").head(6).to_string(index=False))


if __name__ == "__main__":      # required: PhosKinTime starts worker processes
    main()
pixi run python my_workflow.py
valid: True []
run folder: .../script-project/results
   name    value               identifiability_label
 A_i[A] 0.027646                        not assessed
 A_i[B] 0.012820                        not assessed
...
A_i[T1] 1.000000 not identifiable: no data influence
...
 time  value_obs  value_pred
 0.00   1.000000    1.000000
 0.50   1.143639    1.299128
...
          metric      value
            rmse   0.166432
             mae   0.111516
           n_obs 139.000000
       objective   0.084063
frechet_distance   2.985158
bundle ok: True
      scenario  time variable    value  fold_change
inhibit_K1_0.5   0.0  X_B_Y_4 0.300000     1.000000
inhibit_K1_0.5   0.5  X_B_Y_4 0.336285     1.120951
...

Keep the if __name__ == \"__main__\": lines

Without them every worker process runs your whole script again. You get confusing errors such as FileExistsError: ... is not empty or Connection reset by peer.

Run the script a second time only after choosing a new project folder name.

Function by function: Library, 11. Library API and run bundle.

Next: Troubleshooting.