\n", "\n", "The course contains material derived from the course [Biological Circuit Design by Michael Elowitz and Justin Bois, 2020 at Caltech](http://be150.caltech.edu/2020/content/index.html).\n", "\n", "The original course material has been changed by [Matthias Fuegger](http://www.lsv.fr/~mfuegger/) and [Thomas Nowak](https://www.thomasnowak.net)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This lecture covers:\n", "\n", "**Concepts**\n", "\n", "- Chemical reaction networks (CRNs) to describe species and reactions among them\n", "- Determinstic ODE kinetics of CRNs\n", "- Stochastic Markov chain kinetics of CRNs\n", "- Their link via the Langevin equation\n", "\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Chemical Reactions Networks\n", "\n", "\n", "A *chemical reaction network* is described by a set $\\mathcal{S}$ of species and a set $\\mathcal{R}$ of reactions.\n", "A *reaction* is a triple $(\\mathbf{r}, \\mathbf{p}, \\alpha)$ where $\\mathbf{r}, \\mathbf{p}\\in \\mathbb{N}_0^{\\mathcal{S}}$ and $\\alpha\\in\\mathbb{R}_{\\geq0}$.\n", "The species with positive count in $\\mathbf{r}$ are called the reaction's *reactants* and those with positive count in $\\mathbf{p}$ are called its *products*.\n", "The parameter $\\alpha$ is called the reaction's *rate constant*." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The dynamical equations\n", "\n", "For simple protein production, we have the following species\n", "* DNA. We assume there is a single promoter followed by a protein-coding gene in the cell\n", "* mRNA, where $m$ is the current number of mRNA corresponding to the above gene\n", "* protein, where $p$ is the current number of proteins corresponding to the above gene\n", "\n", "as well as the following reactions among them:\n", "\\begin{align}\n", "\\text{DNA} &\\rightarrow \\text{mRNA} + \\text{DNA} &\\text{(transcription)}\\\\\n", "\\text{mRNA} &\\rightarrow \\emptyset &\\text{(mRNA degradation and dilution)}\\\\\n", "\\text{mRNA} &\\rightarrow \\text{protein} + \\text{mRNA} &\\text{(translation)}\\\\\n", "\\text{protein} &\\rightarrow \\emptyset &\\text{(protein degradation and dilution)}\n", "\\end{align}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Macroscale equations (deterministic, ODE semantics)\n", "As we've seen before, the deterministic dynamics, which describe mean concentrations over a large population of cells, are described by the ODEs\n", "\n", "\\begin{align}\n", "\\frac{\\mathrm{d}m}{\\mathrm{d}t} &= \\beta_m - \\gamma_m m, \\\\[1em]\n", "\\frac{\\mathrm{d}p}{\\mathrm{d}t} &= \\beta_p m - \\gamma_p p.\n", "\\end{align}\n", "\n", "\n", "In general, the rate of a reaction $(\\mathbf{r}, \\mathbf{p}, \\alpha)$ at time $t$ is $\\alpha \\prod_{s\\in \\mathcal{S}} s(t)^{\\mathbf{r}(s)}$ where $s(t)$ is the concentration of species $s$ at time $t$. The differential equation for a species $s \\in \\mathcal{S}$ is:\n", "$$\n", "\\frac{ds}{dt} = \\sum_{(\\mathbf{r}, \\mathbf{p}, \\alpha) \\in \\mathcal{R}} (\\mathbf{p}(s) - \\mathbf{r}(s)) \\cdot \\alpha \\prod_{\\tilde{s}\\in \\mathcal{S}} \\tilde{s}(t)^{\\mathbf{r}(\\tilde{s})}\n", "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The Chemical Master equation (stochastic, Markov chain semantics)\n", "\n", "We can write a master equation for these dynamics. In this case, each state is defined by an mRNA copy number $m$ and a protein copy number $p$.\n", "States can transition to other states with rates.\n", "We assume that the state fully described the system state.\n", "That is the probability to transition from a state $(m,p)$ to a state $(m',p')$ with in an infinitesimal time $\\Delta t$\n", "is independent if how long our system already is in state $(m,p)$.\n", "It is approximately $\\Delta t \\cdot \\gamma_i(m,p)$, where $\\gamma_i(m,p)$ is the rate at which reaction $i$ happens if in state $(m,p)$.\n", "\n", "The following image shows state transitions and their corresponding reactions for large enough $m$ and $p$.\n", "Care has to be taken at the boundaries, e.g., if $m = 1$ or $m = 0$.\n", "\n", "

\n",
" \n",
"\n",
"\n",
"

\n",
"\n",
"Denote by **$P(m, p, t)$** the probability that the system is in state $(m,p)$ at time $t$.\n",
"Then, by letting $\\Delta t \\to 0$, it is\n",
"\n",
"\\begin{align}\n",
"\\frac{\\mathrm{d}P(m,p,t)}{\\mathrm{d}t} &= \\beta_m P(m-1,p,t) & \\text{(from left)}\\\\\n",
" &+ (m+1)P(m+1,p,t) & \\text{(from right)}\\\\\n",
" &+\\beta_p mP(m,p-1,t) & \\text{(from bottom)}\\\\\n",
" &+ \\gamma (p+1)P(m,p+1,t) &\\text{(from top)}\\\\\n",
" &- mP(m,p,t) & \\text{(to left)}\\\\\n",
" &- \\beta_m P(m,p,t) & \\text{(to right)}\\\\\n",
" &- \\gamma p P(m,p,t) &\\text{(to bottom)}\\\\\n",
" &- \\beta_p mP(m,p,t)\\enspace. & \\text{(to top)}\n",
"\\end{align}\n",
"\n",
"We implicitly define $P(m, p, t) = 0$ if $m < 0$ or $p < 0$. This is the master equation we will sample from using the stochastic simulation algorithm (SSA) also called Gillespie algorithm."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Gillespie algorithm\n",
"\n",
"### Propensity\n",
"The rhs terms in the above equation are familiar to us: they almost look like reaction rates with a single difference of not being functions of *concentrations*, but of *species counts*.\n",
"For example, a reaction\n",
"$$\n",
"A + B \\rightarrow C\n",
"$$\n",
"with mass-action kinetics and rate constant $\\gamma$ in units of $\\text{L} s^{-1}$\n",
"has **rate**\n",
"$$\n",
"\\gamma \\cdot [A] \\cdot [B]\n",
"$$\n",
"in units of $\\text{L}^{-2} \\cdot \\text{L} \\text{s}^{-1} = \\text{L}^{-1} \\text{s}^{-1}$.\n",
"Concentrations may as well be given in [molar units](https://en.wikipedia.org/wiki/Molar_concentration).\n",
"\n",
"By contrast, the **propensity** of the reaction is\n",
"$$\n",
"\\gamma' \\cdot A \\cdot B\n",
"$$\n",
"in units of $\\text{s}^{-1}$, where\n",
"$\\gamma' = \\gamma / \\text{vol}$ is in units of $\\text{s}^{-1}$\n",
"and vol is the volume of the compartment in which the reactions happen.\n",
"\n",
"The propensity for a given transition/reaction, say indexed $i$, is denoted as $a_i$.\n",
"The equivalence to notation we introduced for master equations is that if transition $i$ results in the change of state from $n'$ to $n$, then $a_i = W(n\\mid n')$.\n",
"\n",
"In general, the propensity of a reaction $(\\mathbf{r}, \\mathbf{p}, \\alpha)$ at time $t$ is\n",
"$$\n",
"\\frac{\\alpha}{v^{o-1}} \\prod_{s\\in \\mathcal{S}} \\binom{s(t)}{\\mathbf{r}(s)}\n",
"$$\n",
"where $s(t)$ is the *count* of species $s$ at time $t$, $v$ is the volume, and $o = \\sum_{s\\in\\mathcal{S}} \\mathbf{r}(s)$ is the order of the reaction.\n",
"Its effect is subtracting $\\mathbf{r}(s)$ from the count of species $s$ and adding $\\mathbf{p}(s)$ to the count of species $s$.\n",
"\n",
"### Switching states: transition probabilities and transition times \n",
"To cast this problem for a Gillespie simulation, we can write each change of state (moving either the copy number of mRNA or protein up or down by 1 in this case) and their respective propensities.\n",
"\n",
"\\begin{align}\n",
"\\begin{array}{ll}\n",
"\\text{reaction, }r_i & \\text{propensity, } a_i \\\\\n",
"m \\rightarrow m+1,\\;\\;\\;\\; & \\beta_m \\\\[0.3em]\n",
"m \\rightarrow m-1, \\;\\;\\;\\; & m\\\\[0.3em]\n",
"p \\rightarrow p+1, \\;\\;\\;\\; & \\beta_p m \\\\[0.3em]\n",
"p \\rightarrow p-1, \\;\\;\\;\\; & \\gamma p\\enspace.\n",
"\\end{array}\n",
"\\end{align}\n",
"\n",
"We will not carefully prove that the Gillespie algorithm samples from the probability distribution governed by the master equation, but will state the principles behind it. The basic idea is that events (such as those outlined above) are rare, discrete, separate events. I.e., each event is an arrival of a Poisson process. The Gillespie algorithm starts with some state, $(m_0,p_0)$. Then a state change, *any* state change, will happen in some time $\\Delta t$ that has a certain probability distribution (which we will show is exponential momentarily).\n",
"\n",
"#### transition probabilities\n",
"The probability that the state change that happens is because of reaction $j$ is proportional to $a_j$.\n",
"That is to say, state changes with high propensities are more likely to occur.\n",
"Thus, choosing which of the $k$ state changes happens in $\\Delta t$ is a matter of drawing an integer $j \\in [1,k]$ where the probability of drawing $j$ is\n",
"\n",
"\\begin{align}\n",
"\\frac{a_j}{\\sum_i a_i}\\enspace.\n",
"\\end{align}\n",
"\n",
"#### transition times\n",
"Now, how do we determine how long the state change took?\n",
"Let $T_i(m,p)$ be the stochastic variable that is the time that reaction $i$ occurs in state $(m,p)$, given that it is reaction\n",
" $i$ that results in the next state.\n",
"The probability density function $p_i$ for the stochastic variable $T_i$, is\n",
"\\begin{align}\n",
"p_i(t) = a_i\\, \\mathrm{e}^{-a_i t}\\enspace,\n",
"\\end{align}\n",
"for $t \\geq 0$, and $0$ otherwise.\n",
"This is known as the [exponential distribution](https://www.randomservices.org/random/poisson/Exponential.html) with rate parameter $a_i$ (related, but not equal to the rate of the reaction).\n",
"\n",
"The probability that it has *not* occurred by time $\\Delta t$, is thus\n",
"\\begin{align}\n",
"P(T_i(m,p) > \\Delta t \\mid \\text{reaction } r_i \\text{ occurs}) = \\int_{\\Delta t}^\\infty p_i(t) \\mathrm{d}t = \\mathrm{e}^{-a_i \\Delta t}\\enspace.\n",
"\\end{align}\n",
"\n",
"However, in state $(m,p)$ there are several reactions that may make the system transition to the next state.\n",
"Say we have $k$ reactions that arrive at times $t_1, t_2, \\ldots$.\n",
"When does the first one of them arrive?\n",
"\n",
"The probability that *none* of them arrive before $\\Delta t$ is\n",
"\\begin{align}\n",
"P(t_1 > \\Delta t \\wedge t_2 > \\Delta t \\wedge \\ldots) &=\n",
"P(t_1 > \\Delta t) P(t_2 > \\Delta t) \\cdots =\n",
"\\prod_i \\mathrm{e}^{-a_i \\Delta t} \n",
"= \\mathrm{exp}\\left(-\\Delta t \\sum_i a_i\\right)\\enspace.\n",
"\\end{align}\n",
"This is the equal to $P(T(m,p) > \\Delta t \\mid \\text{reaction } R \\text{ occurs})$ for a reaction $R$ with\n",
" propensity $\\sum_i a_i$.\n",
"For such a reaction the occurrence times are exponentially distributed with rate parameter $\\sum_i a_i$.\n",
"\n",
"### The algorithm\n",
"So, we know how to choose a state change and we also know how long it takes.\n",
"The Gillespie algorithm then proceeds as follows.\n",
"\n",
"1. Choose an initial condition, e.g., $m = p = 0$.\n",
"2. Calculate the propensity for each of the enumerated state changes. The propensities may be functions of $m$ and $p$, so they need to be recalculated for every $m$ and $p$ we encounter.\n",
"3. Choose how much time the reaction will take by drawing out of an exponential distribution with a mean equal to $\\left(\\sum_i a_i\\right.)^{-1}$. This means that a change arises from a Poisson process.\n",
"4. Choose what state change will happen by drawing a sample out of the discrete distribution where $P_i = \\left.a_i\\middle/\\left(\\sum_i a_i\\right)\\right.$. In other words, the probability that a state change will be chosen is proportional to its propensity.\n",
"5. Increment time by the time step you chose in step 3.\n",
"6. Update the states according to the state change you choose in step 4.\n",
"7. If $t$ is less than your pre-determined stopping time, go to step 2. Else stop.\n",
"\n",
"Gillespie proved that this algorithm samples the probability distribution described by the master equation in his seminal papers in [1976](https://doi.org/10.1016/0021-9991(76)90041-3) and [1977](http://doi.org/10.1021/j100540a008). (We recommend reading the latter.) You can also read a concise discussion of how the algorithm samples the master equation in [Section 4.2 of Del Vecchio and Murray](http://www.cds.caltech.edu/~murray/books/AM08/pdf/bfs-stochastic_14Sep14.pdf)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Chemical Langevin Equation\n",
"\n",
"The Chemical Master Equation can be difficult to solve, which is why several approxmations were developed. One of these approximations is the Chemical Langevin Equation, which we will now derive. It is perfectly useful on its own, in particular from a computational perspective. We present it here for another reason as well: to show that the ODE kinetics of a CRN are an approximation to the expected stochastic kinetics, at least for linear CRNs.\n",
"\n",
"It starts \n",
"\n",
"$$\n",
"X_i(t + \\tau) = X_i(t) + \\sum_{j=1}^M \\nu_{j,i} K_j(X(t), \\tau)\n",
"$$\n",
"where $\\nu_{j,i}$ is the net change in the count of species $i$ in reaction $j$ and $K_j(X(t), \\tau)$ is the random variable that specifies how many times reaction $j$ occurs in the time interval $[t, t+\\tau]$.\n",
"\n",
"**Assumption 1** of the chemical Langevin equation is that the propensity functions do not change significantly during the time interval $[t, t+\\tau]$, i.e., $a_j(X(t')) \\approx a_j(X(t))$ for all $t' \\in [t,t+\\tau]$.\n",
"\n",
"Then, we can rewrite the above equation as\n",
"$$\n",
"X_i(t + \\tau) = X_i(t) + \\sum_{j=1}^M \\nu_{j,i} \\mathcal{P}_j(a_j(X(t)) \\cdot \\tau)\n",
"$$\n",
"where the $\\mathcal{P}_j(a_j(X(t)) \\cdot \\tau)$ are independent Poisson variables with parameter $a_j(X(t)) \\cdot \\tau$.\n",
"\n",
"**Assumption 2** of the chemical Langevin equation requires the expected number of occurrences of each reaction to be big, i.e., $a_j(X(t))\\cdot \\tau \\gg 1$.\n",
"\n",
"Note that the two assumption require a tradeoff: assumption 1 wants $\\tau$ to be small whereas assumption 2 wants $\\tau$ to be big. It is very well possible that no choice of $\\tau$ satisifies both assumptions for a given system.\n",
"\n",
"It is [well-known](https://en.wikipedia.org/wiki/Poisson_distribution#General) that the Poisson distribution with parameter $\\lambda$ is well approximated by the normal distribution $\\mathcal{N}(\\lambda,\\lambda)$ with expected value $\\mu = \\lambda$ and variance $\\sigma^2 = \\lambda$ for large values of $\\lambda$.\n",
"\n",
"Assumption 2 thus suggests using this approximation to get\n",
"$$\n",
"\\mathcal{P}_j(a_j(X(t)) \\tau) \\approx a_j(X(t))\\tau + \\sqrt{a_j(X(t))\\tau} \\cdot \\mathcal{N}(0,1)\n",
"$$\n",
"where $\\mathcal{N}(0,1)$ is a standard normally distributed random variable.\n",
"\n",
"Now, switching to $X(t)$ being real-valued and setting $\\tau = dt$, in the limit $dt \\to 0$, we finally get the chemical Langevin equation:\n",
"$$\n",
"\\frac{dX_i(t)}{dt} = \\sum_{j=1}^M \\nu_{j,i} a_j(X(t)) + \\sum_{j=1}^M \\nu_{j,i} \\sqrt{a_j(X(t))} \\Gamma_j(t)\n",
"$$\n",
"where the $\\Gamma_j$ are independent standard Gaussian white noise processes."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## From Stochastic to Deterministic Kinetics\n",
"\n",
"If the assumptions of the chemical Langevin equation hold sufficiently well, it is easy to make the connection between the stochastic and the deterministic kinetics of CRNs. In this case, taking the expected value (over an ensemble of sample paths) on both sides of the equation, we get:\n",
"$$\n",
"\\frac{d \\mathbb{E} X_i(t)}{dt} = \\sum_{j=1}^M \\nu_{j,i} \\mathbb{E} a_j(X(t))\n",
"$$\n",
"\n",
"If the propensities follow a mass-action law, the expected value $\\mathbb{E} a_j(X(t))$ is sometimes an approximation to $a_j(\\mathbb{E} X(t))$. If there are only unary reactions, they are equal for instance.\n",
"\n",
"The detour via the chemical Langevin equation is not the only way to show the above formula. For a large-volume (or large-species-count) limit, it can be derived directly from the Chemical Master Equation."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}