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

조회 수: 1 (최근 30일)
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)
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

채택된 답변

Florian Augustin
Florian Augustin 2023년 5월 29일
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

추가 답변 (0개)

커뮤니티

더 많은 답변 보기:  SimBiology Community

카테고리

Help CenterFile Exchange에서 Extend Modeling Environment에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by