Further reading: not part of the course. This material is not included in the course, but it is relevant if you want to learn more about the topic.

Continuous-time Markov chains

Further reading — Continuous-time Markov chains

Quantitative biology and integrative omics

About this lecture

In Markov chains, time moved in steps: \mathbf{x}_{t+1} = \mathbf{x}_t P. Real cells do not wait for a clock tick. A promoter can switch on at 10:03:17, and an ion channel can open after 2.4 ms.

This lecture builds the continuous-time version of the same idea:

  • Rates instead of per-step probabilities.
  • The time spent in a state is exponential (from Error models).
  • The rate matrix Q, whose rows sum to 0.
  • Simulating a chain: draw a waiting time, then pick a jump.
  • The stationary distribution from \boldsymbol\pi Q = \mathbf{0}, found by balancing flows.
  • How Q links back to the step matrix P.

Biology happens in continuous time

Many biological switches flip at random moments, not on a schedule:

  • Gene promoter ON/OFF (the telegraph model): a promoter switches between an active and a silent state, and mRNA is made only while it is ON.
  • Ion channels open and close; the current through a single channel jumps between levels.
  • Cell states such as stem ↔︎ progenitor → differentiated, observed in time-lapse.
  • Mutations: a DNA site changes base now and then, over millions of years.

One promoter, simulated over 40 minutes (numbers = how long each period lasted):

Continuous-time chains use rates, not step probabilities

A rate is “expected number of events per unit of time”, for example 0.5 per minute.

Discrete time (Markov chains) Continuous time (today)
Time steps t = 0, 1, 2, \dots any time t \ge 0
Arrow i \to j carries probability p_{ij} per step rate q_{ij}, e.g. 0.5 /min
Staying put self-loop p_{ii} no self-loop: just “not jumped yet”
Collected in P, rows sum to 1 Q, rows sum to 0

For a short time \Delta t, a rate turns into a small probability:

P(\text{jump } i \to j \text{ within } \Delta t) \;\approx\; q_{ij}\,\Delta t .

With q_{\text{ON}\to\text{OFF}} = 0.5 /min: in 6 seconds (\Delta t = 0.1 min) the chance to switch off is about 0.05.

Time spent in a state is exponentially distributed

Let q_i be the total rate of leaving state i (the sum of the rates on all arrows out of i). Then the time T spent in i before the next jump is exponential (see the exponential distribution in Error models):

T \sim \text{Exp}(q_i), \qquad \text{mean time in } i = \frac{1}{q_i}.

Promoter: ON is left at a = 0.5 /min, so an ON period lasts on average 1/0.5 = 2 minutes.

  • Short periods are the most common; long ones are rare but do happen.
  • Memoryless: a promoter that has been ON for 5 minutes is no more likely to switch off in the next second than one that just switched on.
  • Same maths as gaps between random events, for example P(T > 4) = e^{-0.5\cdot 4} \approx 0.135.

The next state is picked in proportion to its rate

When a state has several arrows out, two questions are answered separately:

  1. When do you leave? After an \text{Exp}(q_i) time, where q_i = \sum_{j \ne i} q_{ij}.
  2. Where do you go? To j with probability \frac{q_{ij}}{q_i} = \frac{\text{rate to } j}{\text{total leaving rate}}.

The list of states visited, ignoring the times, is an ordinary discrete Markov chain (the jump chain), with no self-loops.

The rate matrix Q has rows that sum to zero

Collect the rates in a matrix, in the same row = from, column = to convention as P:

  • Off the diagonal: q_{ij} = rate from i to j (zero if there is no arrow).
  • On the diagonal: q_{ii} = -q_i, minus the total rate of leaving i.

So every row of Q sums to 0. For 3 cell states (rates per day):

