{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Hill Activation function\n", "\n", "Examine the Hill activation function. \n", "\n", "The components are\n", "- vmax_z: maximum rate of the reaction (ultimately, this will be the rate of transcription of Z)\n", "- K_xz: the activation threshold for X's activation of the reaction\n", "- n_xz: the Hill coefficient (exponent) for X's activation of the reaction\n", "- X: the amount of X in the system\n", "\n", "The activation function is\n", "\n", "$v_{max} \\frac{x^{n_{xz}}}{K_{xz}^{n_{xz}}+x^{n_{xz}}}$\n", "\n", "Assuming $v_{max}=1$, plot the activation as a function of X (X from 0 to 2 with step of 0.01) for values of $n_{xz}$ ranging from 1 to 10 with a step of 1. Identify on the plot the location of $K_{xz}=0.5$. Also, identify the location on each line where x=1, because we will be using X=1 for activated X in the model simulation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import scipy.integrate" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Write code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Transcription with a single activator\n", "\n", "Implement a model of Z, which is activated by X (a parameter) and that degrades. The model function takes as input the time, state variables, and parameters. It should have one state variable, Z, that is activated by a transcription factor X. In this scenario, X is considered an input. There is no differential equation for X, so we treat it as a parameter.\n", "\n", "The parameters are\n", "- vmax_z: maximum rate of Z's transcription\n", "- K_xz: the activation threshold for X's activation of Z\n", "- n_xz: the Hill coefficient (exponent) for X's activation of Z\n", "- d_z: the degradation rate constant for Z\n", "- X: the amount of X in the system\n", "\n", "The model's activation function is\n", "\n", "$v_{max} \\frac{x^{n_{xz}}}{K_{xz}^{n_{xz}}+x^{n_{xz}}}$\n", "\n", "and $\\frac{dZ}{dt}$ depends on activation and degradation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def single_activator( t, statevars, params ):\n", " # write code here\n", "\n", " dydt = np.zeros( (1,) )\n", " dydt[0] = # Write code here\n", " return dydt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Simulate the model\n", "\n", "Use $v_{max}=1$, $K_{xz}=0.5$, $n_{xz}=5$, and $d_z=2$. X should be 0 until t=0.5, and 1 thereafter. Simulate from t=0 to t=20 with a time steps of 0.01.\n", "\n", "We are going to take extra precautions when we solve this system. We will first simulate the situation before X is on, then start a new simulation with X on. This way, we can guarantee that we have the solution change behaviors at exactly the right time. (The danger is that the solver is so satisfied with the flat solution before X is on, that it takes such big steps that it doesn't notice when X is turned on.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Assign each parameter a name by value\n", "vmax_z = 1;\n", "K_xz = 0.5;\n", "n_xz = 5;\n", "d_z = 2;\n", "\n", "# Set up parameters so that X is off, and then X is on\n", "time_x_on = 0.5\n", "params_off = (vmax_z, K_xz, n_xz, d_z,0);\n", "params_on = (vmax_z, K_xz, n_xz, d_z,1);\n", "\n", "# Make versions of the model with X off and X on\n", "mf_off = lambda t,y : single_activator(t,y, params_off)\n", "mf_on = lambda t,y : single_activator(t,y, params_on)\n", "\n", "# Simulate first with X off, then turn X on.\n", "sol1 = scipy.integrate.solve_ivp( fun=mf_off, t_span=(0,time_x_on), y0=(0,), \n", " t_eval=np.arange(0,time_x_on,.01) )\n", "sol2 = scipy.integrate.solve_ivp( fun=mf_on, t_span=(time_x_on,20), y0=sol1.y[:,-1], \n", " t_eval=np.arange(time_x_on,20,.01) )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot the simulation\n", "Plot X over time in an upper subplot and Z over time in a lower subplot." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "plt.subplot( 2, 1, 1)\n", "plt.plot( [sol1.t[0],time_x_on,time_x_on,sol2.t[-1]], [0,0,1,1] )\n", "plt.ylabel( \"X\")\n", "plt.subplot( 2, 1, 2 )\n", "plt.plot(sol1.t, sol1.y.T); #Simulation before signal on\n", "plt.gca().set_prop_cycle(None) # this resets the color cycle\n", "plt.plot(sol2.t, sol2.y.T); #Simulation after signal on\n", "plt.xlabel( 'Time')\n", "plt.ylabel( \"Z\")\n", "plt.tight_layout()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Simulate and plot the model for varying Hill coefficients\n", "For $n_{xz}$ from 1 to 10 (with step of 1), simulate the model (with all other info as above). Plot all simulation outputs on the same plot, and use a legend to label the value of $n_{xz}$ for each line." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Write code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Hill Repression function\n", "\n", "Examine the Hill repression function. \n", "\n", "The components are\n", "- vmax_z: maximum rate of the reaction (ultimately, this will be the rate of transcription of Z)\n", "- K_xz: the activation threshold for X's activation of the reaction\n", "- n_xz: the Hill coefficient (exponent) for X's activation of the reaction\n", "- X: the amount of X in the system\n", "\n", "The repression function is\n", "\n", "$v_{max} \\frac{K_{xz}^{n_{xz}}}{K_{xz}^{n_{xz}}+x^{n_{xz}}}$\n", "\n", "Assuming $v_{max}=1$, plot the activation as a function of X (X from 0 to 2 with step of 0.01) for values of $n_{xz}$ ranging from 1 to 10 with a step of 1. Identify on the plot the location of $K_{xz}=0.5$. Also, identify the location on each line where x=1, because we will be using X=1 for activated X in the model simulation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Write code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Transcription with a single repressor\n", "\n", "Implement a model of Z, which is repressed by X (a parameter) and that degrades. The model function takes as input the time, state variables, and parameters. It should have one state variable, Z, that is activated by a transcription factor X. In this scenario, X is considered an input. There is no differential equation for X, so we treat it as a parameter.\n", "\n", "The parameters are\n", "- vmax_z: maximum rate of Z's transcription\n", "- K_xz: the activation threshold for X's repression of Z\n", "- n_xz: the Hill coefficient (exponent) for X's repression of Z\n", "- d_z: the degradation rate constant for Z\n", "- X: the amount of X in the system\n", "\n", "The model's activation function is\n", "\n", "$v_{max} \\frac{K_{xz}^{n_{xz}}}{K_{xz}^{n_{xz}}+x^{n_{xz}}}$\n", "\n", "and $\\frac{dZ}{dt}$ depends on transcription (which can be repressed) and degradation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def single_repressor( t, statevars, params ):\n", " # write code here\n", "\n", " dydt = np.zeros( (1,) )\n", " dydt[0] = # Write code here\n", " return dydt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Simulate the model\n", "\n", "Use $v_{max}=1$, $K_{xz}=0.5$, $n_{xz}=5$, and $d_z=2$. X should be 0 until t=0.5, and 1 thereafter. Simulate from t=0 to t=20 with a time steps of 0.01.\n", "\n", "We are going to take extra precautions when we solve this system. We will first simulate the situation before X is on, then start a new simulation with X on. This way, we can guarantee that we have the solution change behaviors at exactly the right time. (The danger is that the solver is so satisfied with the flat solution before X is on, that it takes such big steps that it doesn't notice when X is turned on.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vmax_z = 1;\n", "K_xz = 0.5;\n", "n_xz = 5;\n", "d_z = 2;\n", "\n", "time_x_on = 0.5\n", "params_off = (vmax_z, K_xz, n_xz, d_z,0);\n", "params_on = (vmax_z, K_xz, n_xz, d_z,1);\n", "\n", "mf_off = lambda t,y : single_repressor(t,y, params_off)\n", "mf_on = lambda t,y : single_repressor(t,y, params_on)\n", "\n", "sol1 = scipy.integrate.solve_ivp( fun=mf_off, t_span=(0,time_x_on), y0=(0,), \n", " t_eval=np.arange(0,time_x_on,.01) )\n", "sol2 = scipy.integrate.solve_ivp( fun=mf_on, t_span=(time_x_on,20), y0=sol1.y[:,-1], \n", " t_eval=np.arange(time_x_on,20,.01) )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot the simulation\n", "Plot X over time in an upper subplot and Z over time in a lower subplot." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "# Write code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Simulate and plot the model for varying Hill coefficients\n", "For $n_{xz}$ from 1 to 10 (with step of 1), simulate the model (with all other info as above). Plot all simulation outputs on the same plot, and use a legend to label the value of $n_{xz}$ for each line." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Write code here" ] } ], "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.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }