13C Metabolic Flux Analysis

13C Metabolic Flux Analysis

Guides an AI agent to estimate intracellular metabolic fluxes from carbon-13 tracing data using atom maps, mfapy simulation and constrained multistart fitting with diagnostics.

Skill files16 files

assets/

references/

scripts/

SKILL.md218 lines
1
---
2
name: 13c-metabolic-flux
3
description: Estimates intracellular metabolic fluxes from steady-state carbon-13 isotope-tracing measurements using validated atom maps, mfapy isotope simulation, constrained multistart fitting, and flux-profile diagnostics. Use for 13C-MFA, carbon tracing, mass isotopomer distributions (MDVs/MIDs), positional isotopomers, parallel tracer experiments, and determining whether labeling data constrain a pathway flux. Distinguishes measured-label inference from COBRA flux balance analysis and flags experiments requiring nonstationary MFA.
4
license: MIT
5
compatibility: Python 3.12 with uv and Git for installation. Tested with mfapy 0.6.3 at a10433af16682386548b360297e2476152d46ede, NumPy 2.5.3, SciPy 1.18.1, and NLopt 2.11.0. Network access is needed only to install public dependencies. Inference runs locally without credentials; inputs are JSON.
6
metadata:
7
version: "1.2"
8
skill-author: K-Dense Inc.
9
last-reviewed: "2026-09-30"
10
---
11
12
# Carbon-13 metabolic flux inference
13
14
Turn reviewed carbon maps, explicit tracer mixtures, and corrected labeling measurements
15
into feasible flux estimates and evidence about which fluxes the experiment constrains.
16
Use the bundled solver rather than reconstructing isotope balances or fitting each
17
reaction independently. It runs mfapy's EMU forward simulator and fits fluxes in the
18
mass-balanced feasible space with SciPy. It does not use an FBA objective.
19
20
## Scope and required evidence
21
22
This implementation supports **metabolic and isotopic steady state**, a single shared
23
flux state across one or more tracer experiments, nonnegative one-way reaction fluxes,
24
and carbon-subset mass distributions. Reversible reactions are two separately mapped
25
directions. Measurement error is Gaussian with a supplied covariance or a disclosed
26
diagonal approximation.
27
28
Before fitting, obtain:
29
30
- The carbon network and the source of each atom assignment. Stoichiometry alone does
31
not specify where labeled atoms go. Record compartments as separate metabolite IDs.
32
- Evidence for both steady-state assumptions. Stable metabolite abundance does not
33
establish isotopic steady state. Time-course labeling requires INST-MFA with pool
34
sizes and initial labeling; do not average it into this solver.
35
- Every carbon input's positional isotopomer distribution, including unlabeled
36
supplements, bicarbonate/CO2 when assimilated, and tracer impurity.
37
- Fragment carbon assignments, natural-abundance correction history, and uncertainty
38
of the **reported mean**. Raw peak intensities, derivatized spectra, and MS/MS
39
transitions require validated preprocessing before these inputs can be constructed.
40
- Flux units, extracellular rate measurements or a stated relative-flux reference,
41
and biologically justified bounds. Label fractions alone cannot set an absolute rate.
42
43
If necessary information is missing, name it and prepare the input template; do not
44
invent a fragment assignment, atom map, isotope correction, or measurement error.
45
Read [references/input-contract.md](references/input-contract.md) when preparing inputs.
46
Read [references/inference.md](references/inference.md) before interpreting an actual fit.
47
48
## Install the tested engine
49
50
Run in the user's analysis directory. Set `SKILL_DIR` to this skill's installed directory,
51
using the actual resolved path. Keep environments and generated results outside the skill.
52
53
```bash
54
uv venv --python 3.12 .venv-mfa
55
uv pip install --python .venv-mfa/bin/python -r "$SKILL_DIR/assets/requirements.txt"
56
```
57
58
The following commands use `.venv-mfa/bin/python`; on Windows use the environment's
59
`Scripts/python.exe`. mfapy is installed from an immutable Git revision because it is
60
not distributed on PyPI. Installation executes dependency build code; model inputs
61
are data, not user-supplied Python. The adapter restricts identifiers and atom-map
62
syntax before they reach mfapy's internally generated numerical functions.
63
64
The pinned commit matched upstream `master` on 2026-09-30. Its README labels the
65
latest change "064", but its installed distribution still reports `0.6.3`; retain
66
the Git commit alongside the package version in an analysis record. The refreshed
67
NumPy/SciPy pins require Python 3.12 or later; the commands above use the tested 3.12
68
environment. See the reviewed forward-model contract in
69
[references/inference.md](references/inference.md).
70
71
## Workflow
72
73
1. **Prepare explicit inputs.** Copy a relevant model asset into the analysis directory,
74
then replace its scientific content only from reviewed evidence. The bundled models
75
are demonstrations, not validated organism-specific reconstructions. Use a separate
76
dataset for each biological condition; jointly fit tracer replicates only when their
77
biological flux state is defensibly shared.
78
2. **Check the contract and feasibility.**
79
80
```bash
81
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" check \
82
--model model.json --data measurements.json --output input-check.json
83
```
84
85
This checks atom counts and conservation, fragments, tracer sums, uncertainty
86
matrices, bounds, and steady-state mass-balance feasibility. It cannot verify that a
87
chemically consistent atom map is biologically correct or that a sample reached steady state.
88
3. **Exercise the forward model.** Supply one mass-balanced flux vector in the declared
89
units. Compare predicted labeling with a reference or independently derived limits.
90
91
```bash
92
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" simulate \
93
--model model.json --data measurements.json --fluxes fluxes.json \
94
--output simulated-mdvs.json
95
```
96
97
4. **Fit and profile the fluxes relevant to the question.**
98
99
```bash
100
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" fit \
101
--model model.json --data measurements.json --starts 12 --seed 2026 \
102
--profile v3 --profile v7 --profile-points 31 --profile-starts 6 \
103
--output fit.json
104
```
105
106
Replace `v3` and `v7` with actual reaction IDs. Each profile point fixes that reaction
107
and reoptimizes nuisance fluxes. For nonlinear networks, repeat with a different seed
108
and more starts before interpreting a profile. A small residual is not an
109
identifiability result.
110
5. **Inspect the evidence.** Check failed starts, residual patterns, mass balance,
111
active bounds, local sensitivity rank, and profile status. Report threshold-crossing
112
brackets at their actual grid resolution. Refine the grid if they are too coarse.
113
Each requested profile gives a one-flux interval under the stated error model;
114
multiple 95% profiles are not a simultaneous 95% region for the whole network.
115
If a profile finds a better solution than the baseline, rerun the fit; do not publish
116
the stale intervals. A failed profile point is unknown, not excluded by the data.
117
6. **Deliver a bounded scientific result.** Include model and data hashes, package
118
versions, source/correction provenance, units and reference flux, fitted predictions,
119
residual diagnostics, profile plots or a table, and the unresolved flux combinations.
120
Retain the JSON artifact. Separate point estimates supported by the data from arbitrary
121
optimizer choices along a flat direction. Suggest additional measurements only after
122
testing that their predicted labeling changes along that direction.
123
124
## Worked examples
125
126
These executable examples use synthetic, tracer-only data. There is no hidden natural-
127
abundance correction, and the tracer proportions already include unlabeled material.
128
129
### Recover a pathway split; then remove the informative measurement
130
131
The analytical two-route model sends a two-carbon substrate through either a
132
carbon-preserving or a carbon-swapping route. Uptake is fixed to 100. An 80% carbon-1
133
labeled feed and a carbon-1 fragment with M+1 = 0.56 determine the preserving route
134
as 70 and the swapping route as 30.
135
136
```bash
137
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" fit \
138
--model "$SKILL_DIR/assets/branch-model.json" \
139
--data "$SKILL_DIR/assets/branch-identifiable.json" \
140
--profile straight --profile-points 41 --output branch-fit.json
141
142
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" fit \
143
--model "$SKILL_DIR/assets/branch-model.json" \
144
--data "$SKILL_DIR/assets/branch-unresolved.json" \
145
--profile straight --output unresolved-fit.json
146
```
147
148
The first fit recovers approximately 70/30. Under its declared Gaussian error model,
149
the analytical 95% interval for `straight` is about 67.55–72.45; the script reports
150
grid brackets enclosing the threshold crossings. The second fit has only the whole-
151
molecule distribution, which is identical for the two routes. Expect local rank zero
152
and `unresolved_within_bounds`; its returned split is an arbitrary optimum.
153
154
`assets/branch-fluxes.json` supplies the 70/30 forward-simulation vector.
155
156
### Reproduce a published cyclic-network calculation
157
158
```bash
159
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" simulate \
160
--model "$SKILL_DIR/assets/tca-model.json" \
161
--data "$SKILL_DIR/assets/tca-tracer.json" \
162
--fluxes "$SKILL_DIR/assets/tca-fluxes.json" --output tca-simulation.json
163
164
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" fit \
165
--model "$SKILL_DIR/assets/tca-model.json" \
166
--data "$SKILL_DIR/assets/tca-reference-mdv.json" \
167
--profile v3 --profile v7 --output tca-fit.json
168
```
169
170
The first command reproduces the published rounded glutamate MDV
171
`[0.3464, 0.2695, 0.2708, 0.0807, 0.0286, 0.0039]`.
172
The second uses synthetic reference measurements to recover the glutamate branch
173
flux near 50, while recognizing that this labeling does not resolve the
174
fumarate/oxaloacetate exchange. A constraint-induced upper edge is not evidence of
175
a measurement-determined exchange interval.
176
177
## Interpretation boundaries
178
179
- A positional isotopomer string runs **carbon 1 to carbon N from left to right**.
180
`"100000"` means carbon-1 labeled glucose. A mass distribution alone cannot specify
181
that positional mixture. The adapter handles mfapy's reversed integer-bit ordering.
182
- Natural-abundance correction and tracer-purity correction are different operations.
183
Inputs must be in the documented tracer-only basis, with tracer impurity represented
184
consistently in source mixtures. Do not correct the same contribution twice.
185
- An N-carbon mass distribution has at most N independent components because it sums
186
to one. The tool removes one bin and uses the reduced covariance. Retain cross-bin
187
correlations when available. Diagonal SEM fits are explicitly approximate.
188
- The `symmetric` flag means equal averaging of identity and **complete carbon-order
189
reversal**, as in the bundled fumarate/succinate map. It is not arbitrary molecular
190
symmetry. Other permutations need an explicitly supported model representation.
191
- Unsupported in this CLI: nonstationary MFA, isotope effects on reaction rates,
192
unmodeled pools or compartments, MS/MS joint distributions, multi-element isotope
193
correction, fractional carbon stoichiometry/pseudo-reactions, and organism-scale
194
performance guarantees. For these, use a validated specialized model/engine and
195
retain the same input/provenance and identifiability discipline.
196
197
## Implementation and validation
198
199
`scripts/mfa.py` is the CLI. `scripts/_mfa_model.py` validates inputs and adapts them to
200
the mfapy EMU simulator; `scripts/_mfa_fit.py` handles feasible flux coordinates,
201
multistart optimization, diagnostic rank, and profile calculations.
202
The engine is pinned in [assets/requirements.txt](assets/requirements.txt).
203
204
The repository suite at `tests/13c-metabolic-flux/` checks the published reference,
205
analytical split recovery and likelihood profiles, unresolved routes and exchange,
206
omitted-bin invariance with correlated errors, parallel tracers, absolute-rate
207
anchoring, repeated-substrate condensation, symmetry, invalid maps, and CLI behavior.
208
These checks establish the tested numerical behavior, not biological validation of a
209
user's model or a measured advantage over any particular language model.
210
211
## Sources
212
213
- [mfapy source at the tested revision](https://github.com/fumiomatsuda/mfapy/tree/a10433af16682386548b360297e2476152d46ede), version 0.6.3; [API documentation](https://fumiomatsuda.github.io/mfapy-document/mfapy.html).
214
- Matsuda et al. (2021), [mfapy: An open-source Python package for 13C-based metabolic flux analysis](https://doi.org/10.1016/j.mec.2021.e00177).
215
- Antoniewicz, Kelleher, and Stephanopoulos (2007), [Elementary metabolite units (EMU): A novel framework for modeling isotopic distributions](https://doi.org/10.1016/j.ymben.2006.09.001).
216
- The TCA network is adapted from mfapy's MIT-licensed example files; the attribution
217
and full notice are in [assets/mfapy-license.txt](assets/mfapy-license.txt).
218

© K-Dense Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 12,830 prompts

More by @OpenSourceBuffGuy

See all
Continuous Testing prompt image

Continuous Testing

Guides an AI agent to build continuous testing into CI/CD pipelines with GitHub Actions, GitLab CI and Jenkins, including test selection, parallel runs and flaky test detection.

agent-skill, ci-cd, testing, devops, github-actions, gitlab, best-practices, test-generation, workflow-automation, unit-testing, end-to-end-testing, deployment, code, for-developers, for-devops-engineers, step-by-step-guide, long-form, observability, dashboard, jenkins, flaky-tests

Cybernetic Portrait with Prosthetic Hand prompt image

Cybernetic Portrait with Prosthetic Hand

Draws a gritty cinematic close-up of a freckled young woman beside a weathered mechanical prosthetic hand, with metallic augmentations on a grey studio backdrop.

image-prompt, nano-banana, photorealistic, cinematic, cyberpunk, futuristic, portrait, woman, close-up, robots, editorial, studio-lighting, dramatic-lighting, muted-colors, moody, 3d-render, digital-art, macro, negative-space, long-form

National Park Trail Map Rising Into Miniature Diorama prompt image

National Park Trail Map Rising Into Miniature Diorama

Draws a national park trail map on a picnic table whose terrain rises into a tiny living diorama; a fill-in template for trailhead, wildlife, water and weather.

image-prompt, placeholders, template, maps, miniature, landscape, mountains, forest, animals, outdoors, hiking, camping, golden-hour, text-rendering, nano-banana, adobe-firefly, for-travelers

Reviews

Loading reviews…

Discussion

Loading comments…