Version 1.1

User's Reference

In the following all functions contained in the full SBaddon package are documented.

MEX Simulation Function - Overview

MEX Simulation FunctionThe SBaddon package creates and uses MEX simulation functions. These functions are compiled C-code versions of SBmodels linked together with the CVODE integrator and a MATLAB interface. In this way a simulation performance of stand-alone software applications is obtained, while still keeping MATLABs flexibility in handling the returned simulation data and the models. Additionally these functions allow to perform parameter sensitivity analysis.

Functions - Overview

Installation of SBaddon
 
installSBAOInstallation script for the SBaddon package.
 
MEX Simulation Function Creation
 
SBAOcreateMEXmodelCreating a MEX simulation function for a given SBmodel.
SBAOcreateTempMEXmodelCreating a temporary MEX simulation function for a given SBmodel (in systems temp folder).
SBAOcompileMEXmodelCompilation of a given C model function to a MEX simulation function.
 
Simulation Functions
SBAOsimulateWrapper function for simulation of MEX models and SBmodels.
SBAOsenssimWrapper function for sensitivity analysis (parameters only) of MEX models and SBmodels.
 
Parameter Identifiability
SBAOparamcorrFunction for determining parameter correlations based on parametric sensitivities.
 
 
Other Functions
createparametervectorSBAOCreating full parameter vector and changing given parameters to given new values.
createicvectorSBAOCreating full initial condition vector and changing given states to given new values.
getparameterindicesSBAOGet parameter indices for given parameter names.
getstateindicesSBAOGet state indices for given state names.
 

MEX Simulation Function - Full Description

MEX simulation functions, created by the SBaddon package, have the following calling syntax and functionality. 'filename' relates to the name of a MEX simulation function.

output = filename(): returns a vector with the models initial conditions
output = filename('states'): returns a cell array with the models state names
output = filename('parameters'): returns a cell array with the models parameter names
output = filename('parametervalues'): a returns a vector with the models parameter values

The following calls to a MEX simulation function perform simulation of the corresponding model and return the obtained data as a MATLAB structure:

output = filename(timevector)
output = filename(timevector, initialconditions)
output = filename(timevector, initialconditions, parametervector)
output = filename(timevector, initialconditions, parametervector, options)

timevector: Vector of time instants for which simulation data is to be returned
initialconditions: Vector of initial conditions
parametervector: Vector containing a full set of parameter values that are to be used instead of the nominal parameters, stored in the model
options: Structure with options for the integrator. The available fields of this structure and their possible settings are described below. If a certain field is not present in the options structure, default values are used instead for the corresponding setting.
options.abstol: Absolute tolerance (default: 1e-6)
options.reltol: Relative tolerance (default: 1e-6)
options.minstep: Minimal integrator step size (default: 0)
options.maxstep: Maximal integrator step size (default: inf)
options.maxnumsteps: maximum number of steps to be taken by the solver in its attempt to reach the next output time (default: 500)
options.method: String indicating intergration method. 'stiff' or 'nonstiff' (default: 'stiff')
options.simdata: String indicating if only state values are to be calculated or even variabled and reaction rates. 'states' or 'all' (default: 'states')
options.outputfunction: Name of a M- or MEX function to call after each integration step. The defined function needs to exist in the MATLAB path (is checked) and have four input arguments: outputfunction(time, statevalues, variablevalues, reactionvalues)

Sensitivity analysis related options:

options.sensitivity: String indicating if sensitivity analysis is to be performed: 'yes' or 'no' (default: 'no')
options.sensparams: Vector containing parameter indices of the parameters to use for sensitivity computations. (default: if this field is not present, all parameters are used).
options.sensparamscaling: Vector containing scalings for the given parameters (default: scaling each parameter by 1).
options.sensstates: Vector containing indices of the states for whos initial conditions the sensitivities are to be computed. (default: if this field is not present, initial conditions for all states are considered).
options.senstype: String determining the method to use for the forward sensitivity analysis: 'simultaneous', 'staggered', 'staggered1'. For more information please read the CVODES users manual. (default: 'simultaneous')
options.senserror: String determining the error control method for integration: 'full' or 'partial'. (default: 'partial'). For more information please read the CVODES users manual.

Event handling: If events are present in the model and they are fired during simulation the output data structure contains information about the time instants at which the events fired. For each such time instant it is also specified which event has fired (important in the case of more than one event in the model).

If several events are fired at the same time the event assignments are executed based on the same statevector, present at the time at which the events happened.

Important: If events are present in the model do not use to large timesteps in the timevector.

Functions - Full Description and Examples

Installation of SBaddon

installSBAO
Usage Run this script from within the SBADDON folder to install the package. The script contents do not need to be edited by the user.
Examples >> installSBAO

Clears the workspace and the desktop, closes all open figures, and sets the paths needed for the package.

