User's Reference
In the following all functions contained in the full SBaddon package are documented.
MEX Simulation Function - Overview
| MEX Simulation Function | The 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 | |
|---|---|
| installSBAO | Installation script for the SBaddon package. |
| MEX Simulation Function Creation | |
| SBAOcreateMEXmodel | Creating a MEX simulation function for a given SBmodel. |
| SBAOcreateTempMEXmodel | Creating a temporary MEX simulation function for a given SBmodel (in systems temp folder). |
| SBAOcompileMEXmodel | Compilation of a given C model function to a MEX simulation function. |
| Simulation Functions | |
| SBAOsimulate | Wrapper function for simulation of MEX models and SBmodels. |
| SBAOsenssim | Wrapper function for sensitivity analysis (parameters only) of MEX models and SBmodels. |
| Parameter Identifiability | |
| SBAOparamcorr | Function for determining parameter correlations based on parametric sensitivities. |
| Other Functions | |
| createparametervectorSBAO | Creating full parameter vector and changing given parameters to given new values. |
| createicvectorSBAO | Creating full initial condition vector and changing given states to given new values. |
| getparameterindicesSBAO | Get parameter indices for given parameter names. |
| getstateindicesSBAO | Get 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]
sbm: SBmodel |
| 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'); 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]) 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'); 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) |
| 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'); 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]; |
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
input=[model]
model: Name of MEX simulation function or SBmodel (SBmodels will be converted to
MEXmodels prior to simulation). 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'); 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; |
| 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]
model: Name of MEX simulation function or SBmodel (SBmodels will be converted to
MEXmodels prior to simulation). 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'); 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}; |
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: 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]
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.
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: |
| 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 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'); 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]); 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 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 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 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. |
