image thumbnail
from SimBiology Tutorial by Asawari Samant
Files used in Online SimBiology Tutorial

ParameterEstimation.m
%% Example of parameter estimation in the Apoptosis model 

% This example shows how to 
% ** Select parameters to match simulation results with experimental data
% ** Estimate the parameters using sbioparamestim

% Copyright 2004-2008 The MathWorks, Inc.

%% Introduction

% The task of explaining experimental behavior with model simulation
% results is inherently complex. Models are built using some fundamental
% concepts, but there are always a lot of assumptions made. Moreover, there
% could be multiple parameters in the model that could affect results in
% different ways. This makes it difficult to decide which parameters should
% be changed and by how much so as not to cause any undesirable side
% effects.

% This example shows how to select the right set of parameters and
% find their values in order to explain some experimental behavior. The
% example uses the Parameter Estimation tool in SimBiology for this task. 
% The model used in this example is a Apoptosis model


%% Load Model

clear all, clc, close all
sbioloadproject final_Apoptosis m1

%% Load and plot the target Data

% We would like to choose parameter values in the model in such a way as to
% match the following experimental results.  

% Read Concentration v/s time data for Casp3* in the tissue compartment 

data_expt=xlsread('Data.xls');
t_span = data_expt(:,1);
Casp3_target = data_expt(:,2);

% Plot the target data.
fh = figure;
plot(t_span, Casp3_target,'o');
grid on;
title('Observed Concentration of Caspase3*');
xlabel('Time (hour)');
ylabel('Concentration ');
lgnd0 ={'Expt Data'};
legend(lgnd0,'Location','Northeast');


%% Simulation using guess values for k5

% Let's simulate the model as is to see how Casp3* level in the model varies with
% time using guess values of k5 

% Select parameters to be tuned
param_to_tune = sbioselect(m1,'Type','parameter','Name','k5');

% Initial guesss for parameters k5
param_init  = 0.0001 ; 
set(param_to_tune, 'Value', param_init);

SimObj1= sbiosimulate(m1);
data_orig = selectbyname(SimObj1,{'Tissue.Casp3*'},'Format','struct');

t_orig = data_orig.Time;
SimData_orig = data_orig.SpeciesData.Data ;

% Let's look at the plot of Casp3* vs. Time.
figure(fh);
hold on;
plot(t_orig, SimData_orig,'-.');
legend('Expt Data','Original','Location','Northeast');

%% Parameter Estimation

% We will use the initial values of parameters in the model as the starting
% values for optimization. We will use the default optimization method
% ( |'lsqcurvefit'| if you have the Optimization Toolbox installed), but we
% will switch on information about iterations in the display to see how
% optimization is progressing.

display(' Performing parameter estimation ...');
opt1.Display = 'iter';
[param_fit, result] = sbioparamestim(m1, t_span, Casp3_target , {'Tissue.Casp3*'},{'k5'},param_init, {'lsqcurvefit',opt1});

%% Simulation Results of Using the Estimated Parameter Value

% Let's use the estimated value of parameter and see how it affects simulation
% results. Before we change the value, we will save it to use it later. 

set(param_to_tune, 'Value', param_fit);

SimObj2 = sbiosimulate(m1);
data_fit = selectbyname(SimObj2,{'Tissue.Casp3*'},'Format','Struct');
t_fit = data_fit.Time;
SimData_fit = data_fit.SpeciesData.Data ;

% Plot the data and compare the simulations with experimental results

figure(fh);
plot(t_fit, SimData_fit, '-');
legend('Expt Data','Original','Fitted','Location','Northeast');



Contact us at files@mathworks.com