13c Metabolic Flux
K-DenseCommunityCreated by K-Dense Inc.
- Skill
- Tool integration
- Science and research
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured workflow for performing 13C-metabolic flux analysis (13C-MFA). It enables researchers to estimate intracellular fluxes by fitting experimental carbon-13 labeling data (such as mass isotopomer distributions) to a metabolic network model. The tool uses a forward simulator based on elementary metabolite units (EMU) and a constrained multistart optimization approach to find feasible flux distributions. It is designed to handle steady-state isotope tracing experiments, providing diagnostics to assess flux identifiability and the reliability of the resulting estimates.
What it does
- Simulates mass isotopomer distributions from a given metabolic network and flux state.
- Fits metabolic fluxes to experimental labeling data using constrained multistart optimization.
- Performs flux-profile diagnostics to evaluate the identifiability of specific reaction fluxes.
- Validates input models for mass balance and atom conservation.
- Distinguishes between measured-label inference and flux balance analysis (FBA).
- Generates structured JSON reports containing flux estimates, residuals, and sensitivity diagnostics.
When to use it
- When you have steady-state 13C-labeling data and need to calculate intracellular metabolic fluxes.
- To determine if your experimental labeling data provides sufficient constraints to resolve specific pathway fluxes.
- When you need to compare predicted labeling patterns against experimental measurements for a proposed metabolic model.
- To perform sensitivity analysis on specific fluxes within a metabolic network.
Advantages
- Uses a rigorous EMU-based forward model for accurate isotope simulation.
- Provides local sensitivity diagnostics to identify unresolved or insensitive flux directions.
- Supports complex, multi-tracer experimental designs.
- Enforces strict input validation to ensure chemical and stoichiometric consistency.
- Operates locally with no external dependencies or cloud-based data transmission.
Usage examples
- “Check if my metabolic model and measurement data are consistent for 13C-MFA.”
- The tool validates atom counts, conservation, and mass-balance feasibility, returning a report on whether the inputs are ready for fitting.
- “Estimate fluxes for my TCA cycle model using the provided tracer data.”
- The tool runs a multistart optimization to find a feasible flux vector that minimizes the residual between simulated and experimental mass distributions.
- “Determine the confidence interval for the flux through reaction v3.”
- The tool performs a flux profile analysis, fixing v3 at various points and reoptimizing other fluxes to map the feasible range of v3.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/k-dense-ai/13c-metabolic-flux/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip 13c-metabolic-flux.zip -d .agents/skills
Documentation by K-Dense Inc.
Carbon-13 metabolic flux inference
Turn reviewed carbon maps, explicit tracer mixtures, and corrected labeling measurements into feasible flux estimates and evidence about which fluxes the experiment constrains. Use the bundled solver rather than reconstructing isotope balances or fitting each reaction independently. It runs mfapy's EMU forward simulator and fits fluxes in the mass-balanced feasible space with SciPy. It does not use an FBA objective.
Scope and required evidence
This implementation supports metabolic and isotopic steady state, a single shared flux state across one or more tracer experiments, nonnegative one-way reaction fluxes, and carbon-subset mass distributions. Reversible reactions are two separately mapped directions. Measurement error is Gaussian with a supplied covariance or a disclosed diagonal approximation.
Before fitting, obtain:
The carbon network and the source of each atom assignment. Stoichiometry alone does not specify where labeled atoms go. Record compartments as separate metabolite IDs.
Evidence for both steady-state assumptions. Stable metabolite abundance does not establish isotopic steady state. Time-course labeling requires INST-MFA with pool sizes and initial labeling; do not average it into this solver.
Every carbon input's positional isotopomer distribution, including unlabeled supplements, bicarbonate/CO2 when assimilated, and tracer impurity.
Fragment carbon assignments, natural-abundance correction history, and uncertainty of the reported mean. Raw peak intensities, derivatized spectra, and MS/MS transitions require validated preprocessing before these inputs can be constructed.
Flux units, extracellular rate measurements or a stated relative-flux reference, and biologically justified bounds. Label fractions alone cannot set an absolute rate.
If necessary information is missing, name it and prepare the input template; do not invent a fragment assignment, atom map, isotope correction, or measurement error. Read references/input-contract.md when preparing inputs. Read references/inference.md before interpreting an actual fit.
Install the tested engine
Run in the user's analysis directory. Set SKILL_DIR to this skill's installed directory,
using the actual resolved path. Keep environments and generated results outside the skill.
uv venv --python 3.12 .venv-mfa
uv pip install --python .venv-mfa/bin/python -r "$SKILL_DIR/assets/requirements.txt"The following commands use .venv-mfa/bin/python; on Windows use the environment's
Scripts/python.exe. mfapy is installed from an immutable Git revision because it is
not distributed on PyPI. Installation executes dependency build code; model inputs
are data, not user-supplied Python. The adapter restricts identifiers and atom-map
syntax before they reach mfapy's internally generated numerical functions.
The pinned commit matched upstream master on 2026-09-30. Its README labels the
latest change "064", but its installed distribution still reports 0.6.3; retain
the Git commit alongside the package version in an analysis record. The refreshed
NumPy/SciPy pins require Python 3.12 or later; the commands above use the tested 3.12
environment. See the reviewed forward-model contract in
references/inference.md.
Workflow
Prepare explicit inputs. Copy a relevant model asset into the analysis directory, then replace its scientific content only from reviewed evidence. The bundled models are demonstrations, not validated organism-specific reconstructions. Use a separate dataset for each biological condition; jointly fit tracer replicates only when their biological flux state is defensibly shared.
Check the contract and feasibility.
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" check \ --model model.json --data measurements.json --output input-check.jsonThis checks atom counts and conservation, fragments, tracer sums, uncertainty matrices, bounds, and steady-state mass-balance feasibility. It cannot verify that a chemically consistent atom map is biologically correct or that a sample reached steady state.
Exercise the forward model. Supply one mass-balanced flux vector in the declared units. Compare predicted labeling with a reference or independently derived limits.
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" simulate \ --model model.json --data measurements.json --fluxes fluxes.json \ --output simulated-mdvs.jsonFit and profile the fluxes relevant to the question.
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" fit \ --model model.json --data measurements.json --starts 12 --seed 2026 \ --profile v3 --profile v7 --profile-points 31 --profile-starts 6 \ --output fit.jsonReplace
v3andv7with actual reaction IDs. Each profile point fixes that reaction and reoptimizes nuisance fluxes. For nonlinear networks, repeat with a different seed and more starts before interpreting a profile. A small residual is not an identifiability result.Inspect the evidence. Check failed starts, residual patterns, mass balance, active bounds, local sensitivity rank, and profile status. Report threshold-crossing brackets at their actual grid resolution. Refine the grid if they are too coarse. Each requested profile gives a one-flux interval under the stated error model; multiple 95% profiles are not a simultaneous 95% region for the whole network. If a profile finds a better solution than the baseline, rerun the fit; do not publish the stale intervals. A failed profile point is unknown, not excluded by the data.
Deliver a bounded scientific result. Include model and data hashes, package versions, source/correction provenance, units and reference flux, fitted predictions, residual diagnostics, profile plots or a table, and the unresolved flux combinations. Retain the JSON artifact. Separate point estimates supported by the data from arbitrary optimizer choices along a flat direction. Suggest additional measurements only after testing that their predicted labeling changes along that direction.
Worked examples
These executable examples use synthetic, tracer-only data. There is no hidden natural- abundance correction, and the tracer proportions already include unlabeled material.
Recover a pathway split; then remove the informative measurement
The analytical two-route model sends a two-carbon substrate through either a carbon-preserving or a carbon-swapping route. Uptake is fixed to 100. An 80% carbon-1 labeled feed and a carbon-1 fragment with M+1 = 0.56 determine the preserving route as 70 and the swapping route as 30.
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" fit \
--model "$SKILL_DIR/assets/branch-model.json" \
--data "$SKILL_DIR/assets/branch-identifiable.json" \
--profile straight --profile-points 41 --output branch-fit.json
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" fit \
--model "$SKILL_DIR/assets/branch-model.json" \
--data "$SKILL_DIR/assets/branch-unresolved.json" \
--profile straight --output unresolved-fit.jsonThe first fit recovers approximately 70/30. Under its declared Gaussian error model,
the analytical 95% interval for straight is about 67.55–72.45; the script reports
grid brackets enclosing the threshold crossings. The second fit has only the whole-
molecule distribution, which is identical for the two routes. Expect local rank zero
and unresolved_within_bounds; its returned split is an arbitrary optimum.
assets/branch-fluxes.json supplies the 70/30 forward-simulation vector.
Reproduce a published cyclic-network calculation
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" simulate \
--model "$SKILL_DIR/assets/tca-model.json" \
--data "$SKILL_DIR/assets/tca-tracer.json" \
--fluxes "$SKILL_DIR/assets/tca-fluxes.json" --output tca-simulation.json
.venv-mfa/bin/python "$SKILL_DIR/scripts/mfa.py" fit \
--model "$SKILL_DIR/assets/tca-model.json" \
--data "$SKILL_DIR/assets/tca-reference-mdv.json" \
--profile v3 --profile v7 --output tca-fit.jsonThe first command reproduces the published rounded glutamate MDV
[0.3464, 0.2695, 0.2708, 0.0807, 0.0286, 0.0039].
The second uses synthetic reference measurements to recover the glutamate branch
flux near 50, while recognizing that this labeling does not resolve the
fumarate/oxaloacetate exchange. A constraint-induced upper edge is not evidence of
a measurement-determined exchange interval.
Interpretation boundaries
A positional isotopomer string runs carbon 1 to carbon N from left to right.
"100000"means carbon-1 labeled glucose. A mass distribution alone cannot specify that positional mixture. The adapter handles mfapy's reversed integer-bit ordering.Natural-abundance correction and tracer-purity correction are different operations. Inputs must be in the documented tracer-only basis, with tracer impurity represented consistently in source mixtures. Do not correct the same contribution twice.
An N-carbon mass distribution has at most N independent components because it sums to one. The tool removes one bin and uses the reduced covariance. Retain cross-bin correlations when available. Diagonal SEM fits are explicitly approximate.
The
symmetricflag means equal averaging of identity and complete carbon-order reversal, as in the bundled fumarate/succinate map. It is not arbitrary molecular symmetry. Other permutations need an explicitly supported model representation.Unsupported in this CLI: nonstationary MFA, isotope effects on reaction rates, unmodeled pools or compartments, MS/MS joint distributions, multi-element isotope correction, fractional carbon stoichiometry/pseudo-reactions, and organism-scale performance guarantees. For these, use a validated specialized model/engine and retain the same input/provenance and identifiability discipline.
Implementation and validation
scripts/mfa.py is the CLI. scripts/_mfa_model.py validates inputs and adapts them to
the mfapy EMU simulator; scripts/_mfa_fit.py handles feasible flux coordinates,
multistart optimization, diagnostic rank, and profile calculations.
The engine is pinned in assets/requirements.txt.
The repository suite at tests/13c-metabolic-flux/ checks the published reference,
analytical split recovery and likelihood profiles, unresolved routes and exchange,
omitted-bin invariance with correlated errors, parallel tracers, absolute-rate
anchoring, repeated-substrate condensation, symmetry, invalid maps, and CLI behavior.
These checks establish the tested numerical behavior, not biological validation of a
user's model or a measured advantage over any particular language model.
Sources
mfapy source at the tested revision, version 0.6.3; API documentation.
Matsuda et al. (2021), mfapy: An open-source Python package for 13C-based metabolic flux analysis.
Antoniewicz, Kelleher, and Stephanopoulos (2007), Elementary metabolite units (EMU): A novel framework for modeling isotopic distributions.
The TCA network is adapted from mfapy's MIT-licensed example files; the attribution and full notice are in assets/mfapy-license.txt.
Files
- ATTRIBUTION.mdAdded by AutoGineer940 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md12.4 KiB
- assets/branch-fluxes.json69 B
- assets/branch-identifiable.json823 B
- assets/branch-model.json2.1 KiB
- assets/branch-unresolved.json978 B
- assets/mfapy-license.txt1.0 KiB
- assets/requirements.txt136 B
- assets/tca-fluxes.json114 B
- assets/tca-model.json4.1 KiB
- assets/tca-reference-mdv.json2.4 KiB
- assets/tca-tracer.json570 B
- references/inference.md9.9 KiB
- references/input-contract.md8.0 KiB
- scripts/_mfa_fit.pyScript13.3 KiB
- scripts/_mfa_model.pyScript20.5 KiB
- scripts/mfa.pyScript4.3 KiB
references/inference.md
Inference and interpretation
What is fitted
The adapter constructs internal carbon-pool balances S v = 0 and exact reference constraints. Linear programming checks feasibility in normalized flux units and explicitly verifies the returned vector. A null-space basis parameterizes the equalities, while linear inequalities preserve every directional flux bound. Bounds that force a reaction to a single value on a feasible face are promoted to equalities using a tolerance relative to each reaction's own feasible values. Thus a flux profile endpoint can correctly have fewer free dimensions. Optimizer constraints also use normalized units; an unrelated loose bound does not define this tolerance.
mfapy evaluates the steady-state isotope model using elementary metabolite units. The pinned mfapy generator drops EMU rows with absolute turnover <= 0.001. The adapter uniformly rescales positive directional fluxes so the smallest is 1 for forward simulation only. Steady-state isotope distributions are invariant under this rescaling; reported fluxes and measured-rate residuals retain their original units. This avoids unit-dependent disappearance of slowly turning-over pools. Exact zero-throughput pools can still be undefined and are not repaired by rescaling. The fitting code does not use mfapy's built-in optimizer, confidence intervals, or natural-abundance correction. It uses SciPy SLSQP with multiple feasible starts, constructed from convex combinations of linear-programming vertices. This is a local optimization strategy; no global optimum is guaranteed. Seeds control starting-point generation, not bit-identical behavior across numerical libraries or machines.
For each normalized distribution, omit one bin and minimize
RSS = sum_b (prediction_b - mean_b)^T covariance_b^-1 (prediction_b - mean_b)
+ sum_k ((predicted_flux_k - measured_flux_k) / SEM_k)^2The implementation uses a Cholesky solve rather than explicitly inverting covariance. With a consistent full compositional covariance, changing the omitted bin leaves this quadratic form invariant. A diagonal SEM approximation does not have that property. Covariance validation checks row/column sums relative to each row/column's magnitude and positive semidefiniteness after variance scaling, so large-variance bins cannot hide invalid rare-bin uncertainty. MDV normalization error must be negligible relative to the declared measurement error as well as small in absolute terms.
Read the JSON results
fluxes: one best converged feasible point, including arbitrary coordinates along unresolved directions. Preserve the declaredflux_unitand exact reference.rss,predictions: weighted residual sum and observed/predicted distributions. A low residual can reflect an uninformative experiment or an overflexible model.optimizer_starts: success, residual, iterations, and termination message for every start. Failed numerical evaluations are penalized during optimization; a result is accepted only if its final simulation is finite, constraints hold, and the optimizer reports convergence. No converged solution makes the command fail with exit code 2.free_flux_dimensions: affine feasible flux dimension, not parameter count guessed from a reaction list.independent_measurementscounts retained bins and rates.local_sensitivity_rank: numerical rank of the whitened residual Jacobian in normalized feasible coordinates. Finite differences use step 1e-5 and a singular- value cutoff max(1e-4, largest singular value * 1e-6). This is a local diagnostic, not a proof of structural identifiability. Poor scaling, bounds, near-zero pools, and strongly nonlinear behavior can affect it. A null value means feasible perturbations could not be evaluated.weak_flux_directions: relative reaction changes along locally insensitive directions, normalized to maximum absolute component 1. These are local directions, not permissible finite flux changes without another feasibility check.active_bounds: estimated reactions at imposed bounds, excluding declared fixed reactions. Inspect why the bound is active before making a biological claim.goodness_of_fit: approximate chi-square tail probability only when local rank is full, residual degrees of freedom are positive, and no nonfixed bound is active. Known Gaussian covariance, an adequate observation model, interior parameters, and asymptotic regularity are assumptions. Estimated SEMs, low counts, inequality boundaries, or nonlinearity can invalidate this approximation. A high p-value is not evidence that a biological mechanism is true.
Flux profiles
Every requested reaction is fixed at each grid value across its feasible range; all nuisance fluxes are refitted. The grid includes the best fitted reaction value. Acceptance uses RSS(profile) - RSS(best) <= chi-square(confidence, 1). This is an asymptotic likelihood-ratio approximation for the declared Gaussian observation model, not a universal MFA confidence formula. Profiles of parameter combinations or exact finite-sample coverage require a different analysis.
| Status | Meaning and next action |
|---|---|
threshold_crossings_bracketed | Grid points bracket threshold crossings. Report the brackets; increase resolution and repeat starts if precise limits matter. Inspect all crossings because disconnected accepted regions are possible. |
bound_limited | At least one feasible-range edge remains accepted. Report that edge as constraint-limited, not measurement-determined. |
unresolved_within_bounds | All sampled points across the feasible range remain accepted. Do not report the arbitrary optimum as an identified pathway rate. This finite grid is not a global structural proof. |
incomplete_profile | At least one point failed. Missing points are unknown. Improve starts, numerical conditioning, or model specification before interpreting limits. |
baseline_not_optimal_refit_required | A profile found a materially smaller RSS. Refit the baseline before using any confidence claim. |
fixed_by_constraints | The reaction is fixed by exact constraints; it has no data-estimated profile interval. |
Even a flat reaction can acquire an apparent bound through coupling to a different
bounded reaction. In the TCA demonstration, increasing v7 also increases v6, and
v6 has an imposed upper bound. This can create an upper profile edge even though
the isotope measurements do not determine exchange. Record such bound sensitivity.
Troubleshooting by evidence
Excellent fit, weak rank or broad profiles: examine tracer position and measured carbon subsets, symmetric pools, reversible exchange, absolute flux scale, compartments, and dilution. Simulate candidate measurements at distinct feasible fluxes along the weak direction. Do not add more measurements of an invariant whole-molecule MDV.
Large structured residuals: examine atom maps, input-label purity, missing carbon sources, fragment assignments, isotope correction, compartment mixing, and steady-state assumptions before increasing error bars or adding free reactions.
Negative corrected fractions or singular covariance: revisit the upstream peak and correction model. Clipping and renormalization change both the mean and its error structure. The CLI intentionally rejects such inputs rather than silently changing them.
Different answers across starts: compare RSS, feasibility and profiles. Increase starts and repeat seeds. Report competing optima when both explain the data.
Singular forward model: look for zero-throughput/unfed pools or mappings outside the supported representation. An isotopic steady-state distribution may be undefined. Do not impose positive flux solely to conceal an inactive pool.
Evidence and applicability
The bundled cyclic-network calculation reproduces a published EMU numerical reference. The branch experiment has an independently calculable optimum and likelihood profile. The TCA measurement asset uses those simulated reference probabilities and a declared synthetic covariance; it is not an experimental dataset. Tests also verify isotope limits, repeated-substrate condensation, reversed-label conventions, compositional likelihood invariance, and non-identifiability. Larger organism models, unusual symmetry, or new measurement types require independent validation before scientific use.
Reviewed engine contract
Checked against the official mfapy source at
a10433af16682386548b360297e2476152d46ede
on 2026-09-30. The adapter relies on these forward-simulation contracts:
MetabolicModel(reactions, reversible, metabolites, target_fragments)accepts the mapped dictionaries. The adapter supplies no aggregate reversible constraints and usestype="intermediate"carbon subsets, not multi-intermediate GC-MS fragments.generate_carbon_source_template()returns a carbon-source object initialized as unlabeled. The adapter explicitly replaces every source distribution withset_all_isotopomers(name, values, correction="no")and checks its boolean result. The source implementation confirms that carbon 1 is the least-significant bit.generate_mdv(state, carbon_sources)withouttimepointevaluates steady state and returnsMdvData;get_fragment_mdv(fragment)returns bins in increasing mass order. No natural-abundance addition is enabled by this adapter.
The current SciPy SLSQP and HiGHS linear-programming contracts retain the bound/linear-constraint and feasibility options used here. The numerical suite and documented synthetic examples were rerun with Python 3.12, NumPy 2.5.3, SciPy 1.18.1, NLopt 2.11.0, and the pinned mfapy commit. This validates the bundled adapter's supported scope, not every upstream mfapy feature.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
The author says: 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.
Security
What our scanner noticed· Low risk
- Instructions that use the network
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- K-Dense Inc.
- Publisher
- K-Dense (Community)
- Source
- K-Dense-AI/scientific-agent-skills · skills/13c-metabolic-flux · commit a25cf9e
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by K-Dense Inc. or K-Dense.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download 13c-metabolic-flux.zip