GithubHelp home page GithubHelp logo

bistrulli / gillespie Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nvictus/gillespie

0.0 1.0 0.0 49 KB

Gillespie Stochastic Simulation Algorithm

License: BSD 2-Clause "Simplified" License

MATLAB 69.63% Python 30.37%

gillespie's Introduction

Gillespie

Gillespie Stochastic Simulation Algorithm

The two classic versions of the algorithm implemented in MATLAB:

  • The direct method
  • The first-reaction method

Get it on the File Exchange!

Example model

Simulation output

Consider the following two-state model of the expression of a single gene.

Reaction network:
    1. transcription:       0       --kR--> mRNA
    2. translation:         mRNA    --kP--> mRNA + protein
    3. mRNA decay:          mRNA    --gR--> 0
    4. protein decay:       protein --gP--> 0

1. Provide the time interval and the initial state of the system.

tspan = [0, 10000]; %seconds
x0    = [0, 0];     %mRNA, protein

2. Provide a stoichiometry matrix for your system. Each row of the stoichiometry matrix gives the stoichiometry of a reaction in the network.

stoich_matrix = [ 1  0    %transcription
                  0  1    %translation
                 -1  0    %mRNA decay
                  0 -1 ]; %protein decay

3. Provide a propensity function.

pfun = @propensities_2state;

The solver calculates reaction propensities using a user-defined function. The inputs to this function are:

  • x: the state system at current time
  • p: reaction rate constants

The order of the elements in the returned vector a should match the order of reactions in the stoichiometry matrix.

function a = propensities_2state(x, p)
% Return reaction propensities given current state x
mRNA    = x(1);
protein = x(2);

a = [p.kR           %transcription
     p.kP*mRNA      %translation
     p.gR*mRNA      %mRNA decay
     p.gP*protein]; %protein decay
end

4. Optionally, provide a set of rate constants to pass to the propensity function. Here, we define the rate constants as a struct:

p.kR = 0.1;    %molecules/sec
p.kP = 0.1;    %sec^-1                    
p.gR = 0.1;    %sec^-1                         
p.gP = 0.002;  %sec^-1

5. Run the solver!

[t,x] = directMethod(stoich_matrix, pfun, tspan, x0, p);

gillespie's People

Contributors

nvictus avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.