MEX Simulation Function Creation

SBAOcreateMEXmodel(input)
Usage Creates a MEX simulation functions for a given SBmodel, or if desired only the C source code for the given SBmodel.

input=[sbm, filename]
input=[sbm, filename, sourceflag]

sbm: SBmodel
filename: The name of the executable MEX file to be created
sourceflag: =0: create an executable MEX file (default setting), =1: create model source files without compilation

Examples As example we create a MEX simulation file for the Novak Tyson Cell-Cycle model. Please change into the SBADDON/examples folder and type:

>> model = SBmodel('NovakTysonModel.txt');
>> SBAOcreateMEXmodel(model,'novaktysonsim');

The last command creates a MEX file with the name 'novaktysonsim'. To learn more about the input and output arguments please read the section "MEX Simulation Function - Full Description" above. Here we are simply running a simple simulation over 400 time units and plot the results.

>> simdata = novaktysonsim([0:1:400])
>> plot(simdata.time,simdata.statevalues);
>> legend(simdata.states);

The SBAOcreateMEXmodel function can also be used to create the C-code for the model without compiling it to a MEX simulation function:

>> model = SBmodel('NovakTysonModel.txt');
>> sourceflag = 1;
>> SBAOcreateMEXmodel(model,'novaktysonsim',sourceflag);

The last command creates a .c and a .h file. You can look at these files to get an idea about how you could write your own C-code models (if so wanted). When specifying a model as .c and .h files you can use the command SBAOcompileMEXmodel to create a MEX simulation function for this model.

SBAOcreateTempMEXmodel(input)
Usage Creates a temporary MEX simulation function for a given SBmodel, same as SBAOcreateMEXmodel, but the MEX file is written in the systems temporary directory. No filename is passed, but a temporary functionname is chosen automatically and returned back as output argument. Since the function also includes the path to the systems temporary directory in the MATLAB path the returned functionnames can be used directly.

input=[sbm]

sbm: SBmodel

output = [MEXmodel, MEXmodelfullpath]

MEXmodel: name of the function (filename without .m extension)
MEXmodelfullpath: complete path to the created ODE file (including mex extension). This can be used for deleting the temporary file after its use.

Examples

SBAOcompileMEXmodel(input)
Usage Creates a MEX simulation function for a given C-model.

input=[filename]

filename: Name of the model files (filename.c and filename.h) that are to be compiled and linked with CVODE.

Examples First we create a C-model. For this change into the SBADDON/examples folder and type:

>> model = SBmodel('BIOMD14.xml');
>> sourceflag = 1;
>> SBAOcreateMEXmodel(model,'Cmodel',sourceflag);

The last command creates a Cmodel.c and a Cmodel.h file. By looking at the contents of these files you can get an idea about how to write your own C-model files (if so wanted). The compilation of these files into a MEX simulation function is done by typing:

>> SBAOcompileMEXmodel('Cmodel')

The model can now be simulated by typing:

>> timevector = [0:1:300];
>> simdata = Cmodel(timevector)
>> plot(simdata.time,simdata.statevalues)

Simulation Functions

output = SBAOsimulate(input)
Usage This is a wrapper function for MEX simulation functions allowing a nicer handling of the simulation files. Additionally it can be used to simulate SBmodel.

IMPORTANT: Please note that simulating SBmodels using SBAOsimulate
     produces unnecessary conversion overhead. Using SBAOsimulate
     on MEXmodels is MUCH faster. This is especially important in
     the case of parameter estimation where the same model is
     simulated many times for different parameter sets / initial
     conditions.

input=[model]
input=[model, time]
input=[model, time, initialconditions]
input=[model, time, initialconditions, parameternames, parametervalues]
input=[model, time, initialconditions, parameternames, parametervalues, options]

model: Name of MEX simulation function or SBmodel (SBmodels will be converted to MEXmodels prior to simulation).
time: Scalar value for simulation end time (default: start time is 0 and end time 20, 1000 time steps are used), or a vector of time steps at which to return the simulation data.
initialconditions: Vector of initial conditions (Empty vector leads to the use of nominal initial conditions stored in the model).
parameternames: Cellarray containing the names of the parameters that are to be set to non default values (Empty cellarray leads to the use of nominal parameter values stored in the model).
parametervalues: Vector containing the values for the above defined parameters (Empty vector leads to the use of nominal parameter values stored in the model).
options: structure with options for the integrator.
options.abstol: absolute tolerance (default: 1e-6)
options.reltol: relative tolerance (default: 1e-6)
options.minstep: minimal integrator step size (default: 0)
options.maxstep: maximal integrator step size (default: inf)
options.maxnumsteps: maximum number of steps to be taken by the solver in its attempt to reach the next output time (default: 500)
options.method: string indicating intergration method. 'stiff' or 'nonstiff' (default: 'stiff')
options.simdata: string indicating if only state values are to be calculated or even variabled and reaction rates. 'states' or 'all' (default: 'all')
options.outputfunction: Name of a M- or MEX function to call after each integration step. The defined function needs to exist in the MATLAB path (is checked) and have four input arguments: outputfunction(time, statevalues, variablevalues, reactionvalues)

