Skip to content

TF base series and time alignment (design note, T6/T6c)

This note records the approved model of a TF's activity (DECISIONS_T6, owner decision) and the two defects it corrects. Only the regulator base series $X_i$ and the time alignment of input1 changed. The objective, the constraints and the bounds are unchanged. The settings are described in the Configuration Reference; the model as a whole in TF Optimization.

Model

$$ X_i(t) = \begin{cases} P_i(t) & \text{if TF } i \text{ has an input1 protein row (empty Psite)} \quad \text{source} = \texttt{protein}\ R_i(t) & \text{otherwise, if TF } i \text{ has input3 mRNA} \quad \text{source} = \texttt{mrna} \text{ (logged)} \end{cases} $$

A TF with neither series is excluded together with its edges, and each excluded edge is logged.

$$ A_i(t) = \beta_{i0}\,X_i(t) + \sum_{s\in\mathcal{S}i} \beta(t), \qquad \hat R_j(t) = \max\Big(0,\ \sum_{i\in\mathcal{T}}\,S_{isj} \alpha\,A_i(t)\Big) $$

$S_{is}$ are TF $i$'s own input1 phosphosite rows. The clip at zero is the existing one in compute_predictions.

$$ \min_{\theta=(\alpha,\beta)}\ \frac{1}{N}\sum_j\sum_{t\in T_\mathrm{RNA}}\big(R_j(t)-\hat R_j(t)\big)^2 + \lambda_1\lVert\beta\rVert_1 + \lambda_2\lVert\beta\rVert_2^2 $$

This is loss_type 5, unchanged. As before, the regularisation acts on the β block.

The constraints are $\sum_i \alpha_{ji} = 1$ and $0 \le \alpha_{ji} \le 1$ per target, over real edges only. For each TF, $\beta_{i0} + \sum_s \beta_{is} = 1$ within the configured β bounds.

Rationale. TFOpt fits target mRNA. A TF acts as a protein, so its activity is built from its protein and its own phosphosites, in the same way KinOpt builds a kinase's activity. This matches the ODE in PhosKinTime, where the simulated TF protein drives transcription. The TF's own mRNA is only a fallback proxy.

Settings

key values meaning
tf_protein_source protein_then_mrna (default), mrna, legacy_first_site how $X_i$ is chosen; legacy_first_site reproduces the shipped behaviour and is for control runs only
ms_time_points required (no default); 14 MS times for the shipped data times (min) of input1's columns
time_points required (no default); 9 RNA times for the shipped data times (min) of input3's columns, which are the fit times
ms_alignment by_time (default), legacy_position how input1 series are taken at the RNA times

The Beta Values sheet has a Source column. On each TF-level row (empty PSite) it gives the series that β multiplies (protein, mrna, or first_site in the legacy control). On site rows it reads site. Fit-analysis (tfopt.fitanalysis) rebuilds signals from this column. Workbooks without the column were written before T6, and fit-analysis reads them with the legacy rules.

Defect T6: the "protein" β multiplied a phosphosite

Up to this change the loader skipped every input1 row whose Psite did not start with S_/T_/Y_. That included the protein row, whose Psite is empty. The loader then used the TF's first remaining row, its first phosphosite in file order, as the "protein" series. The rule was introduced in commit 085e15f (2025‑04‑22).

In the shipped workbook (tfopt_results.xlsx, sha256 8ff6c012…), 34 of the 149 TFs therefore had their "protein" β applied to a phosphosite. The other 115 used their mRNA. With that rule, all 16 Estimated targets are rebuilt from the inputs to within 6.7e‑16.

Defect T6c: positional time alignment

input1 has 14 MS columns at 0, 0.5, 0.75, 1, 2, 4, 8, 16, 30, 60, 120, 240, 480 and 960 min. input3 has 9 RNA columns at 4, 8, 15, 30, 60, 120, 240, 480 and 960 min. Taking "the last 9 MS columns" paired RNA 15 min with MS 16 min. Every input1 series is now taken at the RNA times by actual time. Where the MS grid has the RNA time, the value is copied unchanged. Otherwise it is PCHIP-interpolated over the full MS grid; here that applies only at t = 15, which lies between 8 and 16. ms_alignment = "legacy_position" keeps the old pairing, with a logged warning, so the shipped workbook can be reproduced.

Tests

tests/test_t6_series.py covers:

  • the loader on the real input1 layout;
  • $X_i$ selection and logging, and the exclusion of TFs that have no series;
  • the toy data layout;
  • an independent reference rebuild of Estimated (tests/t6_reference.py) to 1e‑12;
  • the Source column;
  • the alignment: detection of the 15/16 pairing, bit-identical shared points, and PCHIP at 15 min.

With TFOPT_T6_DATA pointing at the shipped data, the file also checks that legacy_first_site together with legacy_position reproduces the shipped Estimated sheet to 1e‑12, and that a rebuild from the shipped inputs works. The sha256 of each file is checked first.

Adopted result (DECISIONS_T6)

The fixed run (tf_protein_source = "protein_then_mrna", ms_alignment = "by_time") is adopted as TFOpt's corrected result. All three runs below used the same settings: * inputs: the shipped input1/input3/input4; * solver: scipy-slsqp, tol 1e-10; * multistart: 64 starts, jitter 0.10, seed 123, start_seed 0; * model: loss_type 5, β bounds ±4.

run X_i source alignment accepted starts objective R²
control first phosphosite (legacy_first_site, the shipped behaviour) legacy_position 61/64 0.008672 0.5546
decomposition first phosphosite by_time 59/64 0.008674 0.5543
fixed (adopted) protein row, else mRNA by_time 64/64 0.008838 0.5535

When the "protein" term uses the actual protein row instead of the first phosphosite, the objective rises by 1.9 % (0.008672 → 0.008838) and R² changes from 0.5546 to 0.5535. Of the change in objective, 98.4 % comes from the protein-row fix (T6) and 1.6 % from the time alignment (T6c).

The shipped workbook is not the reference. Its α sum to < 1 for 9 of 16 targets, because of a padded-slot leak in the legacy code, so the reference is the control run.