{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = \"1\";\n", "\n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force !== \"\") {\n", " window._bokeh_onload_callbacks = [];\n", " window._bokeh_is_loading = undefined;\n", " }\n", "\n", "\n", " \n", " if (typeof (window._bokeh_timeout) === \"undefined\" || force !== \"\") {\n", " window._bokeh_timeout = Date.now() + 5000;\n", " window._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"
\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"
\\n\"+\n", " \"\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"
\\n\"+\n",
" \"\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"
\\n\"+\n", " \"\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"
\\n\"+\n",
" \"inspyred
library, we implemented a low level interface to allow the implementation of more elaborate strategies than OptGene."
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"#### Load model\n",
"The first step is to load a model as usual."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"from cameo import models\n",
"iJO1366 = models.bigg.iJO1366"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"## Define objective functions\n",
"\n",
"An objective function defines how the fitness of a solution is computed in the evaluation phase.\n",
"\n",
"Cameo comes with prebuilt objective functions, e.g., Biomass-Product coupled yield[1]."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"data": {
"text/latex": [
"$$bpcy = \\frac{(BIOMASS\\_Ec\\_iJO1366\\_core\\_53p95M * EX\\_ac\\_e)}{EX\\_glc\\_\\_D\\_e}$$"
],
"text/plain": [
" of(model, flux_distribution, decoded_solution)
."
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"## Search for gene knockouts with single objective"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"In this example, we are looking for gene knockouts leading to biomass coupled acetate production with *E. coli* through iJO1366 model. This is very similar to OptGene."
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"#### Setup optimization strategy for gene knockouts\n",
"\n",
"There are multiple configurations for this strategy. The most basic configuration requires a model and an objective funtion. More parameters can be used, such as the method to simulate the flux distributions (FBA is the defualt), the Evolutionary Computation (Genetic Algorithm inspyred.ec.GA
is the default). The implemetation removes the essential genes from the search, as they won't yield soutions that are viable. More genes can be removed from the search if defined (either due to biological knowlege or user strategy)."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"from cameo.strain_design.heuristic.evolutionary import GeneKnockoutOptimization\n",
"ko = GeneKnockoutOptimization(model=iJO1366, objective_function=of)"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"#### Run optimization for gene knockouts with single objective"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true,
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Starting optimization at Thu, 14 Jan 2016 13:49:55\n"
]
},
{
"data": {
"text/html": [
" \n",
"\n",
"\n",
" \n",
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using saved session configuration for http://localhost:5006/\n",
"To override, pass 'load_from_config=False' to Session\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/joao/.virtualenvs/cameo-py3/lib/python3.4/site-packages/bokeh/session.py:318 \u001b[1;31mUserWarning\u001b[0m: You need to start the bokeh-server to see this example.\n"
]
},
{
"data": {
"text/html": [
" \n",
"\n",
"\n",
" \n",
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" 0%"
],
"text/plain": [
"