introduction to stochastic simulation with the gillespie ... · a general method for numerically...

36
Introduction to Stochastic Simulation with the Gillespie Method David Karig April 18, 2005

Upload: others

Post on 11-Mar-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Introduction to Stochastic Simulation with the Gillespie Method

David KarigApril 18, 2005

Page 2: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Stochastic Systems

• Many systems driven by random, discrete interactions

• Traditional deterministic models may not accurately describe such systems

$

Page 3: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Example: The Lambda SwitchVirus Decision Dictated by Noise

Arkin, Ross, McAdams, Genetics (1998)

Page 4: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Example: The Lambda SwitchVirus Decision Dictated by Noise

Arkin, Ross, McAdams, Genetics (1998)

Page 5: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Example: The Lambda SwitchVirus Decision Dictated by Noise

Arkin, Ross, McAdams, Genetics (1998)

Page 6: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Outline

• Deterministic rate reaction model• Gillespie method• Examples

– Lambda phage– Epidemiology

• Optimizations

Page 7: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Deterministic Model

Reactions:A + B C

C A + BA BC

ODE’s:dA/dt = -k1*A*B + k2*C – k3*AdB/dt = -k1*A*B + k2*C + k3*AdC/dt = k1*A*B – k2*C - k4*C

• Given initial conditions, integrate the coupled equations for some period of time

k1

k4

k2

k3

Page 8: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Problem Statement

If we start with N species which can interact through one of M reactions at a given time,what will be the population levels of species after a given period of time?

p**

☺ p**

p**

Page 9: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Deterministic Solution

• Continuous• Average kinetic rates represent

reaction probabilities

dA/dt = -k1*A*B + k2*C – k3*AdB/dt = -k1*A*B + k2*C + k3*AdC/dt = k1*A*B – k2*C – k4*C

A + B CC A + B A B C

0 5 100

500

1000

1500

2000

t

ABC

Page 10: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Validity of Deterministic Solution

A + B C

0 2 4 6 8 100

200

400

600

800

1000

t

ABC

Page 11: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Validity of Deterministic Solution

0 200 400 600 8000

2

4

6

8

10

t

ABC

0 200 400 600 8000

2

4

6

8

10

t

ABC

Page 12: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Reaction Probabilities• cµ dt = average probability that a particular combination

of reactants will react according to Rµ in the next time interval dt

• hµ = number of reactant combinations• hµcµ dt = aµ dt = average probability that an Rµ

reaction will occur somewhere inside Vin the next time interval dt

Page 13: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Reaction Probabilities• cµ dt = average probability that a particular combination

of reactants will react according to Rµ in the next time interval dt

• hµ = number of reactant combinations• hµcµ dt = aµ dt = average probability that an Rµ

reaction will occur somewhere inside Vin the next time interval dt

X molecules of AY molecules of B

XYc1 dt = probability that an R1 reaction will occur somewhereinside V in the next time interval dt

R1: A + B C

h1 = XY reactant combinations

Page 14: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Exact Stochastic Simulation• Avoid averaging assumptions• Probabilistic formulation

– When does next reaction occur?– Which reaction occurs next?

• Reaction probability density function:

t t+τ

P(τ,µ)dτ = probability at time t that the next reaction is Rµ and occurs in interval (t+τ,t+τ+dτ)

t+τ+dτ

Rµ A + B CC A + B A B C

R1:R2:R3:R4:

System State:t+τt

78C21B21A

Page 15: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

P(τ,µ)dτ = P0(τ) hµcµdτ

probability that no reaction occurs during (t,t+τ)

probability that reaction µ occurs during (t+τ, t+τ+dτ)

Deriving Reaction PDF

t t+τ t+τ+dτ

Page 16: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Deriving P0(τ) for Reaction PDF

Kτε =

t t+τ• Divide (t,t+τ) into K subintervals of width ε

• Probability that none of the reactions occur in any of the K subintervals:

( ) [ ] ∑=

⎥⎥⎦

⎢⎢⎣

⎡−=−= =

−=

