Misplaced Pages

Gillespie algorithm

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Method for stochastic equation systems

In probability theory, the Gillespie algorithm (or the Doob–Gillespie algorithm or stochastic simulation algorithm, the SSA) generates a statistically correct trajectory (possible solution) of a stochastic equation system for which the reaction rates are known. It was created by Joseph L. Doob and others (circa 1945), presented by Dan Gillespie in 1976, and popularized in 1977 in a paper where he uses it to simulate chemical or biochemical systems of reactions efficiently and accurately using limited computational power (see stochastic simulation). As computers have become faster, the algorithm has been used to simulate increasingly complex systems. The algorithm is particularly useful for simulating reactions within cells, where the number of reagents is low and keeping track of every single reaction is computationally feasible. Mathematically, it is a variant of a dynamic Monte Carlo method and similar to the kinetic Monte Carlo methods. It is used heavily in computational systems biology.

History

The process that led to the algorithm recognizes several important steps. In 1931, Andrei Kolmogorov introduced the differential equations corresponding to the time-evolution of stochastic processes that proceed by jumps, today known as Kolmogorov equations (Markov jump process) (a simplified version is known as master equation in the natural sciences). It was William Feller, in 1940, who found the conditions under which the Kolmogorov equations admitted (proper) probabilities as solutions. In his Theorem I (1940 work) he establishes that the time-to-the-next-jump was exponentially distributed and the probability of the next event is proportional to the rate. As such, he established the relation of Kolmogorov's equations with stochastic processes. Later, Doob (1942, 1945) extended Feller's solutions beyond the case of pure-jump processes. The method was implemented in computers by David George Kendall (1950) using the Manchester Mark 1 computer and later used by Maurice S. Bartlett (1953) in his studies of epidemics outbreaks. Gillespie (1977) obtains the algorithm in a different manner by making use of a physical argument.

Idea

Mathematics

In a reaction chamber, there are a finite number of molecules. At each infinitesimal slice of time, a single reaction might take place. The rate is determined by the number of molecules in each chemical species.

Naively, we can simulate the trajectory of the reaction chamber by discretizing time, then simulate each time-step. However, there might be long stretches of time where no reaction occurs. The Gillespie algorithm samples a random waiting time until some reaction occurs, then take another random sample to decide which reaction has occurred.

The key assumptions are that

  • each reaction is Markovian in time
  • there are no correlations between reactions

Given the two assumptions, the random waiting time for some reaction is exponentially distributed, with exponential rate being the sum of the individual reaction's rates.

Validity in biochemical simulations

Traditional continuous and deterministic biochemical rate equations do not accurately predict cellular reactions since they rely on bulk reactions that require the interactions of millions of molecules. They are typically modeled as a set of coupled ordinary differential equations. In contrast, the Gillespie algorithm allows a discrete and stochastic simulation of a system with few reactants because every reaction is explicitly simulated. A trajectory corresponding to a single Gillespie simulation represents an exact sample from the probability mass function that is the solution of the master equation.

The physical basis of the algorithm is the collision of molecules within a reaction vessel. It is assumed that collisions are frequent, but collisions with the proper orientation and energy are infrequent. It is assumed that the reaction environment is well mixed.

Algorithm

A review (Gillespie, 2007) outlines three different, but equivalent formulations; the direct, first-reaction, and first-family methods, whereby the former two are special cases of the latter. The formulation of the direct and first-reaction methods is centered on performing the usual Monte Carlo inversion steps on the so-called "fundamental premise of stochastic chemical kinetics", which mathematically is the function

p ( τ , j x , t ) = a j ( x ) exp ( τ j a j ( x ) ) , {\displaystyle p(\tau ,j\mid {\boldsymbol {x}},t)=a_{j}({\boldsymbol {x}})\exp \left(-\tau \sum _{j}a_{j}({\boldsymbol {x}})\right),}

where each of the a {\displaystyle a} terms are propensity functions of an elementary reaction, whose argument is x {\displaystyle {\boldsymbol {x}}} , the vector of species counts. The τ {\displaystyle \tau } parameter is the time to the next reaction (or sojourn time), and t {\displaystyle t} is the current time. To paraphrase Gillespie, this expression is read as "the probability, given X ( t ) = x {\displaystyle {\boldsymbol {X}}(t)={\boldsymbol {x}}} , that the system's next reaction will occur in the infinitesimal time interval [ t + τ , t + τ + d τ ] {\displaystyle } , and will be of stoichiometry corresponding to the j {\displaystyle j} th reaction". This formulation provides a window to the direct and first-reaction methods by implying τ {\displaystyle \tau } is an exponentially-distributed random variable, and j {\displaystyle j} is "a statistically independent integer random variable with point probabilities a j ( x ) / j a j ( x ) {\displaystyle a_{j}({\boldsymbol {x}})/\sum _{j}a_{j}({\boldsymbol {x}})} ".

