Lecturer: Antti Honkela
Your name:
Name of your pair:
In this exercise you will implement simulators to simulate biochemical reaction systems similar to ones that could be used to simulate gene expression.
In this task your aim is to perform stochastic simulation of simple discrete reaction systems with a single species X in different scenarios. Each scenario comes with a number of questions. Please answer these by having your code print out the answers.
The corresponding reaction system is: $$ X \rightarrow \emptyset $$
Hints:
%matplotlib inline
# Import some useful modules
import matplotlib.pyplot as plt
import numpy as np
import numpy.random as npr
# Suggested structure: simulate the decay of a population of N0 individuals at rate 'rate' for 'numsteps' steps
def simulate_decay(N0, rate, numsteps):
# Current population size
N = N0
# Current time
t_cur = 0
# History of population size across the simulation
Nhist = np.zeros(numsteps+1)
Nhist[0] = N
# Times of the corresponding population sizes
Thist = np.zeros(numsteps+1)
Thist[0] = t_cur
# ...
# ADD CODE FOR PERFORMING THE SIMULATION HERE
# ...
return (Thist, Nhist)
The corresponding reaction system is: \begin{align} X &\rightarrow 2X \ X &\rightarrow \emptyset \ \end{align}
def simulate_birthdeath(N0, birthrate, deathrate, numsteps):
# Current population size
N = N0
# Current time
t_cur = 0
# History of population size across the simulation
Nhist = np.zeros(numsteps+1)
Nhist[0] = N
# Times of the corresponding population sizes
Thist = np.zeros(numsteps+1)
Thist[0] = t_cur
# ...
# ADD CODE FOR PERFORMING THE SIMULATION HERE
# ...
return (Thist, Nhist)
The corresponding reaction system is: \begin{align} \emptyset &\rightarrow X \ X &\rightarrow \emptyset \ \end{align}
def simulate_migrationdeath(N0, migrationrate, deathrate, numsteps):
# Current population size
N = N0
# Current time
t_cur = 0
# History of population size across the simulation
Nhist = np.zeros(numsteps+1)
Nhist[0] = N
# Times of the corresponding population sizes
Thist = np.zeros(numsteps+1)
Thist[0] = t_cur
# ...
# ADD CODE FOR PERFORMING THE SIMULATION HERE
# ...
return (Thist, Nhist)
Briefly summarise how each model behaves qualitatively in the text area below:
# Suggested skeleton for the simulation algorithm
# Suggested arguments are NumPy arrays with sizes as follows:
# inputs: [reactions x state]
# outputs: [reactions x state]
# rates: [reactions]
def stochastic_simulation_algorithm(initstate, inputs, outputs, rates, numsteps):
# Current time and state
t_cur = 0
state = 1.0 * initstate
# State history
Nhist = np.zeros((numsteps+1, len(state)))
Nhist[0,:] = state
# Time history
Thist = np.zeros(numsteps+1)
Thist[0] = t_cur
# ...
# ADD CODE FOR PERFORMING THE SIMULATION HERE
# ...
return (Thist, Nhist)
Your simulator should follow Eq. (11) in Gillespie (2000) paper. In order to discretise the time, please select a finite time step \tau and apply the Euler discretisation of approximating $$ \frac{dX(t)}{dt} = f(X(t)) $$ by $$ X(t + \tau) \approx X(t) + \tau \cdot f(X(t)). $$
# Suggested skeleton with same arguments as above, except tau is the time step
def simulate_reaction_ode(initstate, inputs, outputs, rates, numsteps, tau):
pass
Your simulator should follow Eq. (21) of the Gillespie (2000) paper.
# Suggested skeleton with same arguments as above, except tau is the time step
def simulate_chemical_langevin_eq(initstate, inputs, outputs, rates, numsteps, tau):
pass
In this task you will implement a simplified model of repressive regulation, a simplified "repressilator". This is more complicated than the predator-prey system in 2b because preventing preduction is not the same as enhancing degradation. (In the predator analogue, predators would only target the young and therefore decrease the birth rate of prey but leave the existing (adult) population intact.
The repressilator model has 3 genes, each of which represses the next in a cycle A -> B -> C -> A. A realistic model would include 6 species to model both mRNAs and protein levels of each gene. In this task we simplify things a bit by combining the mRNA and protein for each gene.
In order to simulate repression, we augment the model by introducing additional states $aX$ and $rX$ that represent "active" and "repressed" promoter states of gene $X \in \{A, B, C\}$. Production of gene $X$ only happens when the promoter is in the active state and the repressor moves the promoter into repressed state. The system can be expressed through reactions: \begin{align} aX &\rightarrow aX + 10 X \quad &\text{# transcription} \ Y + aX &\rightarrow rX &\text{# repression, } Y \text{ is the repressor}\ rX &\rightarrow aX &\text{# recovery from repression} \ X &\rightarrow \emptyset &\text{# decay} \end{align} These reactions are repeated for all genes, resulting in total 12 reactions for the 9 species in the system.
Bonus task: implement a full repressilator model including both mRNAs and proteins. Try to assign realistic rates for all the reactions. Simulate your model using the simulators you implemented in Tasks 2 and/or 3 and visualise the results.