Information about the application

A MATLAB application from the field of systems biology was chosen for experimental runs. The application was created using SimBiology® which extends MATLAB® with functionality for modeling, simulating, and analyzing biochemical pathways.

The application allows a user to model and simulate the dynamics of a simple gene regulation network, and understand the effect of stochasticity on the final state of the system. A ensemble of stochastic runs were performed on a gene-regulation model, and the distribution of state was studied at any given time point. Several hundred thousand simulations might need to be performed to obtain a smooth probability distribution function, requiring several days of computation on one MATLAB.

% The model used in this script was adpated from the following publication :
% Kepler TB, Elston TC. Stochasticity in transcriptional regulation:
% Origins, consequences and % mathematical representations. Biophys J.
% 2001;81:3116–3136.

Serial version of the code

Clear any old variables

clear all

Define simulation settings

% Total number of runs
numberOfRuns = 20;

% Load SimBiology model
sbioloadproject GeneRegulation m1

% Pre-allocate memory
data   = zeros(numberOfRuns, numel(m1.Species));

Running an ensemble of stochastic simulations


for i = 1:numberOfRuns
    data(i, :) =  simulation;

elapsedTimeSerial = toc;
elapsedTimeSerial =

Parallel version of the code

Open matlabpool using default configuration

if matlabpool('size') == 0
    matlabpool open 2
    warning('MATLAB:poolOpen', 'matlabpool already open')
Starting matlabpool using the parallel configuration 'local'.
Waiting for parallel job to start...
Connected to a matlabpool session with 2 labs.

Define simulation settings

% Pre-allocate memory
dataParfor   = zeros(numberOfRuns, numel(m1.Species));

Running an ensemble of stochastic simulations


% "for" changed to a "parfor" to run in parallel
parfor i = 1:numberOfRuns
    dataParfor(i, :) =  simulation;

elapsedTimeParallel = toc;
elapsedTimeParallel =

Collect and plot results from parfor

title('Histogram of protein state at t = 1000 s')
xlabel('Protein State')

Calculating speedup

speedUp = elapsedTimeSerial/elapsedTimeParallel;
fprintf('Using: %d-Workers, Speedup: %.2f\n', matlabpool('size'), speedUp);
Using: 2-Workers, Speedup: 1.75

Closing the matlabpool

if matlabpool('size') ~= 0
    matlabpool close
    warning('MATLAB:poolClose', 'matlabpool already closed')
Sending a stop signal to all the labs...
Waiting for parallel job to finish...
Performing parallel job cleanup...