pcsk9Model example model showed different number of parameters between command and workspace
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jesse Chao
am 26 Mai 2023
Kommentiert: Jesse Chao
am 3 Jun. 2023
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}};
end
variants_temp.Content = variants_content;
commit(variants_temp,pcsk9Model)
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)
commit(variants_temp,pcsk9Model)
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1394919/image.png)
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.
Jesse
0 Kommentare
Akzeptierte Antwort
Florian Augustin
am 29 Mai 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)});
end
% Commit variant values to PCSK9 model.
commit(variants_temp, pcsk9Model)
I hope this helps.
Best,
Florian
Weitere Antworten (0)
Communitys
Weitere Antworten in SimBiology Community
Siehe auch
Kategorien
Mehr zu Extend Modeling Environment finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!