{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Consistency testing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For most problems, multiple flux states can achieve the same optimum and thus we try to obtain a consistent network. By this, we mean that there will be mulitple blocked reactions in the network, which gives rise to this inconsistency. To solve this problem, we use algorithms which can detect all the blocked reactions and also give us consistent networks." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us take a toy network, like so:\n", "\n", "\\begin{align}\n", "v_1 &: {} \\rightarrow 2A \\\\\n", "v_2 &: A \\leftrightarrow B \\\\\n", "v_3 &: A \\rightarrow D \\\\\n", "v_4 &: A \\rightarrow C \\\\\n", "v_5 &: C \\rightarrow D \\\\\n", "v_6 &: D \\rightarrow\n", "\\end{align}\n", "\n", "Here, $v_{x}$, where $x \\in \\{1, 2, \\ldots, 6\\}$ represent the flux carried by the reactions as shown above." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import cobra" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "unknown metabolite 'A' created\n", "unknown metabolite 'B' created\n", "unknown metabolite 'D' created\n", "unknown metabolite 'C' created\n" ] } ], "source": [ "test_model = cobra.Model(\"test_model\")\n", "v1 = cobra.Reaction(\"v1\")\n", "v2 = cobra.Reaction(\"v2\")\n", "v3 = cobra.Reaction(\"v3\")\n", "v4 = cobra.Reaction(\"v4\")\n", "v5 = cobra.Reaction(\"v5\")\n", "v6 = cobra.Reaction(\"v6\")\n", "\n", "test_model.add_reactions([v1, v2, v3, v4, v5, v6])\n", "\n", "v1.reaction = \"-> 2 A\"\n", "v2.reaction = \"A <-> B\"\n", "v3.reaction = \"A -> D\"\n", "v4.reaction = \"A -> C\"\n", "v5.reaction = \"C -> D\"\n", "v6.reaction = \"D ->\"\n", "\n", "v1.bounds = (0.0, 3.0)\n", "v2.bounds = (-3.0, 3.0)\n", "v3.bounds = (0.0, 3.0)\n", "v4.bounds = (0.0, 3.0)\n", "v5.bounds = (0.0, 3.0)\n", "v6.bounds = (0.0, 3.0)\n", "\n", "test_model.objective = v6" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using FVA" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The first approach we can follow is to use FVA (Flux Variability Analysis) which among many other applications, is used to detect blocked reactions. The `cobra.flux_analysis.find_blocked_reactions()` function will return a list of all the blocked reactions obtained using FVA." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['v2']" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cobra.flux_analysis.find_blocked_reactions(test_model)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As we see above, we are able to obtain the blocked reaction, which in this case is $v_2$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using FASTCC" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The second approach to obtaining consistent network in `cobrapy` is to use FASTCC. Using this method, you can expect to efficiently obtain an accurate consistent network. For more details regarding the algorithm, please see [Vlassis N, Pacheco MP, Sauter T (2014)](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003424)." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[,\n", " ,\n", " ,\n", " ,\n", " ]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "consistent_model = cobra.flux_analysis.fastcc(test_model)\n", "consistent_model.reactions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Similar to the FVA approach, we are able to identify that $v_2$ is indeed the blocked reaction." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.6.6" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": false, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Table of Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": true } }, "nbformat": 4, "nbformat_minor": 2 }