Skip to content

tekeh/pyross

 
 

Repository files navigation

PyRoss: Infectious disease models in Python Binder

About | Installation | Examples | Publications | News | License | Wiki

Imagel

About

PyRoss is a numerical library for mathematical modelling of infectious disease in Python. The library supports structured compartment models formulated stochastically (as chemical master equations) or deterministically (as systems of differential equations). A hybrid algorithm transits smoothly between these limits depending on the magnitude of the compartmental fluctuations.

The library uses Gaussian process regression, on both the epidemiological manifold and its tangent space, to estimate model parameters given epidemiological data. These estimates are convolved with the instrinsic stochasticty of the dynamics to provide Bayesian forecasts of the progress of the epidemic.

Non-pharmaceutical interventions are implemented as controls on the contact structures of the model. Optimal control of these structures, given cost functions, is currently under development.

The library is designed to be model-agnostic. Currently implemented models are SIR, SEIR, SEI5R, SIkR, SEkIkR, SEAIR, SEAI5R, SEAIRQ, and SIRS.

The library is named after Sir Ronald Ross, doctor, mathematician and poet. In 1898 he made "the great discovery" in his laboratory in Calcutta "that malaria is conveyed by the bite of a mosquito". He won the Nobel Prize in 1902 and laid the foundations of the mathematical modelling of infectious diseases.

The authors are part of The Rapid Assistance in Modelling the Pandemic (RAMP) taskforce at the University of Cambridge. In alphabetical order, we are: Ronojoy Adhikari, Austen Bolitho, Tim Ekeh, Julian Kappler, Irene Li, Patrick Pietzonka, Benjamin Remez, Paul Rohrbach, and Rajesh Singh.

Please read the PyRoss Wiki before you use PyRoss for your research. Open an issue, in preference to emailing us with queries. Issues can be shared with others with similar queries and you help the user community by communicating through issues. Thank you!

  • Coming soon: PyRossGeo, an extension of PyRoss that is spatially resolved and explicitly models commuting networks.

Installation

You can take PyRoss for a spin without installation: Binder. Please be patient while Binder loads.

PyRoss requires the following software

Clone (or download) the repository and use a terminal to install PyRoss (above requirements need to be satisfied)

>> git clone https://github.com/rajeshrinet/pyross.git
>> cd pyross
>> python setup.py install

Alternatively, use anaconda to install PyRoss and its dependencies in a pyross environment

>> git clone https://github.com/rajeshrinet/pyross.git
>> cd pyross
>> make env
>> conda activate pyross
>> make

Pip

pip install -e git+https://github.com/rajeshrinet/pyross.git#egg=pyross

Testing

make test

Age structure data: Population Pyramid website

Contact structure data: Projecting social contact matrices in 152 countries using contact surveys and demographic data, Kiesha Prem, Alex R. Cook, Mark Jit, PLOS Computational Biology, (2017)

Examples

PyRoss has a formulation-agnostic and intuitive interface. Once a model is instantiated, stochastic, deterministic and hybrid simulations can performed through the same interface. The example below shows how to set up a deterministic SIR simulation. See the examples folder for more Jupyter notebook examples.

# Ex1: M=1, SIR
import numpy as np
import pyross

M     = 1                  # the SIR model has no age structure
Ni    = 1000*np.ones(M)    # so there is only one age group
N     = np.sum(Ni)         # and the total population is the size of this age group

beta  = 0.2                # infection rate
gIa   = 0.1                # recovery rate of asymptomatic infectives
gIs   = 0.1                # recovery rate of symptomatic infectives
alpha = 0                  # fraction of asymptomatic infectives
fsa   = 1                  # the self-isolation parameter

Ia0   = np.array([0])      # the SIR model has only one kind of infective
Is0   = np.array([1])      # we take these to be symptomatic
R0    = np.array([0])      # and assume there are no recovered individuals initially
S0    = N-(Ia0+Is0+R0)     # initial susceptibles are obtained from S + Ia + Is + R = N

# there is no contact structure
def contactMatrix(t):   
    return np.identity(M)

# instantiate model
parameters = {'alpha':alpha, 'beta':beta, 'gIa':gIa, 'gIs':gIs, 'fsa':fsa}
model      = pyross.deterministic.SIR(parameters, M, Ni)

# simulate model
Tf, Nt = 160,  160           # duration of simulation and data points
data = model.simulate(S0, Ia0, Is0, contactMatrix, Tf, Nt)

# time series of S, Ia, Is, R
S  = model.S(data)
Ia = model.Ia(data)
Is = model.Is(data)
R  = model.R(data)

Publications

News

License

We believe that openness and sharing improves the practice of science and increases the reach of its benefits. This code is released under the MIT license. Our choice is guided by the excellent article on Licensing for the scientist-programmer.

About

Mathematical modelling of infectious disease in Python - https://github.com/rajeshrinet/pyross

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.7%
  • Other 0.3%