torchcell.models.cell_graph_transformer_metabolism.FluxMetaboliteHead
- class FluxMetaboliteHead(metabolite_indices: Tensor, param_dim: int = 1)[source]
Bases:
ModuleRead a measured metabolite level off the predicted flux vector’s turnover.
The mechanistic head. Instead of an MLP over pooled gene tokens, it reads
\[\omega_i(v)=\tfrac12\sum_j\lvert S_{ij}v_j\rvert\]at the metabolite indices that the measurement actually names, and maps each through its own affine in log space:
\[\hat y_k = a_k\,\log\!\big(1+\omega_{i_k}(v)\big) + b_k .\]Turnover is not concentration, and the affine is where that gap is admitted. A metabolite’s pool size depends on its turnover and on its effective residence time, and a steady-state flux model has no residence time in it. What the model can claim is that a strain whose flux carries more mass through tyrosine should have more tyrosine, monotonically – which is exactly what a per-metabolite affine in \(\log\omega\) encodes, and it is why the metric to read is a correlation rather than an error in mM.
A per-metabolite affine, not a shared one, because the 19 amino acids differ by orders of magnitude in both pool size and flux; one shared slope would make the largest pool set the scale for all of them.