{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MFA data as constraints for a COBRA model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we jump into the (for now) final step in our metabolic flux analysis (MFA) pipeline. After constructing an INCA script, running it in MATLAB and reimporting the data we're now here. This example notebook will guide you through different ways to integrate your MFA results into COBRA models and how to make them more reliable." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Determination of memory status is not supported on this \n", " platform, measuring for memoryleaks will never fail\n" ] } ], "source": [ "import pickle\n", "import pandas as pd\n", "import escher\n", "import cobra\n", "from cobra import Reaction\n", "from tabulate import tabulate\n", "from gurobipy import Model as GRBModel\n", "from BFAIR.mfa.INCA import INCA_reimport\n", "from BFAIR.mfa.sampling import (\n", " add_constraints,\n", " add_feasible_constraints,\n", " find_biomass_reaction,\n", " get_min_solution_val,\n", " replace_biomass_rxn_name,\n", " bound_relaxation,\n", ")\n", "from BFAIR.mfa.visualization import (\n", " reshape_fluxes_escher,\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Preparation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This step is detailed in the `MFA_compatibility` notebook. Please consult it for more detail, we will go through the steps without any explanation here" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "fittedFluxes = pd.read_pickle(\"data/MFA_sampling/preprocessed_fittedFluxes.obj\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Academic license - for non-commercial use only - expires 2021-07-30\n", "Using license file /Users/matmat/gurobi.lic\n" ] } ], "source": [ "model = cobra.io.load_json_model(\"data/MFA_sampling/preprocessed_model.json\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's copy the model so we won't have to go through the pre-processing steps again" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpj84wal8o.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpz4icoou0.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n" ] } ], "source": [ "model_original = model.copy()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Re-integration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let's have a look at our model" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Optimal solution with objective value 0.982
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fluxesreduced_costs
EX_cm_e0.0000000.000000e+00
EX_cmp_e0.000000-2.965572e-01
EX_co2_e19.6752230.000000e+00
EX_cobalt2_e-0.000025-0.000000e+00
DM_4crsol_c0.0002190.000000e+00
.........
PTAr_reverse0.0000000.000000e+00
ACONTb_reverse0.0000000.000000e+00
PGK_reverse0.000000-2.775558e-17
ACKr_reverse0.0000006.938894e-17
ACS_reverse0.0000005.551115e-17
\n", "

2593 rows × 2 columns

\n", "
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "original_solution = model.optimize()\n", "original_solution" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's see what happens now when we add our new bound constraints" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- start ---\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpg8vvow6j.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpu2uzuwjf.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Did not work for EX_co2_e_unlabeled\n", "Did not work for EX_glc_e\n", "Did not work for FADR\n", "Did not work for GluSYN\n", "Did not work for HisSYN\n", "Did not work for IleSYN\n", "Did not work for LeuSYN\n", "Did not work for MetSYN\n", "Did not work for MlthfSYN\n", "Did not work for MlthfSYN_reverse\n", "Did not work for NADH\n", "Did not work for PheSYN\n", "Did not work for ProSYN\n", "Did not work for SerSYN\n", "Did not work for SUCCOAS\n", "Did not work for ThrSYN\n", "Did not work for TKT1a\n", "Did not work for TKT1b\n", "Did not work for TKT2a\n", "Did not work for TKT2b\n", "Did not work for TrpSYN\n", "Did not work for TyrSYN\n", "Did not work for ValSYN\n", "Did not work for CYTBD\n", "Did not work for HYD\n", "Did not work for ATPS4r\n", "add_constraints takes 0h: 0min: 10sec to run\n", "--- end ---\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/matmat/opt/anaconda3/envs/bfair/lib/python3.8/site-packages/cobra/util/solver.py:430: UserWarning: solver status is 'infeasible'\n", " warn(\"solver status is '{}'\".format(status), UserWarning)\n" ] }, { "data": { "text/html": [ "infeasible solution" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model = add_constraints(model, fittedFluxes)\n", "model.optimize()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Oh... That's not good... Well that sucks, seems like we have to deal with an infeasible solution. There are two straight forward ways: exclusion and relaxation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Dealing with infeasible solutions - exclusion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The easier way to deal with this issue is to simply exclude the constraints that render a model infeasible. We can do that by adding the calculated bounds one by one. If we come across a reaction whose bounds cause trouble, we restart the process and skip this one. This might have to be done a few times to exclude all troublemakers. the `add_feasible_constraints()` functions takes care of that for us. Let's reset the model first." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp4a1vc36x.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp21n47dhv.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n" ] } ], "source": [ "model = model_original.copy()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "min_val = get_min_solution_val(fittedFluxes, biomass_string='BIOMASS')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- start ---\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp9p9o82ui.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpw2qb3oh4.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Solution infeasible if adding ASPTA\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp99_809un.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpaxl5yla7.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Solution infeasible if adding DAPDC\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp0p1ss7qp.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpemru1hi4.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Solution infeasible if adding BIOMASS_Ec_iJO1366_core_53p95M\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpq6c6eaas.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpxo7ffcyi.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Did not work for EX_co2_e_unlabeled\n", "Did not work for EX_glc_e\n", "Solution infeasible if adding EX_nh4_e\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp48jx61rv.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpg8545zd2.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Did not work for EX_co2_e_unlabeled\n", "Did not work for EX_glc_e\n", "Solution infeasible if adding EX_o2_e\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmppsuzp_y1.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp9au2uh20.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Did not work for EX_co2_e_unlabeled\n", "Did not work for EX_glc_e\n", "Solution infeasible if adding EX_so4_e\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp7m3xb_ha.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpq_l26let.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Did not work for EX_co2_e_unlabeled\n", "Did not work for EX_glc_e\n", "Did not work for FADR\n", "Solution infeasible if adding GLNS\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpx8osj2na.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmp1tz0jylq.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Did not work for EX_co2_e_unlabeled\n", "Did not work for EX_glc_e\n", "Did not work for FADR\n", "Did not work for GluSYN\n", "Did not work for HisSYN\n", "Did not work for IleSYN\n", "Did not work for LeuSYN\n", "Did not work for MetSYN\n", "Did not work for MlthfSYN\n", "Did not work for MlthfSYN_reverse\n", "Did not work for NADH\n", "Did not work for PheSYN\n", "Did not work for ProSYN\n", "Did not work for SerSYN\n", "Did not work for SUCCOAS\n", "Did not work for ThrSYN\n", "Did not work for TKT1a\n", "Did not work for TKT1b\n", "Did not work for TKT2a\n", "Did not work for TKT2b\n", "Did not work for TrpSYN\n", "Did not work for TyrSYN\n", "Did not work for ValSYN\n", "Did not work for CYTBD\n", "Did not work for HYD\n", "Did not work for ATPS4r\n", "---------------------------\n", "Total number of restarts: 7\n", "add_feasible_constraints takes 0h: 1min: 39sec to run\n", "--- end ---\n" ] } ], "source": [ "model, problems = add_feasible_constraints(model, fittedFluxes, min_val=min_val)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `model` is our newly constrained model and the problematic reactions can be listed in `problems`." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['ASPTA',\n", " 'DAPDC',\n", " 'BIOMASS_Ec_iJO1366_core_53p95M',\n", " 'EX_nh4_e',\n", " 'EX_o2_e',\n", " 'EX_so4_e',\n", " 'GLNS']" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "problems" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let's see what an effect these new bounds had on the predicted growth rate (the objective value) of our model" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Optimal solution with objective value 0.807
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fluxesreduced_costs
EX_cm_e0.0000000.0
EX_cmp_e0.000000-0.0
EX_co2_e15.000000-0.0
EX_cobalt2_e-0.000020-0.0
DM_4crsol_c0.0001800.0
.........
PTAr_reverse0.0000000.0
ACONTb_reverse0.0000000.0
PGK_reverse23.7068100.0
ACKr_reverse4.7839060.0
ACS_reverse0.0000000.0
\n", "

2593 rows × 2 columns

\n", "
" ], "text/plain": [ "" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "new_bounds_solution = model.optimize()\n", "new_bounds_solution" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And here's the star of the show, our sampling method. We trust our models because... we have to! And because smart people that knew what they were doing set them up. So in order to gain more confidence in our MFA data, we sample the model after adding the calculated bound for some of the reactions and re-calculate the fluxes a number of time. Then, we take the mean and take that as the most trustworthy calculated flux. These fluxes can be visualized, for example in tools like `Escher`" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpxzgt2q8z.lp\n", "Reading time = 0.03 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpt_ozl2vr.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n" ] } ], "source": [ "sampled_fluxes = cobra.sampling.sample(model, n=100, processes=2)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
EX_cm_eEX_cmp_eEX_co2_eEX_cobalt2_eDM_4crsol_cDM_5drib_cDM_aacald_cDM_amob_cDM_mththf_cEX_colipa_e...ACONTa_reverseFUM_reverseGAPD_reverseICDHyr_reversePGM_reversePTAr_reverseACONTb_reversePGK_reverseACKr_reverseACS_reverse
00.00.014.651387-2.169991e-081.943322e-070.0112720.01.742395e-090.0001710.000890...2.6701701.0507280.0162311.62712216.66492026.7851112.67002519.4477861.01091127.001166
10.00.014.464957-1.890907e-081.687986e-070.0108880.01.513428e-090.0016660.000545...2.7139581.0625940.0169601.52038516.61196426.6832952.71382319.6194481.11019627.091069
20.00.014.478298-1.882824e-081.680482e-070.0108870.01.506698e-090.0013120.000545...2.6686461.0031820.0173291.45326116.61450726.6486772.66851019.6243691.13660927.066028
30.00.014.458260-1.812741e-081.621550e-070.0108870.01.453843e-090.0119180.000534...2.5111910.7990860.0395861.26070416.62583226.7387892.51105619.5185561.22232927.185154
40.00.014.460898-1.867411e-081.672003e-070.0109340.01.491510e-090.0120930.000532...2.5231710.8076940.0462941.26902716.62513526.7762482.52161619.5185511.19861427.181841
..................................................................
950.00.014.445930-1.365700e-061.253752e-050.0042380.01.124099e-070.0034380.000481...14.69935212.1619941.3402038.88169219.9986426.14987014.68648721.4643829.0802178.795291
960.00.014.518657-1.339059e-061.223887e-050.0042550.01.097314e-070.0035180.000247...14.87965212.5087291.5320879.05814620.0683675.95860114.86655121.4930448.8405468.423002
970.00.014.503939-1.333918e-061.219152e-050.0042340.01.093068e-070.0065850.000204...14.94613012.2465611.5370728.86532020.1411185.56219814.93330521.4566698.8983568.222981
980.00.014.507076-1.377036e-061.259269e-050.0028900.01.129048e-070.0006320.000175...15.31265712.3351021.5842228.66044019.9402115.69020215.33928021.3019919.2502338.631202
990.00.014.530041-1.425529e-061.304998e-050.0029790.01.170060e-070.0004460.000186...15.01590512.0542401.4729658.31257919.9000075.85869915.04243821.2901079.2074678.811348
\n", "

100 rows × 2593 columns

\n", "
" ], "text/plain": [ " EX_cm_e EX_cmp_e EX_co2_e EX_cobalt2_e DM_4crsol_c DM_5drib_c \\\n", "0 0.0 0.0 14.651387 -2.169991e-08 1.943322e-07 0.011272 \n", "1 0.0 0.0 14.464957 -1.890907e-08 1.687986e-07 0.010888 \n", "2 0.0 0.0 14.478298 -1.882824e-08 1.680482e-07 0.010887 \n", "3 0.0 0.0 14.458260 -1.812741e-08 1.621550e-07 0.010887 \n", "4 0.0 0.0 14.460898 -1.867411e-08 1.672003e-07 0.010934 \n", ".. ... ... ... ... ... ... \n", "95 0.0 0.0 14.445930 -1.365700e-06 1.253752e-05 0.004238 \n", "96 0.0 0.0 14.518657 -1.339059e-06 1.223887e-05 0.004255 \n", "97 0.0 0.0 14.503939 -1.333918e-06 1.219152e-05 0.004234 \n", "98 0.0 0.0 14.507076 -1.377036e-06 1.259269e-05 0.002890 \n", "99 0.0 0.0 14.530041 -1.425529e-06 1.304998e-05 0.002979 \n", "\n", " DM_aacald_c DM_amob_c DM_mththf_c EX_colipa_e ... ACONTa_reverse \\\n", "0 0.0 1.742395e-09 0.000171 0.000890 ... 2.670170 \n", "1 0.0 1.513428e-09 0.001666 0.000545 ... 2.713958 \n", "2 0.0 1.506698e-09 0.001312 0.000545 ... 2.668646 \n", "3 0.0 1.453843e-09 0.011918 0.000534 ... 2.511191 \n", "4 0.0 1.491510e-09 0.012093 0.000532 ... 2.523171 \n", ".. ... ... ... ... ... ... \n", "95 0.0 1.124099e-07 0.003438 0.000481 ... 14.699352 \n", "96 0.0 1.097314e-07 0.003518 0.000247 ... 14.879652 \n", "97 0.0 1.093068e-07 0.006585 0.000204 ... 14.946130 \n", "98 0.0 1.129048e-07 0.000632 0.000175 ... 15.312657 \n", "99 0.0 1.170060e-07 0.000446 0.000186 ... 15.015905 \n", "\n", " FUM_reverse GAPD_reverse ICDHyr_reverse PGM_reverse PTAr_reverse \\\n", "0 1.050728 0.016231 1.627122 16.664920 26.785111 \n", "1 1.062594 0.016960 1.520385 16.611964 26.683295 \n", "2 1.003182 0.017329 1.453261 16.614507 26.648677 \n", "3 0.799086 0.039586 1.260704 16.625832 26.738789 \n", "4 0.807694 0.046294 1.269027 16.625135 26.776248 \n", ".. ... ... ... ... ... \n", "95 12.161994 1.340203 8.881692 19.998642 6.149870 \n", "96 12.508729 1.532087 9.058146 20.068367 5.958601 \n", "97 12.246561 1.537072 8.865320 20.141118 5.562198 \n", "98 12.335102 1.584222 8.660440 19.940211 5.690202 \n", "99 12.054240 1.472965 8.312579 19.900007 5.858699 \n", "\n", " ACONTb_reverse PGK_reverse ACKr_reverse ACS_reverse \n", "0 2.670025 19.447786 1.010911 27.001166 \n", "1 2.713823 19.619448 1.110196 27.091069 \n", "2 2.668510 19.624369 1.136609 27.066028 \n", "3 2.511056 19.518556 1.222329 27.185154 \n", "4 2.521616 19.518551 1.198614 27.181841 \n", ".. ... ... ... ... \n", "95 14.686487 21.464382 9.080217 8.795291 \n", "96 14.866551 21.493044 8.840546 8.423002 \n", "97 14.933305 21.456669 8.898356 8.222981 \n", "98 15.339280 21.301991 9.250233 8.631202 \n", "99 15.042438 21.290107 9.207467 8.811348 \n", "\n", "[100 rows x 2593 columns]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sampled_fluxes" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "fluxes_sampling = reshape_fluxes_escher(sampled_fluxes)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", "
\n", "\n", " \n" ], "text/plain": [ "" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sampled_flux_map = escher.Builder('e_coli_core.Core metabolism',\n", " reaction_data = fluxes_sampling).display_in_notebook()\n", "sampled_flux_map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are also other ways to cosolidate the MFA calculations and the constraint based flux predictions. One of these is lMOMA (linear Minimization Of Metabolic Adjustment). MOMA assumes that the fluxes before and after adding the new constraints should be similar, so it aims to predicting an optimum for the newly constrined model while keeping the differences to the original model small. We suggest using pFBA (parsimonious Flux Balance Analysis) instead of regular FBA for this step as pFBA aims to keep the overal fluxes low." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Dealing with infeasible solutions - relaxation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Another way of dealing with infeasible models is to relax the added constraints to the point that it works again. You will need to have the Gurobi solver installed for this. The same principle is used in the `BFAIR thermo` tools. For that we add our constraints to a model that will now be infeasible. Have I meantioned that this is much more elegant, better and that you should do that? It is. The other method is *fine* but you exclude reactions and, in general, it is always better to use as much as possible of the information that is available to you." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmprxly7pup.lp\n", "Reading time = 0.03 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpm40nroxp.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n" ] } ], "source": [ "model = model_original.copy()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- start ---\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpc0e4oi9r.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpdcw8mfmh.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Did not work for 26dap_DASH_MSYN\n", "Did not work for ArgSYN\n", "Did not work for EX_co2_e_unlabeled\n", "Did not work for EX_glc_e\n", "Did not work for FADR\n", "Did not work for GluSYN\n", "Did not work for HisSYN\n", "Did not work for IleSYN\n", "Did not work for LeuSYN\n", "Did not work for MetSYN\n", "Did not work for MlthfSYN\n", "Did not work for MlthfSYN_reverse\n", "Did not work for NADH\n", "Did not work for PheSYN\n", "Did not work for ProSYN\n", "Did not work for SerSYN\n", "Did not work for SUCCOAS\n", "Did not work for ThrSYN\n", "Did not work for TKT1a\n", "Did not work for TKT1b\n", "Did not work for TKT2a\n", "Did not work for TKT2b\n", "Did not work for TrpSYN\n", "Did not work for TyrSYN\n", "Did not work for ValSYN\n", "Did not work for CYTBD\n", "Did not work for HYD\n", "Did not work for ATPS4r\n", "add_constraints takes 0h: 0min: 11sec to run\n", "--- end ---\n" ] } ], "source": [ "model = add_constraints(model, fittedFluxes)" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/matmat/opt/anaconda3/envs/bfair/lib/python3.8/site-packages/cobra/util/solver.py:430: UserWarning: solver status is 'infeasible'\n", " warn(\"solver status is '{}'\".format(status), UserWarning)\n" ] }, { "data": { "text/html": [ "infeasible solution" ], "text/plain": [ "" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.optimize()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then we make use of the handy `bound_relaxation()` function that will test our model to figure out which of these added bounds need to be adjusted and return a DataFrame that describes the affected functions and the gravity of the suggested changes. If we allow this function to be `desctructive` it will adjust the input model right away." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- start ---\n", "bound_relaxation takes 0h: 0min: 0sec to run\n", "--- end ---\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
lb_changeub_changesubsystem
reaction
EX_o2_e-16.6105050.000000Extracellular exchange
ASPTA-3.8650620.000000Alanine and Aspartate Metabolism
GLNS0.0000000.767431Glutamate Metabolism
EX_nh4_e_reverse_f9cc60.00000012.360577Extracellular exchange
EX_so4_e_reverse_5c8ed0.0000000.376547Extracellular exchange
DAPDC_reverse_d3ab8-0.0402130.000000Threonine and Lysine Metabolism
\n", "
" ], "text/plain": [ " lb_change ub_change subsystem\n", "reaction \n", "EX_o2_e -16.610505 0.000000 Extracellular exchange\n", "ASPTA -3.865062 0.000000 Alanine and Aspartate Metabolism\n", "GLNS 0.000000 0.767431 Glutamate Metabolism\n", "EX_nh4_e_reverse_f9cc6 0.000000 12.360577 Extracellular exchange\n", "EX_so4_e_reverse_5c8ed 0.000000 0.376547 Extracellular exchange\n", "DAPDC_reverse_d3ab8 -0.040213 0.000000 Threonine and Lysine Metabolism" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cons_table = bound_relaxation(model, fittedFluxes, destructive=True, fluxes_to_ignore=['BIOMASS_Ec_iJO1366_core_53p95M'])\n", "cons_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's see if our model is feasible now." ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Optimal solution with objective value 0.700
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fluxesreduced_costs
EX_cm_e0.0000000.0
EX_cmp_e0.000000-0.0
EX_co2_e14.6982320.0
EX_cobalt2_e-0.000017-0.0
DM_4crsol_c0.0001560.0
.........
PTAr_reverse0.0000000.0
ACONTb_reverse0.0000000.0
PGK_reverse23.0330300.0
ACKr_reverse4.8657070.0
ACS_reverse0.0000000.0
\n", "

2593 rows × 2 columns

\n", "
" ], "text/plain": [ "" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "relaxed_solution = model.optimize()\n", "relaxed_solution" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.7" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "relaxed_solution.fluxes[\"BIOMASS_Ec_iJO1366_core_53p95M\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And here's the star of the show, our sampling method. We trust our models because... we have to! And because smart people that knew what they were doing set them up. So in order to gain more confidence in our MFA data, we sample the model after adding the calculated bound for some of the reactions and re-calculate the fluxes a number of time. Then, we take the mean and take that as the most trustworthy calculated flux. These fluxes can be visualized, for example in tools like `Escher`.\n", "So here is the point where we can let the power of constraint based models work for us and make use of the tools mentioned above in order to adjust the fluxes calculated using MFA so that they nicely fit into our model." ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmpfjca0h7c.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n", "Read LP format model from file /var/folders/mb/7cs2dcbn369_w97fqkfx47brjcxl49/T/tmprv60cd5x.lp\n", "Reading time = 0.02 seconds\n", ": 1805 rows, 5186 columns, 20446 nonzeros\n" ] } ], "source": [ "relaxed_sampled_fluxes = cobra.sampling.sample(model, n=100, processes=2)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "relaxed_fluxes_sampling = reshape_fluxes_escher(relaxed_sampled_fluxes)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", "
\n", "\n", " \n" ], "text/plain": [ "" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "relaxed_flux_map = escher.Builder('e_coli_core.Core metabolism',\n", " reaction_data = relaxed_fluxes_sampling).display_in_notebook()\n", "relaxed_flux_map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And let's have a quick look at the model itself" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

Objective

1.0 BIOMASS_Ec_iJO1366_core_53p95M = 0.7

Uptake

\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
MetaboliteReactionFluxC-NumberC-Flux
ca2_eEX_ca2_e0.00364400.00%
cl_eEX_cl_e0.00364400.00%
cobalt2_eEX_cobalt2_e1.75E-0500.00%
cu2_eEX_cu2_e0.000496300.00%
fe2_eEX_fe2_e0.00577700.00%
fe3_eEX_fe3_e0.00546600.00%
glc__D_eEX_glc__D_e106100.00%
k_eEX_k_e0.136600.00%
mg2_eEX_mg2_e0.00607200.00%
mn2_eEX_mn2_e0.000483700.00%
mobd_eEX_mobd_e9.03E-0500.00%
nh4_eEX_nh4_e7.56100.00%
ni2_eEX_ni2_e0.000226100.00%
o2_eEX_o2_e8.81100.00%
pi_eEX_pi_e0.675200.00%
so4_eEX_so4_e0.176500.00%
zn2_eEX_zn2_e0.000238700.00%

Secretion

\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
MetaboliteReactionFluxC-NumberC-Flux
4crsol_cDM_4crsol_c-0.000156170.00%
5drib_cDM_5drib_c-0.000157550.00%
amob_cDM_amob_c-1.4E-06150.00%
mththf_cDM_mththf_c-0.000313650.01%
ac_eEX_ac_e-2.3214.71%
co2_eEX_co2_e-12.7140.61%
etoh_eEX_etoh_e-2.393215.30%
h2o_eEX_h2o_e-28.7900.00%
h_eEX_h_e-11.800.00%
lac__D_eEX_lac__D_e-3.061329.37%
meoh_eEX_meoh_e-1.4E-0610.00%
" ], "text/plain": [ "" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.summary()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Alternatives" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are also other ways to cosolidate the MFA calculations and the constraint based flux predictions. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### MOMA" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One of these is lMOMA (linear Minimization Of Metabolic Adjustment). MOMA assumes that the fluxes before and after adding the new constraints should be similar, so it aims to predicting an optimum for the newly constrined model while keeping the differences to the original model small. We suggest using pFBA (parsimonious Flux Balance Analysis) instead of regular FBA for this step as pFBA aims to keep the overal fluxes low." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "From [Volkova, 2020](https://www.mdpi.com/2218-1989/10/8/303/htm):\n", "\n", "\"While FBA with the objective of maximizing growth results in reasonable solutions for wild-type cells, it does not so for (unevolved) gene knockout mutants. While in principle wild-type cells optimize their growth, unevolved cells with knockouts do not. Since homeostasis governs metabolic reprogramming, we cannot assume that the cell will follow a common objective, such as maximizing its growth. To acknowledge the requirement for metabolic homeostasis, the minimization of metabolic adjustment (MOMA) approach was proposed. The main idea behind this method is that, to maintain homeostasis, the difference in fluxes before and after the perturbation should be minimal. MOMA predicts the fluxes of a knockout strain by assuming that the cell will have a minimal redistribution of fluxes compared to its ancestor.\"\n", "We're using pFBA istead of FBA because, on top of optimizing the growth rate, it also minimizes the total sum of fluxes." ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "pfba_relaxed_solution = cobra.flux_analysis.pfba(model)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "moma_after_relaxed_MFA = cobra.flux_analysis.moma(\n", " model=model, solution=pfba_relaxed_solution, linear=True)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.7" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "moma_after_relaxed_MFA.fluxes[\"BIOMASS_Ec_iJO1366_core_53p95M\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### ROOM" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "From [Volkova, 2020](https://www.mdpi.com/2218-1989/10/8/303/htm):\n", "\n", "Another similar approach is the regulatory on/off minimization (ROOM), which minimizes the number of fluxes that are significantly different from the wild type. Wild-type fluxes, determined by FBA or other methods, need to be known in order to use these approaches. " ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "room_after_relaxed_MFA = cobra.flux_analysis.room(\n", " model=model, solution=pfba_relaxed_solution, linear=True, delta=0.03, epsilon=0.001)" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.7" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "room_after_relaxed_MFA.fluxes[\"BIOMASS_Ec_iJO1366_core_53p95M\"]" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Method Biomass function\n", "------------------------------ ------------------\n", "Before adding new constraints: 0.98\n", "New constraints relaxed FBA: 0.7\n", "New constraints relaxed pFBA: 0.7\n", "New constraints relaxed MOMA: 0.7\n", "New constraints relaxed ROOM: 0.7\n" ] } ], "source": [ "from tabulate import tabulate\n", "results = [['Before adding new constraints:', round(original_solution.objective_value, 2)],\n", " ['New constraints relaxed FBA:', round(relaxed_solution.objective_value, 2)],\n", " ['New constraints relaxed pFBA:', round(pfba_relaxed_solution.fluxes[\"BIOMASS_Ec_iJO1366_core_53p95M\"], 2)],\n", " ['New constraints relaxed MOMA:', round(moma_after_relaxed_MFA.fluxes[\"BIOMASS_Ec_iJO1366_core_53p95M\"], 2)],\n", " ['New constraints relaxed ROOM:', round(room_after_relaxed_MFA.fluxes[\"BIOMASS_Ec_iJO1366_core_53p95M\"], 2)]]\n", "print(tabulate(results, headers=[\"Method\", \"Biomass function\"]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Of course also the MOMA results can be visualized with `Escher`. The `reshape_fluxes_escher()` can take both pandas DataFrames or cobra solutions as an input." ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", "
\n", "\n", " \n" ], "text/plain": [ "" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fluxes_relaxed_moma = reshape_fluxes_escher(moma_after_relaxed_MFA)\n", "moma_relaxed_flux_map = escher.Builder('e_coli_core.Core metabolism',\n", " reaction_data = fluxes_relaxed_moma).display_in_notebook()\n", "moma_relaxed_flux_map" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", "
\n", "\n", " \n" ], "text/plain": [ "" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fluxes_relaxed_room = reshape_fluxes_escher(room_after_relaxed_MFA)\n", "room_relaxed_flux_map = escher.Builder('e_coli_core.Core metabolism',\n", " reaction_data = fluxes_relaxed_room).display_in_notebook()\n", "room_relaxed_flux_map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "bfair", "language": "python", "name": "bfair" }, "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.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }