tfopt 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tfopt-0.2.0/LICENSE +28 -0
- tfopt-0.2.0/MANIFEST.in +6 -0
- tfopt-0.2.0/PKG-INFO +158 -0
- tfopt-0.2.0/README.md +119 -0
- tfopt-0.2.0/THIRD_PARTY.md +83 -0
- tfopt-0.2.0/config_loader.py +38 -0
- tfopt-0.2.0/pyproject.toml +66 -0
- tfopt-0.2.0/setup.cfg +4 -0
- tfopt-0.2.0/tests/test_analysis.py +188 -0
- tfopt-0.2.0/tests/test_analysis_interfaces.py +75 -0
- tfopt-0.2.0/tests/test_api.py +192 -0
- tfopt-0.2.0/tests/test_app.py +349 -0
- tfopt-0.2.0/tests/test_architecture.py +15 -0
- tfopt-0.2.0/tests/test_bundle.py +284 -0
- tfopt-0.2.0/tests/test_check_release.py +58 -0
- tfopt-0.2.0/tests/test_clean_exit.py +54 -0
- tfopt-0.2.0/tests/test_constraint_residual.py +48 -0
- tfopt-0.2.0/tests/test_constraints.py +84 -0
- tfopt-0.2.0/tests/test_docs_assets.py +84 -0
- tfopt-0.2.0/tests/test_docs_tutorials.py +32 -0
- tfopt-0.2.0/tests/test_import_side_effects.py +42 -0
- tfopt-0.2.0/tests/test_kkt_diagnostics.py +81 -0
- tfopt-0.2.0/tests/test_numerics.py +44 -0
- tfopt-0.2.0/tests/test_optimization.py +139 -0
- tfopt-0.2.0/tests/test_packaging.py +116 -0
- tfopt-0.2.0/tests/test_pipeline.py +73 -0
- tfopt-0.2.0/tests/test_prediction_check.py +42 -0
- tfopt-0.2.0/tests/test_prediction_transform.py +82 -0
- tfopt-0.2.0/tests/test_release_notes.py +22 -0
- tfopt-0.2.0/tests/test_repository.py +16 -0
- tfopt-0.2.0/tests/test_slsqp.py +116 -0
- tfopt-0.2.0/tests/test_t6_series.py +277 -0
- tfopt-0.2.0/tests/test_use_cases.py +75 -0
- tfopt-0.2.0/tests/test_workflows.py +74 -0
- tfopt-0.2.0/tfopt/__init__.py +25 -0
- tfopt-0.2.0/tfopt/__main__.py +5 -0
- tfopt-0.2.0/tfopt/_exit.py +66 -0
- tfopt-0.2.0/tfopt/analysis/__init__.py +74 -0
- tfopt-0.2.0/tfopt/analysis/diagrams.py +221 -0
- tfopt-0.2.0/tfopt/api.py +662 -0
- tfopt-0.2.0/tfopt/app/__init__.py +17 -0
- tfopt-0.2.0/tfopt/app/__main__.py +72 -0
- tfopt-0.2.0/tfopt/app/backend.py +593 -0
- tfopt-0.2.0/tfopt/app/server.py +230 -0
- tfopt-0.2.0/tfopt/app/static/app.css +233 -0
- tfopt-0.2.0/tfopt/app/static/app.js +431 -0
- tfopt-0.2.0/tfopt/app/static/index.html +129 -0
- tfopt-0.2.0/tfopt/bundle/__init__.py +13 -0
- tfopt-0.2.0/tfopt/bundle/build.py +566 -0
- tfopt-0.2.0/tfopt/bundle/contract/1.0/manifest.schema.json +316 -0
- tfopt-0.2.0/tfopt/bundle/contract/1.0/tables.json +1186 -0
- tfopt-0.2.0/tfopt/bundle/contract.py +231 -0
- tfopt-0.2.0/tfopt/cli.py +266 -0
- tfopt-0.2.0/tfopt/examples/__init__.py +119 -0
- tfopt-0.2.0/tfopt/fitanalysis/__init__.py +0 -0
- tfopt-0.2.0/tfopt/fitanalysis/__main__.py +12 -0
- tfopt-0.2.0/tfopt/fitanalysis/curves.py +52 -0
- tfopt-0.2.0/tfopt/fitanalysis/figures.py +96 -0
- tfopt-0.2.0/tfopt/fitanalysis/helper.py +2 -0
- tfopt-0.2.0/tfopt/fitanalysis/helpers/__init__.py +1 -0
- tfopt-0.2.0/tfopt/fitanalysis/helpers/plotter.py +372 -0
- tfopt-0.2.0/tfopt/fitanalysis/metrics.py +12 -0
- tfopt-0.2.0/tfopt/fitanalysis/networks.py +46 -0
- tfopt-0.2.0/tfopt/fitanalysis/regulatory.py +237 -0
- tfopt-0.2.0/tfopt/fitanalysis/workbook.py +264 -0
- tfopt-0.2.0/tfopt/local/__init__.py +0 -0
- tfopt-0.2.0/tfopt/local/__main__.py +62 -0
- tfopt-0.2.0/tfopt/local/config/__init__.py +0 -0
- tfopt-0.2.0/tfopt/local/config/constants.py +120 -0
- tfopt-0.2.0/tfopt/local/config/logconf.py +112 -0
- tfopt-0.2.0/tfopt/local/exporter/__init__.py +0 -0
- tfopt-0.2.0/tfopt/local/exporter/latexit.py +13 -0
- tfopt-0.2.0/tfopt/local/exporter/plotout.py +285 -0
- tfopt-0.2.0/tfopt/local/exporter/sheetutils.py +193 -0
- tfopt-0.2.0/tfopt/local/objfn/__init__.py +0 -0
- tfopt-0.2.0/tfopt/local/objfn/minfn.py +67 -0
- tfopt-0.2.0/tfopt/local/opt/__init__.py +0 -0
- tfopt-0.2.0/tfopt/local/opt/optrun.py +279 -0
- tfopt-0.2.0/tfopt/local/opt/slsqp.py +65 -0
- tfopt-0.2.0/tfopt/local/opt/workers.py +81 -0
- tfopt-0.2.0/tfopt/local/optcon/__init__.py +0 -0
- tfopt-0.2.0/tfopt/local/optcon/construct.py +134 -0
- tfopt-0.2.0/tfopt/local/optcon/feasibility.py +116 -0
- tfopt-0.2.0/tfopt/local/optcon/filter.py +101 -0
- tfopt-0.2.0/tfopt/local/utils/__init__.py +0 -0
- tfopt-0.2.0/tfopt/local/utils/iodata.py +238 -0
- tfopt-0.2.0/tfopt/local/utils/params.py +131 -0
- tfopt-0.2.0/tfopt/optimality/KKT.py +14 -0
- tfopt-0.2.0/tfopt/optimality/__init__.py +1 -0
- tfopt-0.2.0/tfopt/optimality/kkt_diagnostics.py +182 -0
- tfopt-0.2.0/tfopt/processing/__init__.py +1 -0
- tfopt-0.2.0/tfopt/processing/cleanup.py +14 -0
- tfopt-0.2.0/tfopt/processing/map.py +14 -0
- tfopt-0.2.0/tfopt/processing/tfseries.py +188 -0
- tfopt-0.2.0/tfopt.egg-info/PKG-INFO +158 -0
- tfopt-0.2.0/tfopt.egg-info/SOURCES.txt +98 -0
- tfopt-0.2.0/tfopt.egg-info/dependency_links.txt +1 -0
- tfopt-0.2.0/tfopt.egg-info/entry_points.txt +4 -0
- tfopt-0.2.0/tfopt.egg-info/requires.txt +15 -0
- tfopt-0.2.0/tfopt.egg-info/top_level.txt +2 -0
tfopt-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026, Philomina Lillie Normann and Abhinav Mishra
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
tfopt-0.2.0/MANIFEST.in
ADDED
tfopt-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tfopt
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Optimization-based estimation of transcription-factor contributions to mRNA time-series expression, with TF activity built from TF protein and phosphosite series.
|
|
5
|
+
Author: Philomina Lillie Normann, Abhinav Mishra
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/bibymaths/TFOpt
|
|
8
|
+
Project-URL: Documentation, https://bibymaths.github.io/TFOpt/
|
|
9
|
+
Project-URL: Changelog, https://github.com/bibymaths/TFOpt/blob/main/docs/CHANGELOG.md
|
|
10
|
+
Project-URL: Release notes, https://github.com/bibymaths/TFOpt/tree/main/release-notes
|
|
11
|
+
Project-URL: Issues, https://github.com/bibymaths/TFOpt/issues
|
|
12
|
+
Keywords: transcription factor,gene regulation,time series,constrained optimization,systems biology
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
License-File: THIRD_PARTY.md
|
|
23
|
+
Requires-Dist: numpy<3,>=2.5.4
|
|
24
|
+
Requires-Dist: pandas<3,>=2.3.3
|
|
25
|
+
Requires-Dist: scipy<2,>=1.18.1
|
|
26
|
+
Requires-Dist: scikit-learn<2,>=1.9.1
|
|
27
|
+
Requires-Dist: jax<0.13,>=0.4.38
|
|
28
|
+
Requires-Dist: jaxlib<0.13,>=0.4.38
|
|
29
|
+
Requires-Dist: jaxopt<1,>=0.8.4
|
|
30
|
+
Requires-Dist: matplotlib<4,>=3.9.1
|
|
31
|
+
Requires-Dist: seaborn<1,>=0.13.2
|
|
32
|
+
Requires-Dist: plotly<8,>=7.1.0
|
|
33
|
+
Requires-Dist: openpyxl<4,>=3.1.5
|
|
34
|
+
Requires-Dist: xlsxwriter<4,>=3.2.9
|
|
35
|
+
Requires-Dist: networkx<4,>=3.7
|
|
36
|
+
Requires-Dist: pyarrow<27,>=19.0.1
|
|
37
|
+
Requires-Dist: jinja2<4,>=3.1.6
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<picture>
|
|
42
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/bibymaths/TFOpt/main/docs/assets/brand/wordmark-dark.svg">
|
|
43
|
+
<img alt="TFOpt: TF effects on mRNA expression" src="https://raw.githubusercontent.com/bibymaths/TFOpt/main/docs/assets/brand/wordmark-light.svg" width="520">
|
|
44
|
+
</picture>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
<p align="center">
|
|
48
|
+
<a href="https://github.com/bibymaths/TFOpt/actions/workflows/test.yml"><img alt="Tests" src="https://github.com/bibymaths/TFOpt/actions/workflows/test.yml/badge.svg"></a>
|
|
49
|
+
<a href="https://github.com/bibymaths/TFOpt/actions/workflows/deploy-docs.yml"><img alt="Docs" src="https://github.com/bibymaths/TFOpt/actions/workflows/deploy-docs.yml/badge.svg"></a>
|
|
50
|
+
<a href="https://bibymaths.github.io/TFOpt/"><img alt="Documentation" src="https://img.shields.io/badge/docs-bibymaths.github.io%2FTFOpt-1f2a44"></a>
|
|
51
|
+
<a href="https://pixi.sh"><img alt="Pixi" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json"></a>
|
|
52
|
+
<img alt="Python 3.12" src="https://img.shields.io/badge/python-3.12-3a8fd6">
|
|
53
|
+
</p>
|
|
54
|
+
|
|
55
|
+
# TFOpt — Transcription Factor Optimization
|
|
56
|
+
|
|
57
|
+
TFOpt was originally developed by **Philomina Lillie Normann** and subsequently extended and refined by **Abhinav Mishra**, with improvements to computational performance, code consistency, and software architecture.
|
|
58
|
+
|
|
59
|
+
**Documentation:** <https://bibymaths.github.io/TFOpt/> (configured for this address) ·
|
|
60
|
+
[Changelog](docs/CHANGELOG.md) · [Cite](CITATION.cff) · [Security](SECURITY.md) · [Terms of use](TERMS_OF_USE.md) · [Third-party](THIRD_PARTY.md)
|
|
61
|
+
|
|
62
|
+
TFOpt estimates transcription-factor (TF) contributions to time-resolved mRNA expression. For every target mRNA it
|
|
63
|
+
fits how much each of its TFs contributes (α), and for every TF how its protein series and its own phosphosite series
|
|
64
|
+
combine into its activity (β):
|
|
65
|
+
|
|
66
|
+
$$\hat R_j(t)=\max\Big(0,\sum_{i}\alpha_{ji}\big[\beta_{i0}X_i(t)+\sum_s\beta_{is}S_{is}(t)\big]\Big),\qquad
|
|
67
|
+
\sum_i\alpha_{ji}=1,\ \alpha_{ji}\in[0,1],\qquad \beta_{i0}+\sum_s\beta_{is}=1$$
|
|
68
|
+
|
|
69
|
+
$X_i$ is the TF's input1 protein row, else its input3 mRNA; $S_{is}$ are its own input1 phosphosites. β may be
|
|
70
|
+
negative within its bounds; padded regulator slots are fixed to zero. The default objective is `loss_type` 5 (MSE plus
|
|
71
|
+
an elastic-net penalty on β) and the default solver is SciPy SLSQP with the constraints and bounds as exact
|
|
72
|
+
constraints and analytic JAX gradients (`scipy-slsqp`), run from 64 seeded starts with jitter 0.10, with feasibility
|
|
73
|
+
and KKT diagnostics. TFOpt shares KinOpt's architecture and developer workflow; its signals, parameters and diagnostics
|
|
74
|
+
are TF-specific. See [TF Optimization](https://bibymaths.github.io/TFOpt/Documentation/tfopt/README.html) and the
|
|
75
|
+
[TF base series design note](https://bibymaths.github.io/TFOpt/Documentation/tfopt/tf_series.html).
|
|
76
|
+
|
|
77
|
+
## Install and run
|
|
78
|
+
|
|
79
|
+
From a clone of the repository, with [Pixi](https://pixi.sh):
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pixi install
|
|
83
|
+
pixi run tfopt example my-project # a synthetic example project (config.toml and three CSVs)
|
|
84
|
+
pixi run tfopt validate --config my-project/config.toml
|
|
85
|
+
pixi run tfopt run --config my-project/config.toml # or: pixi run tfopt-local --config my-project/config.toml
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
TFOpt installs three commands: `tfopt` (subcommands `run`, `validate`, `bundle`, `readout`, `figures`, `network`,
|
|
89
|
+
`similarity`, `diagram`, `example`, `app`), `tfopt-local` (the fit with the options of earlier versions) and
|
|
90
|
+
`tfopt-app` (a guided GUI in the browser). The library is `tfopt.api` (`load_config`, `RunConfig`, `validate_inputs`,
|
|
91
|
+
`run`, `read_results`). See [Command line](https://bibymaths.github.io/TFOpt/Documentation/cli.html).
|
|
92
|
+
|
|
93
|
+
A run reads one `config.toml`: the one given with `--config`, else `TFOPT_CONFIG`, else the clone's. Paths resolve
|
|
94
|
+
relative to that file. The shipped `config.toml` points at user-supplied inputs in `data/`; it never substitutes the
|
|
95
|
+
tutorial data.
|
|
96
|
+
|
|
97
|
+
- `input1`: TF protein and phosphosite series: `GeneID`, `Psite`, then one column per MS time point. The empty-Psite
|
|
98
|
+
row is the TF's protein series and `S_`/`T_`/`Y_` rows are its phosphosites. A TF without a protein row falls back
|
|
99
|
+
to its input3 mRNA (logged); a TF with neither is excluded with its edges (logged).
|
|
100
|
+
- `input3`: mRNA series: `GeneID`, then one column per RNA time point.
|
|
101
|
+
- `input4`: regulation edges: `Source` TF, `Target` mRNA.
|
|
102
|
+
|
|
103
|
+
The time grids are part of the configuration and have no default: `[tfopt] time_points` (RNA times of input3's
|
|
104
|
+
columns, the fit times) and `ms_time_points` (MS times of input1's columns). input1 series are taken at the RNA times by
|
|
105
|
+
actual time.
|
|
106
|
+
|
|
107
|
+
Results go to `paths.results_dir`: the workbook `tfopt_results.xlsx` (Alpha Values, Beta Values with `Source`,
|
|
108
|
+
Residuals, Observed, Estimated, Optimization Results, KKT Diagnostics, KKT Multipliers, Prediction Check), `multistart_summary.csv`,
|
|
109
|
+
`multistart_params.npz`, `diagnostics.json`, `run_config.json`, fit plots, fit-analysis figures, LaTeX tables,
|
|
110
|
+
`report.html` and the run bundle `<results>.tfopt.zip`. Use a new results folder for each run.
|
|
111
|
+
|
|
112
|
+
| Setting | Default |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `method` | `scipy-slsqp` (exact constraints). The JAXopt methods (`lbfgsb`, `projected-gradient`, `non-negative`, `unconstrained`) are approximate for the production problem |
|
|
115
|
+
| `n_starts`, `jitter_scale` | 64, 0.10 |
|
|
116
|
+
| `seed`, `start_seed` | 123, 0 |
|
|
117
|
+
| `loss_type` | 5 (elastic net) |
|
|
118
|
+
| β bounds | −4, 4 |
|
|
119
|
+
| `tf_protein_source`, `ms_alignment` | `protein_then_mrna`, `by_time` |
|
|
120
|
+
| `time_points`, `ms_time_points` | required, no default |
|
|
121
|
+
|
|
122
|
+
See the [Configuration Reference](https://bibymaths.github.io/TFOpt/Documentation/configuration.html).
|
|
123
|
+
|
|
124
|
+
## Regulatory readout
|
|
125
|
+
|
|
126
|
+
`tfopt readout`, `tfopt figures`, `tfopt network`, `tfopt similarity` and `tfopt diagram` analyse a fitted results
|
|
127
|
+
folder without refitting: signed TF contributions, TF protein/phosphosite components, target dominance, regulatory
|
|
128
|
+
loads, fixed-parameter TF-removal sensitivity, the directed TF → mRNA network, the Fréchet distance between observed
|
|
129
|
+
and estimated series, and model diagrams. Missing required signals are reported, never replaced with zeros. gravis,
|
|
130
|
+
Graphviz and pydot (for `network` and `diagram`) are in the optional `viz` environment.
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pixi install -e dev
|
|
136
|
+
pixi run -e dev check-import
|
|
137
|
+
pixi run -e dev test
|
|
138
|
+
pixi run -e dev test-cov
|
|
139
|
+
TFOPT_CONFIG=notebooks/data/toy.toml pixi run tfopt-local # the tutorial dataset end to end
|
|
140
|
+
pixi run -e docs docs-build # executes the tutorials, then builds the site
|
|
141
|
+
pixi run -e docs docs-serve
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The documentation (Zensical, `zensical.toml`) lives in `docs/`; the tutorials are the notebooks
|
|
145
|
+
`notebooks/00`–`10`, executed and rendered into `docs/tutorials/` by `tools/build_tutorials.py` when the site is built.
|
|
146
|
+
The brand marks in `docs/assets/brand/` are generated by `tools/build_brand.py`. The use cases of the documentation
|
|
147
|
+
(`docs/examples/`) are run by the test suite.
|
|
148
|
+
|
|
149
|
+
## Provenance
|
|
150
|
+
|
|
151
|
+
TFOpt was extracted from the integrated PhosKinTime source into an independent package; the upstream scientific
|
|
152
|
+
implementation and comments keep Philomina Lillie Normann's authorship and Abhinav Mishra's subsequent work. See
|
|
153
|
+
[Architecture](https://bibymaths.github.io/TFOpt/Documentation/architecture.html#provenance-and-migration) for the
|
|
154
|
+
migration record. No KinOpt DOI is asserted for TFOpt; cite it with [CITATION.cff](CITATION.cff).
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
BSD-3-Clause, see `LICENSE`.
|
tfopt-0.2.0/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/bibymaths/TFOpt/main/docs/assets/brand/wordmark-dark.svg">
|
|
4
|
+
<img alt="TFOpt: TF effects on mRNA expression" src="https://raw.githubusercontent.com/bibymaths/TFOpt/main/docs/assets/brand/wordmark-light.svg" width="520">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://github.com/bibymaths/TFOpt/actions/workflows/test.yml"><img alt="Tests" src="https://github.com/bibymaths/TFOpt/actions/workflows/test.yml/badge.svg"></a>
|
|
10
|
+
<a href="https://github.com/bibymaths/TFOpt/actions/workflows/deploy-docs.yml"><img alt="Docs" src="https://github.com/bibymaths/TFOpt/actions/workflows/deploy-docs.yml/badge.svg"></a>
|
|
11
|
+
<a href="https://bibymaths.github.io/TFOpt/"><img alt="Documentation" src="https://img.shields.io/badge/docs-bibymaths.github.io%2FTFOpt-1f2a44"></a>
|
|
12
|
+
<a href="https://pixi.sh"><img alt="Pixi" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json"></a>
|
|
13
|
+
<img alt="Python 3.12" src="https://img.shields.io/badge/python-3.12-3a8fd6">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
# TFOpt — Transcription Factor Optimization
|
|
17
|
+
|
|
18
|
+
TFOpt was originally developed by **Philomina Lillie Normann** and subsequently extended and refined by **Abhinav Mishra**, with improvements to computational performance, code consistency, and software architecture.
|
|
19
|
+
|
|
20
|
+
**Documentation:** <https://bibymaths.github.io/TFOpt/> (configured for this address) ·
|
|
21
|
+
[Changelog](docs/CHANGELOG.md) · [Cite](CITATION.cff) · [Security](SECURITY.md) · [Terms of use](TERMS_OF_USE.md) · [Third-party](THIRD_PARTY.md)
|
|
22
|
+
|
|
23
|
+
TFOpt estimates transcription-factor (TF) contributions to time-resolved mRNA expression. For every target mRNA it
|
|
24
|
+
fits how much each of its TFs contributes (α), and for every TF how its protein series and its own phosphosite series
|
|
25
|
+
combine into its activity (β):
|
|
26
|
+
|
|
27
|
+
$$\hat R_j(t)=\max\Big(0,\sum_{i}\alpha_{ji}\big[\beta_{i0}X_i(t)+\sum_s\beta_{is}S_{is}(t)\big]\Big),\qquad
|
|
28
|
+
\sum_i\alpha_{ji}=1,\ \alpha_{ji}\in[0,1],\qquad \beta_{i0}+\sum_s\beta_{is}=1$$
|
|
29
|
+
|
|
30
|
+
$X_i$ is the TF's input1 protein row, else its input3 mRNA; $S_{is}$ are its own input1 phosphosites. β may be
|
|
31
|
+
negative within its bounds; padded regulator slots are fixed to zero. The default objective is `loss_type` 5 (MSE plus
|
|
32
|
+
an elastic-net penalty on β) and the default solver is SciPy SLSQP with the constraints and bounds as exact
|
|
33
|
+
constraints and analytic JAX gradients (`scipy-slsqp`), run from 64 seeded starts with jitter 0.10, with feasibility
|
|
34
|
+
and KKT diagnostics. TFOpt shares KinOpt's architecture and developer workflow; its signals, parameters and diagnostics
|
|
35
|
+
are TF-specific. See [TF Optimization](https://bibymaths.github.io/TFOpt/Documentation/tfopt/README.html) and the
|
|
36
|
+
[TF base series design note](https://bibymaths.github.io/TFOpt/Documentation/tfopt/tf_series.html).
|
|
37
|
+
|
|
38
|
+
## Install and run
|
|
39
|
+
|
|
40
|
+
From a clone of the repository, with [Pixi](https://pixi.sh):
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pixi install
|
|
44
|
+
pixi run tfopt example my-project # a synthetic example project (config.toml and three CSVs)
|
|
45
|
+
pixi run tfopt validate --config my-project/config.toml
|
|
46
|
+
pixi run tfopt run --config my-project/config.toml # or: pixi run tfopt-local --config my-project/config.toml
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
TFOpt installs three commands: `tfopt` (subcommands `run`, `validate`, `bundle`, `readout`, `figures`, `network`,
|
|
50
|
+
`similarity`, `diagram`, `example`, `app`), `tfopt-local` (the fit with the options of earlier versions) and
|
|
51
|
+
`tfopt-app` (a guided GUI in the browser). The library is `tfopt.api` (`load_config`, `RunConfig`, `validate_inputs`,
|
|
52
|
+
`run`, `read_results`). See [Command line](https://bibymaths.github.io/TFOpt/Documentation/cli.html).
|
|
53
|
+
|
|
54
|
+
A run reads one `config.toml`: the one given with `--config`, else `TFOPT_CONFIG`, else the clone's. Paths resolve
|
|
55
|
+
relative to that file. The shipped `config.toml` points at user-supplied inputs in `data/`; it never substitutes the
|
|
56
|
+
tutorial data.
|
|
57
|
+
|
|
58
|
+
- `input1`: TF protein and phosphosite series: `GeneID`, `Psite`, then one column per MS time point. The empty-Psite
|
|
59
|
+
row is the TF's protein series and `S_`/`T_`/`Y_` rows are its phosphosites. A TF without a protein row falls back
|
|
60
|
+
to its input3 mRNA (logged); a TF with neither is excluded with its edges (logged).
|
|
61
|
+
- `input3`: mRNA series: `GeneID`, then one column per RNA time point.
|
|
62
|
+
- `input4`: regulation edges: `Source` TF, `Target` mRNA.
|
|
63
|
+
|
|
64
|
+
The time grids are part of the configuration and have no default: `[tfopt] time_points` (RNA times of input3's
|
|
65
|
+
columns, the fit times) and `ms_time_points` (MS times of input1's columns). input1 series are taken at the RNA times by
|
|
66
|
+
actual time.
|
|
67
|
+
|
|
68
|
+
Results go to `paths.results_dir`: the workbook `tfopt_results.xlsx` (Alpha Values, Beta Values with `Source`,
|
|
69
|
+
Residuals, Observed, Estimated, Optimization Results, KKT Diagnostics, KKT Multipliers, Prediction Check), `multistart_summary.csv`,
|
|
70
|
+
`multistart_params.npz`, `diagnostics.json`, `run_config.json`, fit plots, fit-analysis figures, LaTeX tables,
|
|
71
|
+
`report.html` and the run bundle `<results>.tfopt.zip`. Use a new results folder for each run.
|
|
72
|
+
|
|
73
|
+
| Setting | Default |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `method` | `scipy-slsqp` (exact constraints). The JAXopt methods (`lbfgsb`, `projected-gradient`, `non-negative`, `unconstrained`) are approximate for the production problem |
|
|
76
|
+
| `n_starts`, `jitter_scale` | 64, 0.10 |
|
|
77
|
+
| `seed`, `start_seed` | 123, 0 |
|
|
78
|
+
| `loss_type` | 5 (elastic net) |
|
|
79
|
+
| β bounds | −4, 4 |
|
|
80
|
+
| `tf_protein_source`, `ms_alignment` | `protein_then_mrna`, `by_time` |
|
|
81
|
+
| `time_points`, `ms_time_points` | required, no default |
|
|
82
|
+
|
|
83
|
+
See the [Configuration Reference](https://bibymaths.github.io/TFOpt/Documentation/configuration.html).
|
|
84
|
+
|
|
85
|
+
## Regulatory readout
|
|
86
|
+
|
|
87
|
+
`tfopt readout`, `tfopt figures`, `tfopt network`, `tfopt similarity` and `tfopt diagram` analyse a fitted results
|
|
88
|
+
folder without refitting: signed TF contributions, TF protein/phosphosite components, target dominance, regulatory
|
|
89
|
+
loads, fixed-parameter TF-removal sensitivity, the directed TF → mRNA network, the Fréchet distance between observed
|
|
90
|
+
and estimated series, and model diagrams. Missing required signals are reported, never replaced with zeros. gravis,
|
|
91
|
+
Graphviz and pydot (for `network` and `diagram`) are in the optional `viz` environment.
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pixi install -e dev
|
|
97
|
+
pixi run -e dev check-import
|
|
98
|
+
pixi run -e dev test
|
|
99
|
+
pixi run -e dev test-cov
|
|
100
|
+
TFOPT_CONFIG=notebooks/data/toy.toml pixi run tfopt-local # the tutorial dataset end to end
|
|
101
|
+
pixi run -e docs docs-build # executes the tutorials, then builds the site
|
|
102
|
+
pixi run -e docs docs-serve
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The documentation (Zensical, `zensical.toml`) lives in `docs/`; the tutorials are the notebooks
|
|
106
|
+
`notebooks/00`–`10`, executed and rendered into `docs/tutorials/` by `tools/build_tutorials.py` when the site is built.
|
|
107
|
+
The brand marks in `docs/assets/brand/` are generated by `tools/build_brand.py`. The use cases of the documentation
|
|
108
|
+
(`docs/examples/`) are run by the test suite.
|
|
109
|
+
|
|
110
|
+
## Provenance
|
|
111
|
+
|
|
112
|
+
TFOpt was extracted from the integrated PhosKinTime source into an independent package; the upstream scientific
|
|
113
|
+
implementation and comments keep Philomina Lillie Normann's authorship and Abhinav Mishra's subsequent work. See
|
|
114
|
+
[Architecture](https://bibymaths.github.io/TFOpt/Documentation/architecture.html#provenance-and-migration) for the
|
|
115
|
+
migration record. No KinOpt DOI is asserted for TFOpt; cite it with [CITATION.cff](CITATION.cff).
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
BSD-3-Clause, see `LICENSE`.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Third-party material
|
|
2
|
+
|
|
3
|
+
TFOpt itself is licensed under BSD-3-Clause ([`LICENSE`](https://github.com/bibymaths/TFOpt/blob/main/LICENSE)), for the code, the documentation and the brand
|
|
4
|
+
marks. This file lists material from others that is part of, or used by, this repository.
|
|
5
|
+
|
|
6
|
+
## Material included in TFOpt
|
|
7
|
+
|
|
8
|
+
### phoskintime-vis design tokens (GUI stylesheet)
|
|
9
|
+
|
|
10
|
+
`tfopt/app/static/app.css` (the GUI `tfopt-app`) contains design tokens and base styles copied from phoskintime-vis
|
|
11
|
+
(`src/app.css`), by way of KinOpt's `kinopt-app`. They are used under the BSD 3-Clause License:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
BSD 3-Clause License
|
|
15
|
+
|
|
16
|
+
Copyright (c) 2026, BioVisForge
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Redistribution and use in source and binary forms, with or without
|
|
20
|
+
modification, are permitted provided that the following conditions are met:
|
|
21
|
+
|
|
22
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
23
|
+
list of conditions and the following disclaimer.
|
|
24
|
+
|
|
25
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
26
|
+
this list of conditions and the following disclaimer in the documentation
|
|
27
|
+
and/or other materials provided with the distribution.
|
|
28
|
+
|
|
29
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
30
|
+
contributors may be used to endorse or promote products derived from
|
|
31
|
+
this software without specific prior written permission.
|
|
32
|
+
|
|
33
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
34
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
35
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
36
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
37
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
38
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
39
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
40
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
41
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
42
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The brand marks in `docs/assets/brand/` are original work of this project. `tools/build_brand.py` draws their
|
|
46
|
+
letters as strokes; no font outlines are used.
|
|
47
|
+
|
|
48
|
+
## Runtime dependencies (`pip install tfopt`)
|
|
49
|
+
|
|
50
|
+
These are installed as dependencies; TFOpt does not distribute them. Versions are those validated in `pixi.lock`.
|
|
51
|
+
|
|
52
|
+
| Package | Version | License | Used for |
|
|
53
|
+
|---|---|---|---|
|
|
54
|
+
| NumPy | 2.5.4 | BSD-3-Clause (bundled parts: 0BSD, MIT, Zlib, CC0-1.0) | arrays |
|
|
55
|
+
| pandas | 2.3.3 | BSD-3-Clause | tables, CSV and Excel I/O |
|
|
56
|
+
| SciPy | 1.18.1 | BSD-3-Clause | SLSQP driver (`scipy-slsqp`), PCHIP interpolation |
|
|
57
|
+
| scikit-learn | 1.9.1 | BSD-3-Clause | fit metrics |
|
|
58
|
+
| JAX, jaxlib | 0.4.38 | Apache-2.0 | objective and analytic gradients (float64) |
|
|
59
|
+
| JAXopt | 0.8.4 | Apache-2.0 | JAXopt methods (projected gradient, L-BFGS-B) |
|
|
60
|
+
| Matplotlib | 3.9.1 | Matplotlib License (PSF-based) | figures |
|
|
61
|
+
| seaborn | 0.13.2 | BSD-3-Clause | figures |
|
|
62
|
+
| Plotly | 7.1.0 | MIT | interactive per-target plots |
|
|
63
|
+
| openpyxl | 3.1.5 | MIT | reading workbooks |
|
|
64
|
+
| XlsxWriter | 3.2.9 | BSD-2-Clause | writing workbooks |
|
|
65
|
+
| NetworkX | 3.7 | BSD-3-Clause | regulatory networks |
|
|
66
|
+
| PyArrow | 19.0.1 | Apache-2.0 | Parquet tables of the run bundle |
|
|
67
|
+
| Jinja2 | 3.1.6 | BSD-3-Clause | LaTeX tables (pandas `to_latex`) |
|
|
68
|
+
|
|
69
|
+
## Optional extras (Pixi `viz` environment)
|
|
70
|
+
|
|
71
|
+
| Package | License | Used for |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| gravis | Apache-2.0 | `tfopt network` (interactive network HTML) |
|
|
74
|
+
| pydot | MIT | `tfopt diagram` |
|
|
75
|
+
| Graphviz | EPL-1.0 | `tfopt diagram` (renderer) |
|
|
76
|
+
|
|
77
|
+
## Documentation and development tools (not distributed)
|
|
78
|
+
|
|
79
|
+
Zensical, mkdocstrings and mkdocstrings-python, pymdown-extensions, nbconvert, nbclient, ipykernel, pytest and
|
|
80
|
+
pytest-cov, git-cliff, build, twine and Pixi are used to build, test and release TFOpt. Each keeps its own licence.
|
|
81
|
+
The documentation site loads KaTeX (MIT) and Mermaid (MIT) from a CDN.
|
|
82
|
+
|
|
83
|
+
Users are responsible for complying with the licences of all transitive dependencies (see `pixi.lock`).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Independent TOML configuration with KinOpt-style section/mode merging."""
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import tomllib
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
def _project_root():
|
|
8
|
+
return Path(__file__).resolve().parent
|
|
9
|
+
|
|
10
|
+
def _deep_merge(base, override):
|
|
11
|
+
result = dict(base)
|
|
12
|
+
for key, value in override.items():
|
|
13
|
+
result[key] = _deep_merge(result[key], value) if isinstance(value, dict) and isinstance(result.get(key), dict) else value
|
|
14
|
+
return result
|
|
15
|
+
|
|
16
|
+
def config_path():
|
|
17
|
+
args = sys.argv[1:]
|
|
18
|
+
for i, arg in enumerate(args):
|
|
19
|
+
if arg == '--conf' and i + 1 < len(args):
|
|
20
|
+
return Path(args[i+1]).expanduser().resolve()
|
|
21
|
+
if arg.startswith('--conf='):
|
|
22
|
+
return Path(arg.split('=',1)[1]).expanduser().resolve()
|
|
23
|
+
return Path(os.environ.get('TFOPT_CONFIG', _project_root() / 'config.toml')).resolve()
|
|
24
|
+
|
|
25
|
+
def load(mode='local', section='tfopt'):
|
|
26
|
+
path = config_path()
|
|
27
|
+
with path.open('rb') as handle:
|
|
28
|
+
raw = tomllib.load(handle)
|
|
29
|
+
base = raw.get(section, {})
|
|
30
|
+
cfg = _deep_merge(base, base.get('modes', {}).get(mode, {}))
|
|
31
|
+
cfg['_paths'] = raw.get('paths', {})
|
|
32
|
+
cfg['_root'] = str(path.parent)
|
|
33
|
+
return cfg
|
|
34
|
+
|
|
35
|
+
def ensure_dirs():
|
|
36
|
+
cfg = load()
|
|
37
|
+
for value in cfg['_paths'].values():
|
|
38
|
+
(Path(cfg['_root']) / value).mkdir(parents=True, exist_ok=True)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Package metadata for the PyPI distribution `tfopt` (built by the release workflow, .github/workflows/publish.yml).
|
|
2
|
+
# Development environments and their dependencies are managed by Pixi in pixi.toml.
|
|
3
|
+
|
|
4
|
+
[build-system]
|
|
5
|
+
requires = ["setuptools>=77"]
|
|
6
|
+
build-backend = "setuptools.build_meta"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "tfopt"
|
|
10
|
+
version = "0.2.0"
|
|
11
|
+
description = "Optimization-based estimation of transcription-factor contributions to mRNA time-series expression, with TF activity built from TF protein and phosphosite series."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = "BSD-3-Clause"
|
|
14
|
+
license-files = ["LICENSE", "THIRD_PARTY.md"]
|
|
15
|
+
authors = [{ name = "Philomina Lillie Normann" }, { name = "Abhinav Mishra" }]
|
|
16
|
+
requires-python = ">=3.12"
|
|
17
|
+
dependencies = [
|
|
18
|
+
# Lower bounds: the versions the release was validated with (pixi.lock). For exact reproduction of published
|
|
19
|
+
# results use pixi.lock; pip install gives compatible versions.
|
|
20
|
+
"numpy>=2.5.4,<3",
|
|
21
|
+
"pandas>=2.3.3,<3",
|
|
22
|
+
"scipy>=1.18.1,<2",
|
|
23
|
+
"scikit-learn>=1.9.1,<2",
|
|
24
|
+
"jax>=0.4.38,<0.13",
|
|
25
|
+
"jaxlib>=0.4.38,<0.13",
|
|
26
|
+
"jaxopt>=0.8.4,<1",
|
|
27
|
+
"matplotlib>=3.9.1,<4",
|
|
28
|
+
"seaborn>=0.13.2,<1",
|
|
29
|
+
"plotly>=7.1.0,<8",
|
|
30
|
+
"openpyxl>=3.1.5,<4",
|
|
31
|
+
"xlsxwriter>=3.2.9,<4",
|
|
32
|
+
"networkx>=3.7,<4",
|
|
33
|
+
"pyarrow>=19.0.1,<27",
|
|
34
|
+
"jinja2>=3.1.6,<4",
|
|
35
|
+
]
|
|
36
|
+
keywords = ["transcription factor", "gene regulation", "time series", "constrained optimization", "systems biology"]
|
|
37
|
+
classifiers = [
|
|
38
|
+
"Development Status :: 4 - Beta",
|
|
39
|
+
"Intended Audience :: Science/Research",
|
|
40
|
+
"Operating System :: OS Independent",
|
|
41
|
+
"Programming Language :: Python :: 3",
|
|
42
|
+
"Programming Language :: Python :: 3.12",
|
|
43
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
Homepage = "https://github.com/bibymaths/TFOpt"
|
|
48
|
+
Documentation = "https://bibymaths.github.io/TFOpt/"
|
|
49
|
+
Changelog = "https://github.com/bibymaths/TFOpt/blob/main/docs/CHANGELOG.md"
|
|
50
|
+
"Release notes" = "https://github.com/bibymaths/TFOpt/tree/main/release-notes"
|
|
51
|
+
Issues = "https://github.com/bibymaths/TFOpt/issues"
|
|
52
|
+
|
|
53
|
+
[project.scripts]
|
|
54
|
+
tfopt = "tfopt.cli:console_main"
|
|
55
|
+
tfopt-local = "tfopt.local.__main__:console_main"
|
|
56
|
+
tfopt-app = "tfopt.app.__main__:console_main"
|
|
57
|
+
|
|
58
|
+
[tool.setuptools]
|
|
59
|
+
py-modules = ["config_loader"]
|
|
60
|
+
|
|
61
|
+
[tool.setuptools.packages.find]
|
|
62
|
+
include = ["tfopt", "tfopt.*"]
|
|
63
|
+
|
|
64
|
+
[tool.setuptools.package-data]
|
|
65
|
+
"tfopt.bundle" = ["contract/*/*.json"]
|
|
66
|
+
"tfopt.app" = ["static/*.html", "static/*.js", "static/*.css"]
|
tfopt-0.2.0/setup.cfg
ADDED