∞→=

∑∑M

iiich

KM

i ii

K

KM

i ii eK

chchP 11

10 1lim1ττ

ετ

Page 17: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Direct Method for Generating P(τ,µ)

( ) ( )

( ) )()(

,

00

0

0

0

1

τµτ

τµτ

µτ

τµ

τ

µµµµ

PPaa

ea

ea

echPchP

a

a

chM

iii

⋅=⎟⎟⎠

⎞⎜⎜⎝

⎛=

=

∑==

−=

when next reaction occurs

which reactionoccurs

aM

a3

a2

a1

a0 ∑=

=M

a1µ

µ

RM

R3

R2

R1

Page 18: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Direct Method for Generating P(τ,µ)

( ) ( )

( ) )()(

,

00

0

0

0

1

τµτ

τµτ

µτ

τµ

τ

µµµµ

PPaa

ea

ea

echPchP

a

a

chM

iii

⋅=⎟⎟⎠

⎞⎜⎜⎝

⎛=

=

∑==

−=

when next reaction occurs

which reactionoccurs

∑∑ =

=<<

µµ

121

1 i ioi i aarandaµ is the integer for which

aM

a3

a2

a1

a0 ∑=

=M

iia

1

rand2a0

τ = (1/a0)ln(1/rand1)

RM

R3

R2

R1

Page 19: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Stochastic Simulation Algorithm1. Initialization

– Set values of cµ for the M reactions.– Set initial population sizes

2. Calculate the M values aµ and a0 = Σ aµ.3. Generate (τ,µ) based on P(τ,µ)4. Adjust population levels according to the

reaction Rµ, and increase t by τ5. Return to Step 2

Page 20: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Lambda Phage Developmental PathwayArkin, Ross, McAdams, Genetics (1998)

• Regulatory circuit exploits stochastic noise to produce different outcomes

• Stochastic model can predict statistics of regulatory outcomes

Page 21: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Lambda Phage: Regulatory Circuit

• CI and Crocompetitively bind OR1, OR2, OR3

• Cro represses PRand PRM

• CI represses PR, can activate PRM

Page 22: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Lambda Phage: Regulatory Circuit

• CI and Crocompetitively bind OR1, OR2, OR3

• Cro represses PRand PRM

• CI represses PR, can activate PRM

Page 23: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Time Evolution of Two Runs

Page 24: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Epidemiology Example

Susceptible Infected Recovered

p**

☺ p**

p**

0 50 100 150 200

700

800

900

# su

scep

tible

s

0 50 100 150 200

100

200

# in

fect

ed

0 50 100 150 200

4200

4400

4600

# re

cove

red

t (weeks)

0 50 100 150 200

700

800

900

# su

scep

tible

s

0 50 100 150 200

100

200

# in

fect

ed

0 50 100 150 200

4200

4400

4600

# re

cove

red

t (weeks)

Page 25: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Evaluation of Stochastic Simulation

• Advantages– continuous time, discrete population changes– captures effects of noise– simple implementation– small memory requirements

• Disadvantages– CPU intensive– typically must simulate many runs– must use good random number generator

• periodicity affects size of simulation• resolution limits range of probabilities

Page 26: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Computational Requirements• Memory (N + 2M + 1)

– N species populations– c and a values for each of M reactions; a0

• Total time scales with number of reactions that occur• Operations per reaction:

Calculate a valuesSearch µCalculate τCalculate a0

Generate 2 random numbersO(M)

O(M)

O(M)

Page 27: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Optimized Direct Method (ODM)Y. Cao, H. Li, L. Petzold. 2004. J. Chem. Phys. 121:4059-4067

∑∑ =

=<<

µµ

121

1 i ioi i aaranda• Reduce cost of searching for index µ

• Observation: Reactions are typically multiscale in a large system. Subset will frequently occur.

• Sort index of reactions based on how often they occur

…aM

a3

a2

a1

a0 ∑=

=M

iia

1

rand2a0

Page 28: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Optimized Direct Method (ODM)

• Reduce cost of calculating all aµ

• Dependency graph• Reduce cost of

summing all aµ to calculate a0

• Modify a0 by subtracting old values, adding new Gibson and Bruck, 2000

Page 29: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Conclusion

• Provides means of studying role of noise in complex systems

• Can predict statistics (Lambda phage)• Can depict behavior that deterministic

simulations do not capture (epidemiology example)

• Enhancing performance an active area of investigation

Page 30: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Useful References / Further Study• Implementations

– STOCKS: http://www.sysbio.pl/stocks/stocks1.html– BioNetS: https://users.biospice.org/toolsumm.php?id=2– http://www.staff.ncl.ac.uk/d.j.wilkinson/software/

• Algorithms/optimizations– D.T. Gillespie. A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled

Chemical Reactions. 1976. J Comput Phys 22:403-434.– D.T. Gillespie. Exact Stochastic Simulation of Coupled Chemical Reactions. 1977. J Phys Chem 81:2340-

2361– M.A. Gibson and J. Bruck. 2000. Efficient Exact Stochastic Simulation of Chemical Systems with Many

Species and Many Channels. J Phys Chem 104:1876-1889– D.T. Gillespie. 2001. Approximate accelerated stochastic simulation of chemically reacting systems. J.

Chem. Phys. 115:1716-1733. – Y. Cao, H. Li and L. Petzold, Efficient formulation of the stochastic simulation algorithm for chemically

reacting system. 2004. J Chem Phys 121:4059-4067– Y. Cao, D. Gillespie, L. Petzold, The slow-scale stochastic simulation algorithm. 2005. J Chem Phys 122(1).– A. Chatterjee and D.G. Vlachos. Binomial distribution based τ-leap accelerated stochastic simulation. 2005.

J Chem Phys 122:024112• Example Uses

– A. Arkin, J. Ross, H. McAdams. Stochastic Kinetic Analysis of Developmental Pathway Bifurcation in λPhage-Infected Escherichia coli Cells. 1998. Genetics 149:1633-1648

– J. Dushoff, J.B. Plotkin, S.A. Levin, D.J.D. Earn. Dynamical resonance can account for seasonality of influenza epidemics. 2004 PNAS.

– S. Hooshangi, S. Thiberge, R. Weiss. Ultrasensitivity and noise propagation in a synthetic transcriptional cascade. 2005. PNAS 102:3581-3586

Page 31: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Acknowledgements

• Ron Weiss and the Weiss group

• PICASso– Steven Kleinstein– J.P. Singh

Page 32: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput
Page 33: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Comparing to Experimental Results• Compare predicted percent lysogenization to

experimental results at different infection levels• Average phage input (API) = ratio of phage particles to

cells at time of infection• Multiplicity of infection (MOI) = phage particles per cell• Poisson probability that a given cell will be infected with

MOI=M when API=A

• Expected fraction of lysogens:

( ) AM

eA

AAMP −=!

,

( ) ( ) ( )∑ ⋅=M

lysogens MFAMPAF ,

Page 34: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Comparing to Experimental Results

Page 35: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Example (deterministic assumptions)

Average rate of R1 in dt per unit volume:

VcXX

VcXX 121121 =

Using concentrations xi = Xi/V and dividing by density of reactants:

21

1211 xx

Vcxxk =

Deterministic assumption:Vck 11=

1211 2S SS :R →+

2112

2111

xxktx

xxktx

−=∂

=∂∂

Page 36: Introduction to Stochastic Simulation with the Gillespie ... · A General Method for Numerically Simulating the Stochastic Time Evolution of Coupled Chemical Reactions. 1976. J Comput

Master equation

• Bµ dt = probability that single R reaction brings us to state X1,…,XN

• aµ dt = hµcµ dt , where hµ is the number of reactant combinations

• Often difficult to solve analytically and even numerically • Instead simulate individual trajectories using Monte

Carlo algorithm

( ) ( )[ ]∑ =−=

∂∂ M

NN tXXPaBtXXPt 1 11 ;,...,;,...,

µ µµ