FHNbacteriaModel.ipynb 7.99 KB
 Munehiro Asally committed Dec 16, 2019 1 2 3 { "cells": [ {  Munehiro Asally committed Dec 04, 2019 4 5 6 7 8 9 10 11 12 13 14 15 16  "cell_type": "markdown", "metadata": {}, "source": [ "# FHN bacteria model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "The model consists of two variables $V_m$ and $W$. Their dynamics are expressed in the following ordinary differential equations.
\n", "\n",  Munehiro Asally committed Dec 04, 2019 17  "\n $\\cfrac{dV_m}{dt} = k_{K}((V_m + V_{m,0}) - \\alpha (V_m + V_{m,0})^3 + W ) + \\cfrac{dI_v}{dt}$\n",  Munehiro Asally committed Dec 04, 2019 18  "\n",  Munehiro Asally committed Dec 04, 2019 19  "\n $\\cfrac{dW}{dt} = (-(V_m + V_{m,0}) +\\beta - W ) + \\cfrac{dI_w}{dt}$\n",  Munehiro Asally committed Dec 04, 2019 20 21 22 23  "\n", "
\n", "where $\\beta$ is defined by:\n", "
\n",  Munehiro Asally committed Dec 04, 2019 24  " $\\beta = 1 - 0.1 \\log{k_K}$\n",  Munehiro Asally committed Dec 04, 2019 25  "
\n",  Munehiro Asally committed Dec 16, 2019 26  "$V_m$ is membrane potential, $W$ is recovery variables. $V_{m,0}$ is the offset in $V_m$. $\\alpha$ is a parameter for $V_m$ dynamics property.
\n",  Munehiro Asally committed Dec 04, 2019 27 28  "$k_K$ corresponds to the degree of $K^+$ concentration gradient across the membrane. This determines the time scale of the dynamics and the resting membrnae potential.\n", "$I_v$, $I_w$ are the strengths of the externally applied electrical field.
\n"  Munehiro Asally committed Dec 04, 2019 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306  ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy.integrate import odeint\n", "import os\n", "import seaborn as sns\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#parameters in the differential equation of w. \n", "#While these parameters were included in the script, \n", "#they are not effective in our simulations as they are multiplificaiton terms set as 1.\n", "a = 1.\n", "b = 1.\n", "c = 1.\n", "\n", "#This parameter correponds to /alpha in the equation. \n", "alpha = 10.\n", "\n", "#This parameter corresponds to k_K in the equation.\n", "k = 10.\n", "\n", "#offset in Vm. Note that this parameter does not affect the dynamics. \n", "vm0 = 1.5\n", "\n", "#time step size\n", "dt = 0.001\n", "\n", "#time scale of the events\n", "tscale = 60.\n", "\n", "#max time to simulate\n", "Tmax = 10.\n", "\n", "tvec = np.arange(0, Tmax, dt)\n", "\n", "\n", "#duration of electrical stimulation\n", "ees_duration = 2.5\n", "\n", "#tvec for electrical stimulaiton\n", "t_ees = np.arange(0,(ees_duration*(Tmax/dt)/(Tmax*tscale))*dt,dt)\n", "\n", "#initial parameter for v and w\n", "vw0 = [-.5,-.5]\n", "\n", "#external stimulation in v and w.\n", "#v is membrane potential and w is recovery variables\n", "Iv = 0.01\n", "Iw = -0.075\n", "I1 = np.array([Iv, Iw])/dt\n", "\n", "#parameter for I when no electrical field is applied\n", "I0 = [0,0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#ODE\n", "def f(vw,t):\n", " v, w = vw\n", " dvdt = k*((v+vm0) - alpha*(v+vm0)**3 + w) +Iv\n", " dwdt = a*(-(v+vm0) + b - c*w) +Iw\n", " return [dvdt, dwdt]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulation for proliferative cells" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#parameter k_K for prolieferative cells\n", "k = 10.\n", "\n", "#calculation of beta \n", "b1 = 1-0.1* np.log(k)\n", "\n", "b = b1\n", "\n", "#simulation without electric field. This is to bring the system to the equlibrium. \n", "Iv, Iw = I0\n", "vwout1p = odeint(f, vw0, tvec)\n", "\n", "#simulation with electric field. \n", "Iv, Iw = I1\n", "vwout1pe = odeint(f, vwout1p[-1,:], t_ees)\n", "\n", "#simulation after removal of electric field.\n", "Iv, Iw = I0\n", "vwout2p = odeint(f, vwout1pe[-1,:], tvec) \n", "\n", "#simulation result combining above.\n", "vwoutp = np.concatenate([vwout1p, vwout1pe, vwout2p])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulation for inhibited cells" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#parameter k_K for inhibited cells\n", "k= .1\n", "b2 = 1- 0.1* np.log(k)\n", "\n", "b = b2\n", "\n", "Iv, Iw = I0\n", "vwout1i = odeint(f, vw0, tvec)\n", "Iv, Iw = I1\n", "vwout1ie = odeint(f, vwout1i[-1,:], t_ees)\n", "Iv,Iw = I0\n", "vwout2i = odeint(f, vwout1ie[-1,:], tvec) \n", "vwouti = np.concatenate([vwout1i, vwout1ie, vwout2i])\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Ploting the simulation results. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#time \n", "time = np.linspace(0, (t_ees.size + 2* tvec.size)*dt*tscale, t_ees.size + 2* tvec.size) - tvec.size*dt*tscale\n", "\n", "#Initial frame for ploting. The system is at the equlibrium (before electrical stimulaiton). \n", "frameq = np.int(tvec.size*0.9)\n", "\n", "#make a figure\n", "fig, ax = plt.subplots(figsize = (5, 4))\n", "\n", "#indicate the electrical stimulation window\n", "plt.fill_between([0,ees_duration],-4, 4, color ='yellow', alpha = 0.4)\n", "\n", "#plot the simulation results\n", "plt.plot( time[frameq:], vwoutp[frameq,0] - vwoutp[frameq:,0],'-', c = 'b', lw = 4, alpha = 0.6)\n", "plt.plot( time[frameq:], vwouti[frameq,0] - vwouti[frameq:,0],'-', c = 'r', lw = 4, alpha = 0.6)\n", "\n", "plt.xticks(np.arange(0,55,10),size = 16)\n", "plt.yticks(np.arange(-0.5,1.2,0.5),size = 16)\n", "\n", "plt.ylim(-0.5,1.3)\n", "plt.xlim(-5, 45)\n", "\n", "plt.ylabel(r'$-\\Delta V_m$', size = 18)\n", "plt.xlabel(r'time (sec)', size = 18)\n", "\n", "sns.despine()\n", "plt.tight_layout()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Plotting the simulation results in $V_m$-$W$ phase space with nullclines" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "v = np.linspace(-3, 0, 100)\n", "\n", "nulc_v = alpha*(v+vm0)**3 - (v +vm0)\n", "nulc_w = (-a*(v+vm0) + a*b1)/(a*c)\n", "\n", "nulc_wi= (-a*(v+vm0) + a*b2)/(a*c)\n", "\n", "fig, ax = plt.subplots(2,1, figsize = (5.3, 8), sharex=True, sharey=True)\n", "\n", "ax1 = ax[0]\n", "ax2 = ax[1]\n", "\n", "ax1.plot(v, nulc_v, '0.3', lw =2, ls = '--')\n", "ax1.plot(v, nulc_w, '0.3', lw =2, ls = '--')\n", "ax1.plot(vwoutp[9000:,0], vwoutp[9000:,1], c = 'b', lw = 3, alpha = 0.5)\n", "\n", "\n", "ax2.plot(v, nulc_v, '0.2', lw =2, ls = '--')\n", "ax2.plot(v, nulc_wi, '0.2', lw =2, ls = '--')\n", "ax2.plot(vwouti[9000:,0], vwouti[9000:,1], c = 'r', lw = 3, alpha = 0.5)\n", "\n", "\n", "plt.xlim(-2.45, -0.2)\n", "plt.ylim(-3,2.1)\n", "\n", "#ax1.set_xlabel(r'$V_m$ (au)', size = 16)\n", "ax2.set_xlabel(r'$V_m$ (au)', size = 16)\n", "ax1.set_ylabel(r'$W$ (au)', size = 16)\n", "ax2.set_ylabel(r'$W$ (au)', size = 16)\n", "\n", "plt.tight_layout()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "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.3" } }, "nbformat": 4, "nbformat_minor": 2 }