Gillespie.jl

Gillespie.jl: Stochastic Simulation Algorithm in Julia - Published in JOSS (2016)

https://github.com/sdwfrost/gillespie.jl

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    1 of 9 committers (11.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.4%) to scientific vocabulary

Keywords from Contributors

graphics

Scientific Fields

Earth and Environmental Sciences Physical Sciences - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

Stochastic Gillespie-type simulations using Julia

Basic Info
  • Host: GitHub
  • Owner: sdwfrost
  • License: other
  • Language: Jupyter Notebook
  • Default Branch: master
  • Homepage:
  • Size: 1.68 MB
Statistics
  • Stars: 64
  • Watchers: 4
  • Forks: 24
  • Open Issues: 6
  • Releases: 2
Created over 11 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Codemeta

README.md

Gillespie.jl

Build Status Coverage Status Gillespie Gillespie Stories in Ready status DOI

Throughput Graph

Statement of need

This is an implementation of Gillespie's direct method as well as uniformization/Jensen's method for performing stochastic simulations, which are widely used in many fields, including systems biology and epidemiology. It borrows the basic interface (although none of the code) from the R library GillespieSSA by Mario Pineda-Krch, although Gillespie.jl only implements exact methods at present, whereas GillespieSSA also includes tau-leaping, etc.. It is intended to offer performance on par with hand-coded C code; please file an issue if you find an example that is significantly slower (2 to 5 times) than C.

Installation

The stable release of Gillespie.jl can be installed from the Julia REPL using the following command.

julia using Pkg Pkg.add("Gillespie")

The development version from this repository can be installed as follows.

julia Pkg.add("https://github.com/sdwfrost/Gillespie.jl")

Example usage

An example of a susceptible-infected-recovered (SIR) epidemiological model is as follows.

```julia using Gillespie using Gadfly using Random

function F(x,parms) (S,I,R) = x (beta,gamma) = parms infection = betaSI recovery = gamma*I [infection,recovery] end

x0 = [999,1,0] nu = [[-1 1 0];[0 -1 1]] parms = [0.1/1000.0,0.01] tf = 250.0 Random.seed!(1234)

result = ssa(x0,F,nu,parms,tf)

data = ssa_data(result)

plottheme = Theme( panelfill=colorant"white", defaultcolor=colorant"black" ) p=plot(data, layer(x=:time,y=:x1,Geom.step,Theme(defaultcolor=colorant"red")), layer(x=:time,y=:x2,Geom.step,Theme(defaultcolor=colorant"orange")), layer(x=:time,y=:x3,Geom.step,Theme(defaultcolor=colorant"blue")), Guide.xlabel("Time"), Guide.ylabel("Number"), Guide.title("SSA simulation"), Guide.manualcolorkey("Subpopulation",["S","I","R"],["red","orange","blue"]), plot_theme ) ```

SIR

Julia versions of the examples used in GillespieSSA are given in the examples directory.

Jensen's method or uniformization

