Skip to content

Releases

KinOpt 0.11.0

Choose a tag to compare

@github-actions github-actions released this 30 Nov 14:14
899b737

KinOpt 0.11.0

KinOpt becomes a library with a command line and a guided GUI around it, and every run writes a run bundle: one
self-contained, checkable folder or zip with all results, for kinopt-vis. Results change: the default prediction
transform is now none, and SLSQP converges to KKT points (exact gradient, tight stopping rule), so every start that
is accepted is a verified first-order optimum. On the reference inputs this finds a better fit (objective 0.151295
instead of 0.159286, R² 0.712 instead of 0.696) and changes α and β; recompute earlier results.

Breaking changes

  • prediction_transform is now "none" (until 0.10.0: max(0, x), now available as "clip"; "softplus" also
    remains). With clip, a site whose summed prediction is below zero has no gradient, which stopped the multistart
    short of the best fit: on the reference inputs, clip evaluated at the best none solution gives exactly the same
    objective (0.153191) because no prediction is negative there, so none reaches a better optimum of the same
    problem. A fitted prediction should not be negative, so every run now flags each site whose fitted prediction is
    negative at any time point (a warning, the sheet "Prediction Check", the Summary row "Sites with a negative
    prediction" and the bundle table prediction_check). Set prediction_transform = "clip" for the earlier model.

  • Convergence and acceptance (follow-up of #8). SLSQP gets the
    exact gradient (JAX) and stops at ftol = 1e-12 (before: finite differences and SciPy's default 1e-6, which left a
    stationarity residual of about 2e-4). A start is accepted only if it converged, every constraint residual and
    bound violation is at most 1e-10, and the KKT conditions pass (stationarity at most 1e-5 relative to the gradient's
    size); the selected start is the accepted start with the lowest objective. The verdict of every start is in
    multistart_summary.csv and the bundle. Runs take longer: on the reference inputs 288 s instead of 212 s (64 starts,
    96 cores).

  • Numerical changes against 0.10.0 (reference inputs, 64 starts, the same seeds; results_v0.11.0_reference): a
    better fit (best objective 0.151295, R² 0.712) with all 64 of 64 starts accepted and the reconstruction at 36/36:

    0.10.0 (clip, finite differences) 0.11.0 (none, KKT acceptance)
    best objective (weighted); selected start 0.159286; start 28 0.151295; start 42
    R² 0.696 0.712
    objective over starts: median / 75th percentile / max 0.219 / 0.438 / 1.100 0.178 / 0.178 / 0.227
    accepted starts 64 (rule then: converged, residuals ≤ 1e-10) 64 of 64 (also KKT)
    KKT stationarity of the selected start 2.2e-4 (fail) 2.3e-7 (pass)
    α: max / mean |Δ|; edges with |Δ| > 0.05 – 1.0 / 0.107; 31 of 94
    β: max / mean |Δ|; values with |Δ| > 0.05 – 3.5 / 0.63; 50 of 75
    dominant kinase changed – 5 of 36 sites
    edges with α = 0 23 27 (20 in both)
    reconstruction of Estimated from input1, α, β 36/36 36/36 (max error 1.8e-15)
    sites with a negative fitted prediction – 0 of 36 (smallest prediction 0.159)
  • time_points is required in the configuration ([kinopt] time_points, the time of input1's columns in
    minutes). The code no longer holds a default time grid: a configuration without it stops with an error,
    RunConfig(...) needs time_points=..., the kinopt.analysis functions need a time_points argument, and
    kinopt.analysis.DEFAULT_TIME_POINTS is removed. The shipped config.toml and the example project list them.

  • scripts/ is removed. Its user-facing functions are in the package:
    kinopt_network_readout.py → kinopt readout / kinopt.analysis.network_readout;
    curve_similarity.py → kinopt similarity / kinopt.analysis.curve_similarity. kinopt_network_viz.py and
    make_kinopt_diagram.py are deleted. The maintainer tools (check_release.py, build_brand.py, the new
    build_contract.py) are in tools/, which is not in the sdist or wheel; pixi run check-release works as before.

  • app/ (the Streamlit app) is replaced by the GUI kinopt-app. Streamlit was never a dependency.

  • The app draws no plots any more. All plotting is removed from the app; the data of every former figure is a
    table of the run bundle (see Run bundle, "Former
    app figures"), for kinopt-vis to draw.

  • kinopt.optimality.KKT is removed, as announced in 0.10.0: import kinopt.optimality.checks.

  • Summary sheet: the "SSE" row changes meaning (#5). Until
    0.10.0 the row "SSE" held the objective of the configured loss (the weighted objective), not a sum of squares. That
    value is now in the row "Objective (weighted)" (the loss type in brackets), and "SSE" holds the plain sum of squared
    residuals, a different number. Two rows are appended: "Prediction transform" and "Method". Readers that took the
    objective from "SSE" must read Objective (<loss type>).

  • Logs of a run go to <results_dir>/logs (they belong to the run and go into its bundle); paths.logs_dir no
    longer applies to runs.

  • New runtime dependency: PyArrow (>=24.0.0,<25, Apache-2.0) for the Parquet tables of the run bundle.

New

  • The guided GUI kinopt-app: inputs → validation → configuration (defaults pre-filled, advanced options folded
    away) → run (progress, log, cancel) → results (objective and metrics, convergence, starts, constraint checks, α, β,
    KKT) with the bundle download. Standard-library server, plain HTML/JS/CSS in the wheel, no new dependency. It binds
    127.0.0.1 on a free port, requires a random per-session token on every request, accepts only .csv uploads up to a
    size limit, and never writes outside its working folder. It calls the same functions as the command line; a test
    checks that both give identical results.
  • Run bundles: every run writes a run bundle, <results>/<name>.kinopt.zip (manifest with sha256 of every
    file, provenance, 29 Parquet tables, the multistart parameters, and the inputs of a what-if recomputation).
    kinopt bundle <results_dir> writes one from any 0.11 results folder; kinopt bundle --check validates a bundle
    against the published contract contracts/kinopt/1.0 (manifest.schema.json, tables.json, in
    phoskintime-vis's format) and its hashes.
  • A library API, kinopt.api: load_config, RunConfig, validate_inputs, run, read_results; the command
    kinopt with run, validate, bundle, readout, similarity, example and app; kinopt.__version__.
    kinopt-local gains --config PATH. Each run writes run_config.json (resolved configuration, seeds, versions,
    git commit, input sha256s, selected start, KKT verdicts).
  • Use cases in the documentation: the command line, the library and a complete downloadable script, all run by the
    test suite on a synthetic example (kinopt example; generated from a fixed seed, no data file is shipped).
  • prediction_transform (#4) = none (default) | clip |
    softplus, in config.toml, RunConfig, kinopt run --prediction-transform and
    kinopt-local --prediction_transform; recorded in the Summary sheet, run_config.json and the bundle; negative
    predictions are flagged per site. See the evaluation below.
  • Per-start KKT verdicts and acceptance: every start's stationarity, verdict and acceptance in
    multistart_summary.csv, the bundle and the GUI.
  • KKT diagnostics (#8), kinopt.optimality.kkt_diagnostics:
    stationarity, primal and dual feasibility and complementary slackness of the selected solution, with tolerances and
    pass/fail verdicts; λ from SLSQP when available, else estimated; bound multipliers estimated with μ >= 0 (BVLS). In
    the workbook (sheets "KKT", "KKT Multipliers"), the bundle and the GUI; run_config.json also holds the verdict with
    estimated multipliers as a cross-check.
  • Faster SLSQP constraints (#6): the sum-to-one constraints are
    evaluated as one compiled vector function. On the reference inputs, measured before the convergence change (so that
    the comparison isolates this change): per-start objectives and parameters bit-identical to 0.10.0 (64 of 64), same
    start selected; median time per start 99.9 s instead of 529.1 s (5.3x),
    run wall time 215 s instead of 831 s (3.9x). A plain NumPy evaluation was also tried: as fast, but it sums in a
    different order and is not bit-identical (best objective differs by 1.8e-5, α by up to 0.095), so it is not used.
  • kinopt.analysis: the calculations of the former app and scripts as tested library functions returning tidy tables
    (kinase activity, contributions, knockouts, dominance, fragility, load, bound pressure, network edges and nodes,
    control DAG, curve similarity).

Evaluation of prediction_transform (#4)

All three transforms on the reference inputs, 64 starts with the same seeds, SciPy SLSQP as in 0.10.0 (finite
differences, before the convergence change):

clip (0.10.0 default) none (0.11.0 default) softplus
best objective (weighted) 0.15929 0.15319 0.15571
R² 0.696 0.708 0.703
objective over starts: median / 75th percentile / max 0.219 / 0.438 / 1.100 0.180 / 0.182 / 0.228 0.196 / 0.197 / 0.221
starts converged; within 1 % of the best 64; 1 64; 1 64; 1
median time per start 102 s 92 s 111 s
fitted points whose summed prediction is negative 0 of 504 0 of 504 108 of 504 (9 of 36 sites)
estimated values near zero (< 1e-6) 0 0 0
α: mean / max |Δ| against clip; edges changed by > 0.05 ...
Read more

KinOpt 0.10.0

Choose a tag to compare

@github-actions github-actions released this 30 Nov 08:15
d0a19f7

KinOpt 0.10.0

The first tagged release of KinOpt. It changes results: it fixes defect K1, which put β on the wrong kinase's
series, and it makes SciPy SLSQP with hard constraints the default solver. α and β from earlier KinOpt runs,
including the KinOpt code formerly inside PhosKinTime, should be recomputed.

Breaking changes

  • Results change. The K1 fix (below) changes α and β, and with them the Estimated series; recompute earlier
    results.
  • New default solver settings in config.toml: method = "scipy-slsqp" (SciPy SLSQP, hard constraints),
    n_starts = 64, jitter_scale = 0.10, start_seed = 20260115. Runs take longer (about 20 minutes on a machine
    with enough cores). The JAXopt methods remain available as approximate options.
  • Output layout: the workbook is results_dir/kinopt_results.xlsx (before: results_dir/kinopt/…); the
    multistart files (multistart_summary.csv, multistart_params.npz) and the analysis plots and tables are in
    results_dir/General/; one folder per fitted gene. The workbook is no longer copied into data/ unless
    --copy_to_ode_data_dir is given.
  • Command line: --method accepts exactly the supported methods (scipy-slsqp, projected-gradient,
    lbfgsb, slsqp, non-negative, unconstrained, and their aliases), also for the value in config.toml;
    trust-constr is rejected with an error. In python -m config.cli, --mode, --conf and the all command are
    removed; kinopt passes its options to kinopt.local. kinopt.local.config.constants.parse_args() returns a
    ninth value (copy_to_ode_data_dir).
  • Module rename: kinopt.optimality.KKT is now kinopt.optimality.checks (the old name is a deprecated alias
    until 0.11), and its functions and output files are renamed (see below).
  • Errors instead of silent fallbacks: unmappable inputs, and constraints a penalty method cannot apply, stop the
    run with an error.
  • Preprocessing: python -m processing.cleanup writes only to [paths] data_dir; it no longer copies into
    kinopt/data/ and tfopt/data/.
  • Logging: the logger and log files are named kinopt (before: phoskintime).

Fixed: β was applied to other kinases' series (K1)

KinOpt built each kinase's rows in the order the kinases first appear in input2, while the β offsets assumed
sorted kinase order. Unless input2 listed kinases in sorted order, a kinase's activity was built from other
proteins' series. On the PhosKinTime inputs, 24 of 27 kinases were affected, and the shipped Estimated sheet
reproduced from input1 only under that misassignment (1 of 36 sites from each kinase's own series). The kinase rows
and the β offsets now use one ordering, and a guard stops the run if they ever disagree. The objective, constraints
and bounds are unchanged.

Validation on the PhosKinTime inputs (same 64 seeded starts, SciPy SLSQP, all starts converged with constraint
residuals ≤ 1e-10), against a control run with the old indexing:

old indexing (control) 0.10.0
best objective (weighted loss) 0.1807 0.1593
R² 0.655 0.696
Estimated reproduced from each kinase's own series 2 of 36 sites 36 of 36 (max error 1.8e-15)

Across the two runs, α changes by 0.23 on average (up to 1) and β by 1.85 on average (up to 6.5); which α are exactly
zero changes for 31 edges.

Changed: default solver and multistart (approved for this release)

config.toml now uses:

  • method = "scipy-slsqp": SciPy SLSQP with Σα = 1 per site, Σβ = 1 per kinase and the bounds as hard
    constraints (maxiter 20000).
  • n_starts = 64 and jitter_scale = 0.10: 64 seeded starts (start_seed = 20260115; start i uses seed
    20260115 + i), the best converged start is kept.

These are the settings validated above. The JAX/JAXopt methods (projected-gradient, lbfgsb, non-negative,
unconstrained, and the compatibility name slsqp, which runs LBFGSB) remain available as
approximate options: they enforce the sum-to-one constraints with a penalty, so the sums hold only approximately
(about 1e-6), and runs may stop at the iteration cap without converging.

Run time: one SLSQP start takes several minutes, so a default run of 64 starts takes about 20 minutes on a
machine with enough cores (starts run in parallel).

Other changes

  • trust-constr is rejected with a clear error. Before, it ran without any sum-to-one constraint (its
    constraint object was skipped by the penalty). The penalty methods now refuse any constraint they cannot apply.
  • Constraint check renamed and corrected (kinopt.optimality): it checks Σα = 1, Σβ = 1 and the bounds within a
    tolerance (1e-10) instead of an exact != 1, and its outputs are named for what they compute:
    constraint_residuals.png and observed_range.png replace constraint_violations.png and sensitivity.png, and
    the log reports one "constraint check". The functions print_primal_feasibility_results,
    print_sensitivity_and_active_constraints, plot_constraint_violations and plot_sensitivity_analysis are
    replaced by log_constraint_check, plot_constraint_residuals and plot_observed_range. No KKT conditions or
    sensitivities are computed. The module is renamed kinopt.optimality.checks; kinopt.optimality.KKT remains as
    a deprecated alias (with a DeprecationWarning) until 0.11.
  • Output layout: the results workbook stays at the top of paths.results_dir; per-gene plots go to one folder
    per fitted gene, everything else to General/. Before, any file named <word>_… got its own folder, so
    kinopt/, multistart/ and others were listed as genes in the report.
  • python -m kinopt.fitanalysis (task kinopt-fitanalysis) runs the fit analysis on an existing results
    folder; before, it did nothing. The fit analysis also runs on small problems (t-SNE perplexity capped).
  • Logger name: KinOpt logs as kinopt (log files kinopt_<date>.log), no longer as phoskintime. The unused
    PhosKinTime classes PhosKinConfig and load_config_toml are removed from config_loader.
  • Current Matplotlib: the exporter uses matplotlib.colormaps instead of matplotlib.cm.get_cmap, which recent
    Matplotlib releases removed (a pip install kinopt with Matplotlib 3.11 failed at the first plot).
  • Preprocessing writes to one folder: python -m processing.cleanup writes its CSV files only to [paths] data_dir (or the out_dir given to each function). It no longer writes into processing/ and no longer copies
    into kinopt/data/ and tfopt/data/ (PhosKinTime-era locations); move_processed_files is removed.
  • Documentation: the background page on mass-spectrometry proteomics (docs/assets/background/) and its figures
    are removed from the repository and the documentation site.
  • Errors instead of silent fallbacks. A site in input2 without an input1 row, a site listed twice, or a
    kinase without any input1 series now stops the run with a ValueError. Before, another series was silently
    reused, or the rows were misaligned.
  • Multistart ranking. Among feasible starts, a converged start comes first, then the lowest objective. Before,
    tiny differences in constraint violation could outrank the objective.
  • No copy into data/ by default. The results workbook is copied into paths.ode_data_dir only with
    --copy_to_ode_data_dir. Before, every run overwrote data/kinopt_results.xlsx.
  • Seeded starting values through [kinopt] start_seed. Before, they were unseeded and runs were not
    reproducible.
  • n_starts and jitter_scale are [kinopt] settings (10 and 0.20 if the keys are absent).
  • kinopt.local.config.constants.parse_args() returns a ninth value (copy_to_ode_data_dir). Code that
    unpacks it must take nine values.
  • On PyPI: pip install kinopt installs the kinopt package and the kinopt-local command. An installed
    KinOpt looks for config.toml above the working directory (a clone still uses its own config.toml), so run it
    from a project folder with a config.toml; without one it stops with a clear error.
  • Removed: the Dockerfile and the kinopt-evol task (the kinopt.evol module was removed earlier).
  • Project: documentation corrected to the current code, with an API reference generated from the (rewritten)
    docstrings of every module and the site configured in zensical.toml, and a License page (code BSD-3-Clause, documentation
    CC BY 4.0; LICENSE, LICENSE-docs.md, THIRD_PARTY.md); a KinOpt logo and wordmark; a changelog generated with
    git-cliff. Releases are published by a tag-triggered workflow: GitHub release, archived on Zenodo, and PyPI.
    Tests, the import check and the docs build run on every push and pull request (test.yml).

Reproducibility and dependency versions

For exact reproduction of published results use pixi.lock; pip install gives compatible versions. The PyPI package
requires at least the versions this release was validated with (NumPy 2.4.6, SciPy 1.17.1, JAX/jaxlib 0.9.2, JAXopt
0.8.4, Matplotlib 3.10.9, pandas 3.0.3, scikit-learn 1.8.0, statsmodels 0.14.6, seaborn 0.13.2, Plotly 6.6.0,
openpyxl 3.1.5, adjustText 1.3.0, joblib 1.5.3), with upper bounds NumPy < 3, SciPy < 2, Matplotlib < 4 and
JAX/jaxlib < 0.13.

Check on a synthetic case (4 sites, 3 kinases, scipy-slsqp, 4 starts): the Pixi environment (NumPy 2.4.6,
SciPy 1.17.1, JAX 0.9.2, Matplotlib 3.10.9) and a clean pip install (NumPy 2.5.5, SciPy 1.18.1, JAX 0.12.1,
Matplotlib 3.11.2) reach best objectives that differ by 4.0e-14 (relative 1.1e-10). Over the 4 starts, objectives
differ by at most 2.6e-11, α by at most 8.5e-10, β by at most 4.0e-9.

Upgrading

  • Re-run KinOpt on your inputs and replace earlier kinopt_results.xlsx workbooks; their α and β are affected by
    K1.
  • Expect longer runs with the new defaults. For a quick exploratory run, set n_starts lower or choose...
Read more