{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# This notebook shows how to study noise with MuMoT\n", "There are 7 examples worked through below." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import mumot\n", "\n", "mumot.__version__\n", "mumot.about()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Production and decay of protein $P$ and its dimerization into $P_2$ ($P_2$ is called $Q$ below)\n", "### (see F. Hayot & C. Jayaprakash (2004), Physical Biology 1, pp. 205-210)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model1 = mumot.parseModel(r\"\"\"\n", "\\emptyset -> P : k_3\n", "P -> \\emptyset : k\n", "P + P -> Q + \\emptyset : k_1\n", "Q + \\emptyset -> P + P : k_2\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model1.showODEs(method='vanKampen')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol1 = model1.integrate(['Q', 'P'], legend_loc='center right')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol1.showLogs(tail=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bookmark_evol1 = model1.integrate(showStateVars=['P', 'Q'], initialState = {'P': 1.0, 'Q': 0.0}, \n", " maxTime = 3.0, plotProportions = False, \n", " params = [('k_{3}', 2.0), ('k_{2}', 2.0), ('k', 2.0), ('k_{1}', 2.0), \n", " ('plotLimits', 1), ('systemSize', 10.0)], \n", " legend_loc = 'center right', bookmark = False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr1 = model1.noiseCorrelations(maxTime=120, legend_loc='upper right', legend_fontsize=10)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr1.showLogs(tail=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model1.noiseCorrelations()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bookmark_ncorr1 = model1.noiseCorrelations(initialState = {'P': 1.0, 'Q': 0.0}, params = [('k_{3}', 2.0), ('k_{2}', 2.0), ('k', 2.0), ('k_{1}', 2.0), ('plotLimits', 1), ('systemSize', 10.0)], legend_loc = 'upper right', legend_fontsize = 10, maxTime = 120, bookmark = False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model1.showFokkerPlanckEquation()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model1.showNoiseEquations()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model1.showNoiseSolutions()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stream1 = model1.stream('P', 'Q', showFixedPoints=True, showNoise = True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stream1.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bookmark_stream1 = model1.stream('P', 'Q', params = [('k_{3}', 2.0), ('k_{2}', 2.0), ('k', 2.0), ('k_{1}', 2.0), ('plotLimits', 1.5), ('systemSize', 10.0)], showFixedPoints = True, showNoise = True, bookmark = False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The 'Brusselator' reaction mechanism (proposed by Prigogene and Lefever in 1968)\n", "### (see J.D. Murray (1991), Mathematical Biology, p. 175)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model2 = mumot.parseModel(r\"\"\"\n", "(\\alpha) -> X : \\gamma\n", "X + X + Y -> X + X + X : \\chi\n", "(\\beta) + X -> Y + \\emptyset : \\delta\n", "X -> \\emptyset : \\xi\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol2 = model2.integrate(legend_loc='lower right')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol2.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol2b = model2.integrate(['X'], maxTime=50, legend_loc='lower right')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr2 = model2.noiseCorrelations(maxTime=20, legend_loc='upper right', legend_fontsize=14)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr2.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model2.showFokkerPlanckEquation()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model2.showNoiseEquations()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model2.showNoiseSolutions()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stream2 = model2.stream('X', 'Y', showNoise=True, showFixedPoints=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stream2.showLogs()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Textbook example for multivariate master equation \n", "### (see N. van Kampen (1981), Stochastic processes in physics and chemistry, pp. 273-277)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model3 = mumot.parseModel(r\"\"\"\n", "(A) -> X : \\alpha\n", "X + X -> Y + \\emptyset : \\gamma\n", "Y -> (B) : \\beta\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model3.showODEs(method='vanKampen')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol3 = model3.integrate(legend_loc='center right')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol3.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr3 = model3.noiseCorrelations(maxTime=20, legend_loc='upper right', legend_fontsize=12)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr3.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model3.showFokkerPlanckEquation()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model3.showNoiseEquations()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model3.showNoiseSolutions()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stream3 = model3.stream('X', 'Y', showNoise=True, showFixedPoints=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stream3.showLogs()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pitchfork bifurcation: a prototypical example " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model4 = mumot.parseModel(r\"\"\"\n", "\\emptyset + X -> X + X : \\mu\n", "X + X + X -> X + X + \\emptyset : \\alpha\n", "Y -> \\emptyset : \\beta\n", "(A) -> Y : \\kappa\n", "X -> \\emptyset : \\gamma\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model4.showODEs(method='vanKampen')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol4 = model4.integrate(['X', 'Y'], legend_loc='center right')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol4.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr4 = model4.noiseCorrelations(maxTime=20, legend_loc='upper right', legend_fontsize=12)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr4.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model4.showFokkerPlanckEquation()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model4.showNoiseEquations()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model4.showNoiseSolutions()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stream4 = model4.stream('X', 'Y', showNoise=True, showFixedPoints=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stream4.showLogs()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Time evolution of stop-signal model" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model5 = mumot.parseModel(r\"\"\"\n", "U -> A : g_A\n", "U -> B : g_B\n", "A -> U : a_A\n", "B -> U : a_B\n", "A + U -> A + A : r_A\n", "B + U -> B + B : r_B\n", "A + B -> A + U : s\n", "A + B -> B + U : s\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol5 = model5.integrate(['A', 'B', 'U'], maxTime=50, legend_loc='center right', legend_fontsize=13)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol5.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr5 = model5.noiseCorrelations(maxTime=50, legend_loc='upper right', legend_fontsize=12)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr5.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model5.showNoiseEquations()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Stop-signal model with 3 options" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model6 = mumot.parseModel(r\"\"\"\n", "U -> A : g_1\n", "U -> B : g_2\n", "U -> C : g_3\n", "A -> U : a_1\n", "B -> U : a_2\n", "C -> U : a_3\n", "A + U -> A + A : r_1\n", "B + U -> B + B : r_2\n", "C + U -> C + C : r_3\n", "A + B -> A + U : s\n", "A + B -> B + U : s\n", "A + C -> A + U : s\n", "A + C -> C + U : s\n", "B + C -> B + U : s\n", "B + C -> C + U : s\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol6 = model6.integrate(['A', 'B', 'C'], maxTime=50, legend_loc='center right')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol6.showLogs()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Population control of *E. coli* cells\n", "### (see You et al. (2004), Nature 428, pp. 868-871)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model7 = mumot.parseModel(r\"\"\"\n", "A -> E : k_E\n", "\\emptyset + X -> X + X : k\n", "\\emptyset + X -> X + X : v_A\n", "X + X -> X + \\emptyset : k_m\n", "E -> \\emptyset : d_E\n", "X -> A : v_A\n", "A -> \\emptyset : d_A\n", "E + X -> E + \\emptyset : d_N\n", "A + \\emptyset -> A + A : k_E\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model7.showODEs(method='vanKampen')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol7 = model7.integrate(['A', 'E', 'X'], maxTime=50, legend_loc='center right')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evol7.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr7 = model7.noiseCorrelations(maxTimeDS=100, tstep=0.02, maxTime=20, \n", " legend_loc='upper right', legend_fontsize=16)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Ncorr7.showLogs()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model7.showFokkerPlanckEquation()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model7.showNoiseEquations()" ] } ], "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.8" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 1 }