Thus, the Monte Carlo generating method is simply to draw two pseudorandom numbers, r 1 {\displaystyle r_{1}} and r 2 {\displaystyle r_{2}} on [ 0 , 1 ] {\displaystyle } , and compute

τ = 1 j a j ( x ) log ( 1 r 1 ) , {\displaystyle \tau ={\frac {1}{\sum _{j}a_{j}({\boldsymbol {x}})}}\log \left({\frac {1}{r_{1}}}\right),}

and

j = {\displaystyle j={}} the smallest integer satisfying j = 1 j a j ( x ) > r 2 j a j ( x ) . {\displaystyle \sum _{j'=1}^{j}a_{j'}({\boldsymbol {x}})>r_{2}\sum _{j}a_{j}({\boldsymbol {x}}).}

Utilizing this generating method for the sojourn time and next reaction, the direct method algorithm is stated by Gillespie as

1. Initialize the time 
  
    
      
        t
        =
        
          t
          
            0
          
        
      
    
    {\displaystyle t=t_{0}}
  
 and the system's state 
  
    
      
        
          x
        
        =
        
          
            x
          
          
            0
          
        
      
    
    {\displaystyle {\boldsymbol {x}}={\boldsymbol {x}}_{0}}
  

2. With the system in state 
  
    
      
        
          x
        
      
    
    {\displaystyle {\boldsymbol {x}}}
  
 at time 
  
    
      
        t
      
    
    {\displaystyle t}
  
, evaluate all the 
  
    
      
        
          a
          
            j
          
        
        (
        
          x
        
        )
      
    
    {\displaystyle a_{j}({\boldsymbol {x}})}
  
 and their sum 
  
    
      
        
          
          
            j
          
        
        
          a
          
            j
          
        
        (
        
          x
        
        )
      
    
    {\displaystyle \sum _{j}a_{j}({\boldsymbol {x}})}
  

3. Calculate the above value of 
  
    
      
        τ

      
    
    {\displaystyle \tau }
  
 and 
  
    
      
        j
      
    
    {\displaystyle j}
  

4. Effect the next reaction by replacing 
  
    
      
        t
        
        t
        +
        τ

      
    
    {\displaystyle t\leftarrow t+\tau }
  
 and 
  
    
      
        
          x
        
        
        
          x
        
        +
        
          ν

          
            j
          
        
      
    
    {\displaystyle {\boldsymbol {x}}\leftarrow {\boldsymbol {x}}+\nu _{j}}
  

5. Record 
  
    
      
        (
        
          x
        
        ,
        t
        )
      
    
    {\displaystyle ({\boldsymbol {x}},t)}
  
 as desired. Return to step 2, or else end the simulation.

where ν j {\displaystyle \nu _{j}} represents adding the j th {\displaystyle j^{\text{th}}} component of the given state-change vector ν {\displaystyle \nu } . This family of algorithms is computationally expensive and thus many modifications and adaptations exist, including the next reaction method (Gibson & Bruck), tau-leaping, as well as hybrid techniques where abundant reactants are modeled with deterministic behavior. Adapted techniques generally compromise the exactitude of the theory behind the algorithm as it connects to the master equation, but offer reasonable realizations for greatly improved timescales. The computational cost of exact versions of the algorithm is determined by the coupling class of the reaction network. In weakly coupled networks, the number of reactions that is influenced by any other reaction is bounded by a small constant. In strongly coupled networks, a single reaction firing can in principle affect all other reactions. An exact version of the algorithm with constant-time scaling for weakly coupled networks has been developed, enabling efficient simulation of systems with very large numbers of reaction channels (Slepoy Thompson Plimpton 2008). The generalized Gillespie algorithm that accounts for the non-Markovian properties of random biochemical events with delay has been developed by Bratsun et al. 2005 and independently Barrio et al. 2006, as well as (Cai 2007). See the articles cited below for details.

Partial-propensity formulations, as developed independently by both Ramaswamy et al. (2009, 2010) and Indurkhya and Beal (2010), are available to construct a family of exact versions of the algorithm whose computational cost is proportional to the number of chemical species in the network, rather than the (larger) number of reactions. These formulations can reduce the computational cost to constant-time scaling for weakly coupled networks and to scale at most linearly with the number of species for strongly coupled networks. A partial-propensity variant of the generalized Gillespie algorithm for reactions with delays has also been proposed (Ramaswamy Sbalzarini 2011). The use of partial-propensity methods is limited to elementary chemical reactions, i.e., reactions with at most two different reactants. Every non-elementary chemical reaction can be equivalently decomposed into a set of elementary ones, at the expense of a linear (in the order of the reaction) increase in network size.

Examples

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (April 2021) (Learn how and when to remove this message)
This section possibly contains original research. Please improve it by verifying the claims made and adding inline citations. Statements consisting only of original research should be removed. (April 2021) (Learn how and when to remove this message)

