{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulating MDV at Steady State" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Metabolic flux analysis involves simulating the labeling pattern of metabolites at a defined flux distribution in a given metabolic network. In this tutorial, we will demonstrate how to simulate the labeling pattern of metabolites using FreeFlux. We will use a [toy model](https://github.com/Chaowu88/freeflux/tree/main/models/toy) to illustrate the process." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We start by loading the metabolic model from a tab-separated values (tsv) [file](https://github.com/Chaowu88/freeflux/blob/main/models/toy/reactions.tsv). We then create a Simulator object for steady-state simulation ('ss'). We call the `set_target_EMUs method` to specify the EMUs whose MDVs need to be simulated." ] }, { "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", "sim = model.simulator('ss')\n", "sim.set_target_EMUs({\n", " 'Glu': [[1,2,3], '12345'], # EMU \"Glu_123\" and \"Glu_12345\"\n", " 'AKG': [2,3], # EMU \"AKG_23\"\n", " 'Cit': '12345' # EMU \"Cit_12345\"\n", "}) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we specify the labeling strategy for the metabolic network. In this toy model, the network uptakes 25% (mol%) C2 labeled and 25% fully labeled acetyl-CoA with both 100% purities." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "sim.set_labeling_strategy(\n", " 'AcCoA', \n", " labeling_pattern = ['01', '11'], \n", " percentage = [0.25, 0.25], \n", " purity = [1, 1]\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "Note:

Call this method for each substrate if multiple substrates are used. \n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can input the defined flux distribution using the `set_flux` method or read it from a .tsv or .xslx [file](https://github.com/Chaowu88/freeflux/blob/main/models/toy/fluxes.tsv) using the `set_fluxes_from_file` method." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "fluxes = {'v1': 10,\n", " 'v2': 10,\n", " 'v3': 5,\n", " 'v4': 5,\n", " 'v5': 5,\n", " 'v6_f': 12.5, # \"_f\" denotes forward flux\n", " 'v6_b': 7.5, # \"_b\" denotes backward flux\n", " 'v7': 5}\n", "for fluxid, value in fluxes.items():\n", " sim.set_flux(fluxid, value)\n", " \n", "# or read from file\n", "FLUXES_FILE = 'path/to/fluxes.tsv'\n", "sim.set_fluxes_from_file(FLUXES_FILE)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are now ready to simulate the labeling patterns:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "simulated MDVs\n", "Glu_123: MDV([0.671, 0.21, 0.102, 0.017])\n", "Glu_12345: MDV([0.328, 0.276, 0.274, 0.088, 0.03, 0.004])\n", "AKG_23: MDV([0.693, 0.262, 0.044])\n", "Cit_12345: MDV([0.328, 0.276, 0.274, 0.088, 0.03, 0.004])\n" ] } ], "source": [ "sim.prepare()\n", "res = sim.simulate()\n", "print(res)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `with` statement can also be used to perform the simulation." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "simulated MDVs\n", "Glu_123: MDV([0.671, 0.21, 0.102, 0.017])\n", "Glu_12345: MDV([0.328, 0.276, 0.274, 0.088, 0.03, 0.004])\n", "AKG_23: MDV([0.693, 0.262, 0.044])\n", "Cit_12345: MDV([0.328, 0.276, 0.274, 0.088, 0.03, 0.004])\n" ] } ], "source": [ "with model.simulator('ss') as sim:\n", " sim.set_target_EMUs({\n", " 'Glu': [[1,2,3], '12345'], \n", " 'AKG': [2,3], \n", " 'Cit': '12345'\n", " })\n", " sim.set_labeling_strategy(\n", " 'AcCoA', \n", " labeling_pattern = ['01', '11'], \n", " percentage = [0.25, 0.25], \n", " purity = [1, 1]\n", " )\n", " sim.set_fluxes_from_file(FLUXES_FILE)\n", " sim.prepare()\n", " res = sim.simulate()\n", "print(res)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For a more complex example of steady state simulation using an *E. coli* model, you can refer to the script \"[tutorial_synechocystis_inst_simulation.py](https://github.com/Chaowu88/freeflux/tree/main/tutorials)\"" ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:freeflux-py37]", "language": "python", "name": "conda-env-freeflux-py37-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.0" } }, "nbformat": 4, "nbformat_minor": 4 }