If no output arguments are given, the result of the simulation is plotted after finished simulation. Otherwise the output is the same MATLAB structure as returned when running the MEX simulation function without the SBAOsimulate wrapper.

Examples Please change into the SBADDON/examples folder and type:

>> model = SBmodel('eventExample.txt');
>> SBAOcreateMEXmodel(model,'test');
>> options.method = 'nonstiff';
>> simdata = SBAOsimulate('test',[],[],{},[],options)
>> plot(simdata.time,simdata.statevalues)

Please have a look at the simdata output of the simulation. The structure contains also information about the times at which events in the model fired and in the case that several events are present which event fired at what time.

If you want to redo a simulation for a different parameter setting you do not need to edit the SBmodel and create the MEX simulation function again. You can instead specify the name of the parameters you want to change and the new values:

>> time = 40;
>> inicond = []; % use nominal initial conditions
>> parameters = {'k1'} % change parameter k1
>> paravalues = [0.1]; % to the value of 0.1 (nominal is 1)
>> simdata = SBAOsimulate('test',time,inicond,parameters, paravalues, options)
>> plot(simdata.time,simdata.statevalues);

output = SBAOsenssim(input)
Usage This is a wrapper function for MEX simulation functions for forward sensitivity analysis (parameters and initialconditions). Alternatively the sensitivity analysis can be directly performed using the MEX simulation function but this wrapper allows a nicer handling of the input arguments. Additionally the function can be used directly on SBmodels.

input=[model, time]
input=[model, time, parameternames]
input=[model, time, parameternames, statenames]
input=[model, time, parameternames, statenames, parameterscalings]
input=[model, time, parameternames, statenames, parameterscalings, options]

model: Name of MEX simulation function or SBmodel (SBmodels will be converted to MEXmodels prior to simulation).
time: Scalar value for simulation end time (default: start time is 0 and end time 20, 1000 time steps are used), or a vector of time steps at which to return the simulation data.
parameternames: Cellarray containing the names of the parameters that are to be considered for sensitivity analysis. (default: all parameters in the model).
statenames: Cellarray containing the names of the states whos initial conditions are to be considered for sensitivity analysis. (default: all states in the model).
parameterscalings: A vector containing scalings for the given parameters.
options: structure with options for the integrator.
options.senstype: string determining the type of forward sensitivity analysis: 'simultaneous', 'staggered', or 'staggered1'
options.senserror: string determining the type of error control during integration: 'full' or 'partial'
options.abstol: absolute tolerance (default: 1e-6)
options.reltol: relative tolerance (default: 1e-6)
options.minstep: minimal integrator step size (default: 0)
options.maxstep: maximal integrator step size (default: inf)
options.maxnumsteps: maximum number of steps to be taken by the solver in its attempt to reach the next output time (default: 500)
options.method: string indicating intergration method. 'stiff' or 'nonstiff' (default: 'stiff')
options.simdata: string indicating if only state values are to be calculated or even variabled and reaction rates. 'states' or 'all' (default: 'all')
options.outputfunction: Name of a M- or MEX function to call after each integration step. The defined function needs to exist in the MATLAB path (is checked) and have four input arguments: outputfunction(time, statevalues, variablevalues, reactionvalues)

If no output arguments are given, the result of the simulation is plotted after finished simulation (only states, variables, reactions). The sensitivities are not plotted.

Examples Please change into the SBADDON/examples folder and type:

>> model = SBmodel('NovakTysonModel.txt');
>> SBAOcreateMEXmodel(model,'test');
>> senssimdata = SBAOsenssim('test',400)

Please have a look at the senssimdata output of the simulation. The field 'senssimdata.sensparameters' contains a cell array with the names of the parameters for which the sensitivities have been computed. The field 'sensimdata.sensparamtrajectories' contains a cell array where each element contains the sensitivity trajectories for the correponding parameter in the 'senssimdata.sensparameters' array (same order). (Same for initial condition sensitivities in the fields: 'senssimdata.sensicstates' and 'sensimdata.sensicstatetrajectories').

To plot the sensitivities of the state variables wrt to the first parameter, type:

>> dSdP1 = senssimdata.sensparamtrajectories{1};
>> plot(senssimdata.time,dSdP1);
>> legend(senssimdata.states);

Parameter Identifiability

output = SBAOparamcorr(input)
Usage Function for determining parameter correlations based on parametric sensitivities. The result can be used to check a priori identifiability of parameters for given experimental settings. Several experiments can be combined.