Q = \begin{array}{c c} & \begin{array}{ccc}\ \text{stem} & \ \ \text{prog} & \ \ \text{diff}\end{array}\\ \begin{array}{c}\text{stem}\\ \text{prog}\\ \text{diff}\end{array} & \left(\begin{array}{ccc} -0.4 & 0.4 & 0\\ 0.2 & -0.4 & 0.2\\ 0 & 0.1 & -0.1 \end{array}\right) \end{array} \qquad \begin{array}{l} \leftarrow -0.4 + 0.4 + 0 = 0\\ \leftarrow 0.2 - 0.4 + 0.2 = 0\\ \leftarrow 0 + 0.1 - 0.1 = 0\end{array}

Check for P (discrete) Check for Q (continuous)
entries between 0 and 1 off-diagonal entries \ge 0 (any size)
rows sum to 1 diagonal \le 0, rows sum to 0

A 2-state example by hand

States ordered (\text{ON}, \text{OFF}); a = rate ON→OFF, b = rate OFF→ON.

Q = \begin{pmatrix} -a & a\\ b & -b \end{pmatrix} = \begin{pmatrix} -0.5 & 0.5\\ 0.25 & -0.25 \end{pmatrix}

  • Rows: -0.5 + 0.5 = 0 ✓, \ 0.25 - 0.25 = 0 ✓
  • Leaving rates: q_{\text{ON}} = 0.5, q_{\text{OFF}} = 0.25 /min
  • Mean times: ON 1/0.5 = 2 min, OFF 1/0.25 = 4 min
  • With only one arrow out, the jump chain is “always switch”.

How does a population change? Like \mathbf{x}_{t+1} - \mathbf{x}_t = \mathbf{x}_t(P - I) in discrete time, here change per minute = \mathbf{x}(t)\,Q:

\text{change in } x_{\text{ON}} \text{ per minute} = \underbrace{-a\,x_{\text{ON}}}_{\text{leaving ON}} + \underbrace{b\,x_{\text{OFF}}}_{\text{arriving from OFF}}.

Simulate by drawing a waiting time, then a jump

To simulate one cell, alternate how long and where to:

a <- 0.5; b <- 0.25                      # rates per minute
t <- 0; state <- "OFF"; times <- 0; states <- state
while (t < 60) {
  rate  <- if (state == "ON") a else b   # total leaving rate
  t     <- t + rexp(1, rate)             # how long?  Exp(rate)
  state <- if (state == "ON") "OFF" else "ON"   # where to? (only one choice here)
  times <- c(times, t); states <- c(states, state)
}

This is the Gillespie algorithm (Gillespie 1977), used for simulating chemical reactions in cells.

Try it: 200 promoters in continuous time

At equilibrium, flow into each state equals flow out

The distribution stops changing when the change per unit time is zero:

\boldsymbol\pi Q = \mathbf{0}, \qquad \textstyle\sum_k \pi_k = 1 \qquad \text{(compare } \boldsymbol\pi P = \boldsymbol\pi \text{ in discrete time).}

For 2 states this is flow in = flow out:

\pi_{\text{ON}}\, a = \pi_{\text{OFF}}\, b .

Add \pi_{\text{ON}} + \pi_{\text{OFF}} = 1:

\boldsymbol\pi = \frac{(b,\ a)}{a+b}.

Promoter: \boldsymbol\pi = (0.25, 0.5)/0.75 = (1/3,\ 2/3). ON one third of the time.

Same answer from the waiting times: mean ON 2 min, mean OFF 4 min, so ON a fraction 2/(2+4) = 1/3 of the time.

The sum of the rates sets the speed to equilibrium

For 2 states, the distance to \boldsymbol\pi shrinks exponentially, with rate a + b:

x_{\text{ON}}(t) = \pi_{\text{ON}} + \big(x_{\text{ON}}(0) - \pi_{\text{ON}}\big)\, e^{-(a+b)t}.

Promoter: a + b = 0.75 /min, so the gap halves every \ln 2 / 0.75 \approx 0.9 min. Both rates speed this up, even though only their ratio sets \boldsymbol\pi.

Back to discrete time: P \approx I + Q\,\Delta t