The development version of Gillespie.jl includes code to simulate via uniformization (a.k.a. Jensen's method); the API is the same as for the SSA, with the addition of max_rate, the maximum rate (Float64). Optionally, another argument, thin (Bool), can be set to false to return all the jumps (including the fictitious ones), and saves a bit of time by pre-allocating the time vector. This code is under development at present, and may change. Time-varying rates can be accommodated by passing a rate function with three arguments, F(x,parms,t), where x is the discrete state, parms are the parameters, and t is the simulation time.

The true jump method

The development version of Gillespie.jl also includes code to simulate assuming time-varying rates via the true jump method; the API is the same as for the SSA, with the exception that the rate function must have three arguments, as described above.

Benchmarks

The speed of an SIR model in Gillespie.jl was compared to:

  • A version using the R package GillespieSSA
  • Handcoded versions of the SIR model in Julia, R, and Rcpp
  • DifferentialEquations.jl's jump interface.

1000 simulations were performed, and the time per simulation computed (lower is better). Benchmarks were run on a Mac Pro (Late 2013), with 3 Ghz 8-core Intel Xeon E3, 64GB 1866 Mhz RAM, running OSX v 10.11.3 (El Capitan), using Julia v0.4.5 and R v.3.3. Jupyter notebooks for Julia and R with the code and benchmarks are available as gists. A plain Julia file is also provided in the benchmarks subdirectory for ease of benchmarking locally.

| Implementation | Time per simulation (ms) | | -------------------------------------------| ------------------------ | | R (GillespieSSA) | 463 | | R (handcoded) | 785 | | Rcpp (handcoded) | 1.40 | | Julia (Gillespie.jl) | 1.69 | | Julia (Gillespie.jl, Static) | 0.89 | | Julia (DifferentialEquations.jl) | 1.14 | | Julia (DifferentialEquations.jl, Static) | 0.72 | | Julia (handcoded) | 0.49 |

(smaller is better)

Julia performance for Gillespie.jl is much better than GillespieSSA, and close to a handcoded version in Julia (which is itself comparable to Rcpp); as compiler performance improves, the gap in performance should narrow.

Future work

Gillespie.jl is under development, and pull requests are welcome. Future enhancements include:

  • Constrained simulations (where events are forced to occur at specific times)
  • Discrete time simulation

Citation

If you use Gillespie.jl in a publication, please cite the following.

  • Frost, Simon D.W. (2016) Gillespie.jl: Stochastic Simulation Algorithm in Julia. Journal of Open Source Software 1(3) doi:0.21105/joss.00042

A Bibtex entry can be found here.

Owner

  • Name: Simon Frost
  • Login: sdwfrost
  • Kind: user
  • Location: Redmond, WA, USA
  • Company: Microsoft

Principal Data Scientist, Microsoft Health; Professor of Pathogen Dynamics, LSHTM

CodeMeta (codemeta.json)

{
  "@context": "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld",
  "@type": "Code",
  "author": [
    {
      "@id": "http://orcid.org/0000-0002-5207-9879",
      "@type": "Person",
      "email": "sdwfrost@gmail.com",
      "name": "Simon Frost",
      "affiliation": "University of Cambridge"
    }
  ],
  "identifier": "http://dx.doi.org/10.5281/zenodo.59127",
  "codeRepository": "http://github.com/sdwfrost/Gillespie.jl",
  "datePublished": "2016-07-18",
  "dateModified": "2016-07-18",
  "dateCreated": "2016-07-18",
  "description": "Stochastic simulation algorithm in Julia",
  "keywords": "Julia, stochastic simulation, Doob-Gillespie algorithm",
  "license": "MIT",
  "title": "Gillespie.jl",
  "version": "v0.0.1"
}

GitHub Events

Total
  • Watch event: 3
Last Year
  • Watch event: 3

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 114
  • Total Committers: 9
  • Avg Commits per committer: 12.667
  • Development Distribution Score (DDS): 0.14
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Simon Frost s****t@g****m 98
Alex Arslan a****n@c****t 6
Chris Rackauckas a****s@c****m 4
Volker Weißmann v****n@g****e 1
Making GitHub Delicious i****n@w****o 1
Benoît Richard k****u@h****m 1
Arfon Smith a****n 1
mcfefa m****s@m****g 1
J-Revell j****1@n****k 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 13
  • Total pull requests: 10
  • Average time to close issues: 5 months
  • Average time to close pull requests: about 3 hours
  • Total issue authors: 11
  • Total pull request authors: 9
  • Average comments per issue: 1.54
  • Average comments per pull request: 2.2
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ChrisRackauckas (2)
  • sdwfrost (2)
  • Vilin97 (1)
  • KristofferC (1)
  • gothub (1)
  • rsrock (1)
  • ararslan (1)
  • konkam (1)
  • pagnani (1)
  • robertfeldt (1)
Pull Request Authors
  • ChrisRackauckas (2)
  • jeetsukumaran (2)
  • waffle-iron (1)
  • Kolaru (1)
  • arfon (1)
  • ararslan (1)
  • Volker-Weissmann (1)
  • J-Revell (1)
  • mcfefa (1)
Top Labels
Issue Labels
Pull Request Labels