The method is based on:
Jacques, J.A. and Greif, P. (1985) Numerical parameter identifiablity
and estimability: Integrating identifiability, estimability, and
optimal sampling design, Mathematical Biosciences, 77, pp. 201-227

This function determines correlations between parameters. The inputs to this function are parameter sensitivity trajectories returned from the SBAOsenssim function, reflecting the sensitivity of the state variables to parameter changes during user-defined experiments. From this information a parameter correlation matrix is determined. Off-diagonal elements in this matrix that are close to +1 or -1 indicate problems in identifying the corresponding parameters independently. Elements that are close to zero indicate that there is no important correlation between the corresponding elements and thus these parameters should be identifiable independently without problem (for the defined experiments).

A priori identifiability: The identifiability is a local property. For different sets of parameter values different correlation matrices can be obtained. Since unknown parameters are, by definition, unknown this might lead to problems interpreting the results. However, one possible approach is to run the identifiability analysis for different sets of parameter values, randomly chosen in certain intervals around a best initial guess.

input = [senssimdata1]
input = [senssimdata1,options]
input = [senssimdata1,senssimdata2]
input = [senssimdata1,senssimdata2,options]
input = [senssimdata1,senssimdata2,...]
input = [senssimdata1,senssimdata2,...,options]

senssimdata1...n: Output argument from the sensitivity analysis function SBAOsenssim. The simulation should reflect (wrt, e.g., sampling time, stimuli) the experiments that are planned to obtain measurement data for the parameter estimation.
options: Structure, defining the states that are considered to be measurements and the parameters that need to be identified. The structure is defined as follows:
options.parameters: cell-array with parameter names
options.measuredstates: cell-array with state names

When called without an output argument the parameter correlation matrix is graphically represented. For easier graphical interpretation the absolute values of the matrix elements are taken. White color indicates a perfect correlation and black color indicates no correlation between parameters. If an output argument is given, the results are returned as a MATLAB structure as follows:
output.parameters: cell-array with parameter names
output.measuredstates: cell-array with names of states that are measured
output.correlationMatrix: parameter correlation matrix

Examples

Other Functions

output = createparametervectorSBAO(input)
Usage This function can be used to create a full parameter vector for the given model representation (SBmodel, MEX simulation function, or ODE file model), where only the specified parameters are set to given values. All other parameters remain unchanged.

This is a useful function, since the MEX simulation functions expect a parameter vector containing values for all parameters in the model.

input=[model,parameternames,parametervalues]

model: SBmodel, ODE file model, or MEX file model
parameternames: Cell-array of parameter names
parametervalues: Vector of correspondnig parameter values

The output is a vector containing all parameter values of the given model, where the specified parameters are set to the specified values. The remaining values are the nominal values stored in the given model.

Examples Please change into the SBADDON/examples folder. We first create a MEX simulation function and simulate it using the default parameters.

>> model = SBmodel('Glycolysis.txt');
>> SBAOcreateMEXmodel(model,'test');
>> simdata = test([0:0.1:20]);
>> plot(simdata.time,simdata.statevalues);

Now we want to change the parameter Glcx0 to 10 and simulate again. This does not require rebuilding the MEX simulation function, but instead you can type:

>> parametervector = createparametervectorSBAO('test',{'Glcx0'},[10]);
>> simdata = test([0:0.1:20],[],parametervector);
>> plot(simdata.time,simdata.statevalues);

You can also change several parameters at a time by specifying several names in the cell array and corresponding values in the vector.

output = createicvectorSBAO(input)
Usage This function can be used to create a full initial condition vector for the given model representation (SBmodel, MEX simulation function, or ODE file model), where only the specified states are set to given values. All other states remain unchanged.

This is a useful function, since the MEX simulation functions expect an initial condition vector containing values for all states in the model.

input=[model,statenames,statevalues]

model: SBmodel, ODE file model, or MEX file model
statenames: Cell-array of state names
statevalues: Vector of correspondnig initial values

The output is a vector containing all initial conditions of the given model, where the specified states are set to the specified values. The remaining values are the nominal values stored in the given model.

Examples This function should be self explaining and does not need any example.

output = getparameterindicesSBAO(input)
Usage Returns a vector containing the indices of the given parameters.

input=[model,parameternames]

model: SBmodel, ODE file model, or MEX file model
parameternames: Cell-array of parameter names

The output is a vector containing the indices of the given parameters as they appear in the model.

Examples This function should be self explaining and does not need any example.

output = getstateindicesSBAO(input)
Usage Returns a vector containing the indices of the given states.

input=[model,statenames]

model: SBmodel, ODE file model, or MEX file model
statenames: Cell-array of state names

The output is a vector containing the indices of the given states as they appear in the model.

Examples This function should be self explaining and does not need any example.