{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Estimating Fluxes at INST state" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To estimate metabolic fluxes at the INST state, FreeFlux uses a nonlinear optimization approach that takes into account both metabolite concentrations and MDVs from multiple timepoints. The problem can be defined mathematically as follows:\n", "\n", "\n", "\n", "Here, ${\\bf{x}}_{sim}$ represents the simulated MDVs at all timepoints, and ${\\bf{v}}_{sim}$ represents the simulated fluxes. Both are functions of the independent variable vector $\\bf{p}$, which includes free fluxes $\\bf{u}$ and concentrations $\\bf{c}$. ${\\bf{x}}_{exp}$ and ${\\bf{v}}_{exp}$ are the measurements of MDV and flux, respectively, and ${\\bf{\\Sigma }}_{{{\\bf{x}}_{exp}}}^{ - 1}$ and ${\\bf{\\Sigma }}_{{{\\bf{v}}_{exp}}}^{ - 1}$ are the inverses of the covariance matrix of measurements. $\\bf{N}$ is the null space of stoichiometric matrix of the network reactions, and $\\bf{T}$ denotes the matrix that transforms total fluxes to net fluxes." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solving both the Fluxes and Concentrations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Similar to before, we start by building a metabolic model by reading the reactions from a [file](https://github.com/Chaowu88/freeflux/tree/main/models/toy)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from freeflux import Model\n", "\n", "MODEL_FILE = 'path/to/reactions.tsv'\n", "\n", "model = Model('demo')\n", "model.read_from_file(MODEL_FILE)\n", "\n", "ifit = model.fitter('inst')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we specify the labeling strategy for the labeled substrates:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ifit.set_labeling_strategy(\n", " 'AcCoA', \n", " labeling_pattern = ['01', '11'], \n", " percentage = [0.25, 0.25], \n", " purity = [1, 1]\n", ") # call this method for each labeled substrate" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The measured metabolite-derived isotopomer fractions (MDVs) and fluxes can be loaded one by one using `set_measured_MDV` and `set_measured_flux`, or all at once from [files](https://github.com/Chaowu88/freeflux/tree/main/models/toy) using `set_measured_MDVs_from_file` and `set_measured_fluxes_from_file`:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "MEASURED_MDV_FILE = 'path/to/measured_inst_MDVs.tsv'\n", "MEASURED_FLUX_FILE = 'path/to/measured_fluxes.tsv'\n", "\n", "ifit.set_measured_MDVs_from_file(MEASURED_MDV_FILE)\n", "ifit.set_measured_fluxes_from_file(MEASURED_FLUX_FILE)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we set the lower and upper bounds for the net fluxes and concentrations using `set_flux_bounds` and `set_concentration_bounds`, respectively:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "ifit.set_flux_bounds('all', bounds = [-100, 100])\n", "ifit.set_concentration_bounds('all', bounds = [0.001, 10])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "