Learn R Programming

GillespieSSA: Gillespie’s Stochastic Simulation Algorithm (SSA)

GillespieSSA provides a simple to use, intuitive, and extensible interface to several stochastic simulation algorithms for generating simulated trajectories of finite population continuous-time model. Currently it implements Gillespie’s exact stochastic simulation algorithm (Direct method) and several approximate methods (Explicit tau-leap, Binomial tau-leap, and Optimized tau-leap).

The package also contains a library of template models that can be run as demo models and can easily be customized and extended. Currently the following models are included, decaying-dimerization reaction set, linear chain system, logistic growth model, Lotka predator-prey model, Rosenzweig-MacArthur predator-prey model, Kermack-McKendrick SIR model, and a metapopulation SIRS model.

Install

You can install GillespieSSA from CRAN using

install.packages("GillespieSSA")

Or, alternatively, you can install the development version of GillespieSSA from GitHub using

devtools::install_github("rcannood/GillespieSSA", build_vignettes = TRUE)

Examples

The following example models are available:

  • Decaying-Dimerization Reaction Set (Gillespie, 2001): vignette("decaying_dimer", package="GillespieSSA")
  • SIRS metapopulation model (Pineda-Krch, 2008): vignette("epi_chain", package="GillespieSSA")
  • Linear Chain System (Cao et al., 2004): vignette("linear_chain", package="GillespieSSA")
  • Pearl-Verhulst Logistic growth model (Kot, 2001): vignette("logistic_growth", package="GillespieSSA")
  • Lotka predator-prey model (Gillespie, 1977; Kot, 2001): vignette("lotka_predator_prey", package="GillespieSSA")
  • Radioactive decay model (Gillespie, 1977): vignette("radioactive_decay", package="GillespieSSA")
  • Rosenzweig-MacArthur predator-prey model (Pineda-Krch et al., 2007): vignette("rm_predator_prey", package="GillespieSSA")
  • Kermack-McKendrick SIR model (Brown & Rothery, 1993): vignette("sir", package="GillespieSSA")

Latest changes

Check out news(package = "GillespieSSA") or NEWS.md for a full list of changes.

Recent changes in GillespieSSA 0.6.2

  • MINOR CHANGE: Allow using .t as parameter in the propensity functions.

Recent changes in GillespieSSA 0.6.1

This release contains a major rewrite of the internal code, to make sure the code is readable and that the algorithm doesn’t continuously update the local environment.

  • MAJOR CHANGE: Instead of passing "D", "ETL", "OTL", or "BTL" to ssa(), it is expected to pass ssa.d(), ssa.etl(), ssa.otl(), or ssa.btl(). This cleans up parameter setting clutter in the ssa() function.

  • MAJOR CHANGE: Rewrite ssa.*() and ssa.*.diag() as ssa_step.ssa_*() and ssa_step_diag.ssa_*() S3 functions.

  • MAJOR CHANGE: Do not save the current state in the function environment. Instead, simply save it in a local variable.

  • MAJOR CHANGE: Precompile propensity functions instead of evaluating them as R code at each iteration.

  • MAJOR CHANGE: Clean up and merge ssa.run(), ssa.terminate(), ssa.check.args() and ssa.check.method() into ssa().

References

  • Brown D. and Rothery P. 1993. Models in biology: mathematics, statistics, and computing. John Wiley & Sons.
  • Cao Y., Li H., and Petzold L. 2004. Efficient formulation of the stochastic simulation algorithm for chemically reacting systems. J. Chem. Phys. 121:4059-4067. doi:10.1063/1.1778376
  • Cao Y., Gillespie D.T., and Petzold L.R. 2006. Efficient step size selection for the tau-leaping method. J. Chem. Phys. 124:044109. doi:10.1063/1.2159468
  • Cao Y., Gillespie D.T., and Petzold L.R. 2007. Adaptive explicit tau-leap method with automatic tau selection. J. Chem. Phys. 126:224101. doi:10.1063/1.2745299
  • Chatterjee A., Vlachos D.G., and Katsoulakis M.A. 2005. Binomial distribution based tau-leap accelerated stochastic simulation. J. Chem. Phys. 122:024112. doi:10.1063/1.1833357
  • Gillespie D.T. 1977. Exact stochastic simulation of coupled chemical reactions. J. Phys. Chem. 81:2340. doi:10.1021/j100540a008
  • Gillespie D.T. 2001. Approximate accelerated stochastic simulation of chemically reacting systems. J. Chem. Phys. 115:1716-1733. doi:10.1063/1.1378322
  • Gillespie D.T. 2007. Stochastic simulation of chemical kinetics. Annu. Rev. Chem. 58:35 doi:10.1146/annurev.physchem.58.032806.104637
  • Kot M. 2001. Elements of mathematical ecology. Cambridge University Press. doi:10.1017/CBO9780511608520
  • Pineda-Krch M. 2008. Implementing the stochastic simulation algorithm in R. Journal of Statistical Software 25(12): 1-18. doi: 10.18637/jss.v025.i12
  • Pineda-Krch M., Blok H.J., Dieckmann U., and Doebeli M. 2007. A tale of two cycles — distinguishing quasi-cycles and limit cycles in finite predator-prey populations. Oikos 116:53-64. doi:10.1111/j.2006.0030-1299.14940.x

Copy Link

Version

Install

install.packages('GillespieSSA')

Monthly Downloads

354

Version

0.6.2

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Last Published

March 10th, 2022

Functions in GillespieSSA (0.6.2)

ssa.etl

Explicit tau-leap method (ETL)
ssa.btl

Binomial tau-leap method (BTL)
ssa.otl

Optimized tau-leap method (OTL)
ssa.plot

Simple plotting of ssa output
GillespieSSA-package

Gillespie Stochastic Simulation Algorithm package
ssa.d

Direct method (D)
ssa

Invoking the stochastic simulation algorithm