{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# INCAWrapper validation case medium size model\n", "In this notebook, we use the INCAWrapper to fit a simulated data. This notebook serves as an integration test the INCAWrapper that can be run when changes are made to the codebase to ensure that the INCAWrapper performs consistently. Furthermore, this case act as a validation case the show that the INCAWrapper actually works and that it is capable of estimating correct flux distribution from simulated data.\n", "\n", "This notebook is not meant as a tutorial and therefore code description is a bit more sparse. For a proper tutorial see the other examples at https://incawrapper.readthedocs.io/en/latest/examples/index.html.\n", "\n", "The model we use is from Alagesan, S., Minton, N.P. & Malys, N. 13C-assisted metabolic flux analysis to investigate heterotrophic and mixotrophic metabolism in Cupriavidus necator H16. Metabolomics 14, 9 (2018). https://doi.org/10.1007/s11306-017-1302-z, which is also used for one of the tutorials.\n", "\n", "The simulation mimics a two parallel experiment where C. necator is grown with different labelled fructose and labelled glycerol. We simulated MS measurements of the amino acids and a few exchanges fluxes are measured. To increase the information about the systems we simulate measurements of CO2 exchange flux. To do this we added one additional reaction to the original model, i.e. CO2 -> CO2.ext. For more details about the simulation see the [simulation script](https://github.com/biosustain/incawrapper/blob/main/docs/examples/Literature%20data/Cupriavidus%20necator%2520%20Alagesan%202017/c_necator_simulation.py)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import dotenv\n", "import ast\n", "import pandera as pa\n", "import incawrapper\n", "from incawrapper import utils\n", "from incawrapper import visualization\n", "import pathlib\n", "import matplotlib.pyplot as plt\n", "import pytest" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# import environment variables\n", "INCA_base_directory = dotenv.get_key(dotenv.find_dotenv(), \"INCA_base_directory\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# set up path to data\n", "working_dir = pathlib.Path(dotenv.find_dotenv()).parent\n", "data_directory = working_dir / 'docs' / 'examples' / 'Literature data' / 'Cupriavidus necator Alagesan 2017' / 'simulated_data'\n", "results_file = data_directory / 'fit_simulated_fructose.mat'" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Reading the reactions, tracers, and simulated measurements\n", "rxn = pd.read_csv(data_directory / 'reactions_processed.csv')\n", "tracers = pd.read_csv(\n", " data_directory / 'tracer_info.csv', \n", " converters={\"atom_ids\": ast.literal_eval, \"atom_mdv\": ast.literal_eval}\n", ")\n", "flux_measurements = pd.read_csv(data_directory / 'flux_measurements_no_noise.csv')\n", "mdv_measurements = pd.read_csv(\n", " data_directory / 'mdv_no_noise.csv',\n", " converters={\"labelled_atom_ids\": ast.literal_eval}\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Looking at the traces dataframe, we can see the design of the two simulated parallel experiments" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | experiment_id | \n", "met_id | \n", "tracer_id | \n", "atom_ids | \n", "atom_mdv | \n", "enrichment | \n", "
|---|---|---|---|---|---|---|
| 0 | \n", "simulation1 | \n", "FRU.ext | \n", "D-[1-13C]fructose | \n", "[1] | \n", "[0.0, 1.0] | \n", "1 | \n", "
| 1 | \n", "simulation1 | \n", "GLY.ext | \n", "[1,2-13C]glycerol | \n", "[1, 2] | \n", "[0.0, 1.0] | \n", "1 | \n", "
| 2 | \n", "simulation2 | \n", "FRU.ext | \n", "[1,6-13C]fructose | \n", "[1, 6] | \n", "[0.0, 1.0] | \n", "1 | \n", "
| 3 | \n", "simulation2 | \n", "GLY.ext | \n", "[1,2-13C]glycerol | \n", "[1, 2] | \n", "[0.0, 1.0] | \n", "1 | \n", "