Look at the chain only every \Delta t minutes. For small \Delta t, using q_{ij}\Delta t for the chance of a jump:

P \approx I + Q\,\Delta t, \qquad \Delta t = 0.25:\quad P = \begin{pmatrix} 1 - 0.125 & 0.125\\ 0.0625 & 1 - 0.0625 \end{pmatrix} = \begin{pmatrix} 0.875 & 0.125\\ 0.0625 & 0.9375 \end{pmatrix}.

  • Rows of P sum to 1, because rows of Q sum to 0.
  • Same \boldsymbol\pi: \boldsymbol\pi P = \boldsymbol\pi + \Delta t\,\boldsymbol\pi Q = \boldsymbol\pi.
  • Small \Delta t follows the exact curve; large \Delta t does not.
  • Aside: the exact step matrix is P(t) = e^{Qt}, the “matrix exponential” (expm package). Not needed here.

Where this shows up: transcriptional bursting

Add mRNA to the telegraph model: while ON, mRNA is made at rate s; each mRNA is degraded at rate g. It is still a continuous-time Markov chain, now with many states (promoter, number of mRNA), simulated with Gillespie.

Short, rare ON periods give bursts. Across 2000 simulated cells: mean 4.5 mRNA, variance 39, and 31\% zeros where a Poisson with that mean would give 1\%. These are the overdispersed counts of Error models; with bursty promoters, counts are close to negative binomial.

Where this shows up: DNA substitution models

At one DNA site, bases change by mutation over long times: a 4-state chain on \{\mathtt{A},\mathtt{C},\mathtt{G},\mathtt{T}\}.

The simplest model, Jukes–Cantor: every change happens at the same rate \alpha.

Q = \begin{pmatrix} -3\alpha & \alpha & \alpha & \alpha\\ \alpha & -3\alpha & \alpha & \alpha\\ \alpha & \alpha & -3\alpha & \alpha\\ \alpha & \alpha & \alpha & -3\alpha \end{pmatrix}, \qquad \boldsymbol\pi = \left(\tfrac14, \tfrac14, \tfrac14, \tfrac14\right).

  • With 3\alpha = 1, time is measured in expected substitutions per site, and the chance that a site still shows its original base after time t is \tfrac14 + \tfrac34 e^{-4t/3}.
  • So two sequences can never differ at more than about 3/4 of their sites: changes on top of changes are hidden. Distances between species are corrected for this.
  • Richer models give transitions and transversions different rates, or unequal base frequencies. Phylogenetics software fits such Q matrices.

The model’s assumptions can fail in real cells

Assumption What it means When it breaks
Memoryless waiting times are exponential; time already spent does not matter a cell-cycle phase has a minimum length; a promoter has a refractory period after switching off
Constant rates q_{ij} do not change over time circadian rhythms, a drug added at a fixed time, cells that age
Few, well-defined states the state says everything about the future a “state” hides sub-states (chromatin, signalling)
Independent walkers cells do not influence each other quorum sensing, competition for resources

A common fix for non-exponential times: split one visible state into several hidden stages in a row. The total time then has a peak instead of a maximum at zero, while the chain stays Markov on the larger state space.

Summary

Concept Discrete time Continuous time
Arrow i \to j probability p_{ij} rate q_{ij} (per time unit)
Matrix P, rows sum to 1 Q, q_{ii} = -q_i, rows sum to 0
Time in state i geometric (in steps) exponential, mean 1/q_i
Next state row i of P j with probability q_{ij}/q_i
Evolution \mathbf{x}_{t+1} = \mathbf{x}_t P change per time = \mathbf{x}(t)\,Q
Stationary \boldsymbol\pi P = \boldsymbol\pi \boldsymbol\pi Q = \mathbf{0}; 2 states: (b, a)/(a+b)
Link P \approx I + Q\,\Delta t for small \Delta t

Simulate with Gillespie: how long (exponential), then where to (rate / total rate).