pcsk9Model example model showed different number of parameters between command and workspace

12 views (last 30 days)
Hello team,
I am trying to learn Bayesian parameter estimation in Simbiology from the shared file form the MatLab file exchange.
After I ran the driver_PCSK9_script.m script, I would like to commit the best fit to the model and further carry out the best fitted simulation with following code.
cs = getconfigset(pcsk9Model);
variants_temp = sbiovariant('Variant');
variants_content = cell(1,height(mhSampler.ParameterEstimates));
for i = 1:numel(variants_content)
param_name = split(mhSampler.ParameterEstimates.Parameter(i),'.');
param = sbioselect(pcsk9Model,'Where','Name','regexpi',param_name(end));
variants_content{i} = {param.Type,param.Name,'Value',mhSampler.ParameterEstimates{i,2}};
variants_temp.Content = variants_content;
However, an error occured on the last line showed:
Error using SimBiology.Variant/commit
Component 'CholesterolIntakeDiet' does not exist in the model.
Error in untitled8 (line 19)
Then I checked with the pcsk9Model model and I found that when I excuted "pcsk9Model" in the command line, I saw there are 47 parameters including parameter 'CholesterolIntakeDiet'. I also opened the model in the SimBiology Model Builder and was able to find parameter 'CholesterolIntakeDiet'. However, when I clicked into the pcsk9Model in the Workspace, it only showed 29 parameters. (showed in photo below)
Do not know why and how this could happen or if have any misunderstanding of the model.
Could you please showed me what could cause this problem and how to resolve it?
Thank you very mch.

Accepted Answer

Florian Augustin
Florian Augustin on 29 May 2023
Hi Jesse,
the model component CholesterolIntakeDiet is a reaction-scoped parameter and needs to be referenced by it's "qualified" name. A "qualified" name of a reaction-scoped parameter is <Name of Parent Reaction>.<Name of Reaction-Scoped Parameter>. If either the name of the parent reaction or the name of the reaction-scoped parameter are not valid MATLAB variable names, then the name will need to be specified in square brackets.
For example, the reaction scoped parameter CholesterolIntakeDiet in reaction DietCholesterolAbsorption needs to be referenced as DietCholesterolAbsorption.CholesterolIntakeDiet.
If the names were not valid MATLAB variable names (i.e. if they contained whitespaces, or special characters), then the name would need to be specified in square brakets. For example, a reaction scoped parameter named "Cholesterol Intake Diet" in reaction Diet-Cholesterol-Absorption will need to be referenced as [Diet-Cholesterol-Absorption].[Cholesterol Intake Diet].
The MCMC sampler returns results containing the correctly qualified name of the estimated model components. Thus, instead of the split name in your example code, you can use mhSampler.Parameters. Below is the slightly tweaked code you provided that uses the qualified component names.
% Create an empty variant.
variants_temp = sbiovariant('Variant');
% Loop over all estimated parameters.
for i = 1:height(mhSampler.Parameters)
% Get model component from SimBiology model to determine its Type property.
component_name = split(mhSampler.Parameters(i), '.');
component = sbioselect(pcsk9Model, 'Name', component_name(end));
% Add estimated parameter to variant.
variants_temp.addcontent({component.Type, ...
char(mhSampler.Parameters(i)), ...
'Value', ...
mhSampler.ParameterEstimates.("Maximum A Posteriori Estimate")(i)});
% Commit variant values to PCSK9 model.
commit(variants_temp, pcsk9Model)
I hope this helps.

More Answers (0)


Find more on Biotech and Pharmaceutical in Help Center and File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!