Skip to content

TFOpt tutorial overview

Download the notebook (executed for this page) · source

TFOpt estimates how much each transcription factor (TF) contributes to the expression of its target mRNAs (α), and how a TF's protein series and its own phosphosite series combine into its activity (β):

$$\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)$$

$X_i$ is TF $i$'s input1 protein row (else its input3 mRNA), $S_{is}$ its own input1 phosphosites. TFOpt shares its architecture with KinOpt; its inputs and model are TF-specific, not kinase equations.

Tutorials 00–09 use a small synthetic dataset with a known solution (notebooks/data/, configuration notebooks/data/toy.toml); tutorial 10 uses the library API on the example project of tfopt example. Begin with the known solution before optimizing: a low objective alone is insufficient without feasibility.

from pathlib import Path
import os, sys
ROOT = next(p for p in [Path.cwd(), *Path.cwd().parents] if (p / 'pixi.toml').exists())
os.environ['TFOPT_CONFIG'] = str(ROOT / 'notebooks/data/toy.toml')
os.environ.setdefault('MPLBACKEND', 'Agg')
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))
import tfopt
import numpy as np
import pandas as pd
from notebooks.tutorial import build_problem, optimize, OUTPUT
p = build_problem()
from tfopt.local.objfn.minfn import objective_
print('Known loss:', float(objective_(p['known'], *p['args'])))
print('Known violation:', p['geometry'].violation(p['known']))
assert p['geometry'].violation(p['known']) < 1e-12
Known loss: 4.8276643939306716e-32
Known violation: 0.0

Interpretation

Check both fit and feasibility. For biological data, identifiability, scaling and regulatory coverage need domain review. Results and figures belong only in notebooks/outputs/.