Reversible binding of A and B to form AB dimers

A simple example may help to explain how the Gillespie algorithm works. Consider a system of molecules of two types, A and B. In this system, A and B reversibly bind together to form AB dimers such that two reactions are possible: either A and B react reversibly to form an AB dimer, or an AB dimer dissociates into A and B. The reaction rate constant for a given single A molecule reacting with a given single B molecule is k D {\displaystyle k_{\mathrm {D} }} , and the reaction rate for an AB dimer breaking up is k B {\displaystyle k_{\mathrm {B} }} .

If at time t there is one molecule of each type then the rate of dimer formation is k D {\displaystyle k_{\mathrm {D} }} , while if there are n A {\displaystyle n_{\mathrm {A} }} molecules of type A and n B {\displaystyle n_{\mathrm {B} }} molecules of type B, the rate of dimer formation is k D n A n B {\displaystyle k_{\mathrm {D} }n_{\mathrm {A} }n_{\mathrm {B} }} . If there are n A B {\displaystyle n_{\mathrm {AB} }} dimers then the rate of dimer dissociation is k B n A B {\displaystyle k_{\mathrm {B} }n_{\mathrm {AB} }} .

The total reaction rate, R T O T {\displaystyle R_{\mathrm {TOT} }} , at time t is then given by

R T O T = k D n A n B + k B n A B {\displaystyle R_{\mathrm {TOT} }=k_{\mathrm {D} }n_{\mathrm {A} }n_{\mathrm {B} }+k_{\mathrm {B} }n_{\mathrm {AB} }}

So, we have now described a simple model with two reactions. This definition is independent of the Gillespie algorithm. We will now describe how to apply the Gillespie algorithm to this system.

In the algorithm, we advance forward in time in two steps: calculating the time to the next reaction, and determining which of the possible reactions the next reaction is. Reactions are assumed to be completely random, so if the reaction rate at a time t is R T O T {\displaystyle R_{\mathrm {TOT} }} , then the time, δt, until the next reaction occurs is a random number drawn from exponential distribution function with mean 1 / R T O T {\displaystyle 1/R_{\mathrm {TOT} }} . Thus, we advance time from t to t + δt.

Plot of the number A molecules (black curve) and AB dimers as a function of time. As we started with 10 A and B molecules at time t=0, the number of B molecules is always equal to the number of A molecules and so it is not shown.

The probability that this reaction is an A molecule binding to a B molecule is simply the fraction of total rate due to this type of reaction, i.e.,

the probability that reaction is P ( A + B AB ) = k D n A n B / R TOT {\displaystyle P({\ce {{A}+ B -> AB}})=k_{D}n_{A}n_{B}/R_{{\ce {TOT}}}}

The probability that the next reaction is an AB dimer dissociating is just 1 minus that. So with these two probabilities we either form a dimer by reducing n A {\displaystyle n_{\mathrm {A} }} and n B {\displaystyle n_{\mathrm {B} }} by one, and increase n A B {\displaystyle n_{\mathrm {AB} }} by one, or we dissociate a dimer and increase n A {\displaystyle n_{\mathrm {A} }} and n B {\displaystyle n_{\mathrm {B} }} by one and decrease n A B {\displaystyle n_{\mathrm {AB} }} by one.

Now we have both advanced time to t + δt, and performed a single reaction. The Gillespie algorithm just repeats these two steps as many times as needed to simulate the system for however long we want (i.e., for as many reactions). The result of a Gillespie simulation that starts with n A = n B = 10 {\displaystyle n_{\mathrm {A} }=n_{\mathrm {B} }=10} and n A B = 0 {\displaystyle n_{\mathrm {AB} }=0} at t=0, and where k D = 2 {\displaystyle k_{\mathrm {D} }=2} and k B = 1 {\displaystyle k_{\mathrm {B} }=1} , is shown at the right. For these parameter values, on average there are 8 n A B {\displaystyle n_{\mathrm {AB} }} dimers and 2 of A and B but due to the small numbers of molecules fluctuations around these values are large. The Gillespie algorithm is often used to study systems where these fluctuations are important.

That was just a simple example, with two reactions. More complex systems with more reactions are handled in the same way. All reaction rates must be calculated at each time step, and one chosen with probability equal to its fractional contribution to the rate. Time is then advanced as in this example.

Stochastic self-assembly

This section needs expansion. You can help by adding to it. (April 2023)

The Gard model describes self-assembly of lipids into aggregates. Using stochastic simulations it shows the emergence of multiple types of aggregates and their evolution.

References

  1. Gillespie, Daniel T. (2007-05-01). "Stochastic Simulation of Chemical Kinetics". Annual Review of Physical Chemistry. 58 (1): 35–55. Bibcode:2007ARPC...58...35G. doi:10.1146/annurev.physchem.58.032806.104637. ISSN 0066-426X. PMID 17037977.

Further reading

Categories: