Torkel Loman in MATLAB Answers
最後のアクティビティ: 2022 年 8 月 4 日

I have an .sbml model I want to simulate using ssa. It works for small timespans, and when using ode simulations. However, in this example matlab simply crashes. Why is this? is there a way of preventing this? % Load model. model_egfr_net = sbmlimport('egfr_net.xml'); % Prepare model for SSA simulations. clean_ssa_sbml_model(model_egfr_net) cs = getconfigset(model_egfr_net); cs.SolverType = 'ssa'; cs.StopTime = 100.0; % Simulate model. [t, x, names] = sbiosimulate(model_egfr_net); I have attached the model. Also, per https://uk.mathworks.com/matlabcentral/answers/1582584-simbio-running-stochastic-ssa-simulation-of-sbml-imported-model the model has to be modified to enable ssa simulations. The attached function (used in the script) is provided here: function [] = clean_ssa_sbml_model(model) parameters = sbioselect(model, 'Type', 'parameter'); for paramIndex = 1:numel(parameters) parameter = parameters(paramIndex); [~, usageTable] = findUsages(parameter); % Update any reaction that uses this parameter in its rate. if isempty(usageTable) % if check added by Torkel. continue end reactions = usageTable.Component(usageTable.Property == "ReactionRate"); for reactionIndex = 1:numel(reactions) reaction = reactions(reactionIndex); oldRate = reaction.ReactionRate; kineticLaw = reaction.KineticLaw; if isempty(kineticLaw) % Add a kinetic law kineticLaw = addkineticlaw(reaction, 'MassAction'); else % Update the existing kinetic law to mass action kineticLaw.KineticLawName = 'MassAction'; end kineticLaw.ParameterVariableNames = parameter.Name; newRate = reaction.ReactionRate; if ~strcmp(oldRate, newRate) warning("Reaction rate for reaction %s changed from %s to %s.", ... reaction.Name, oldRate, newRate); end end end end
Torkel Loman in MATLAB Answers
最後のアクティビティ: 2022 年 4 月 6 日

I have a .sbml model stored in an .xml file. It contains a couple of observables. When I plto the simulation results, these are uniformly set to "1" when I use the ssa simulation, however, observables seems to work fine with ode simulations. This is the code: % Fetch model. model = sbmlimport('multistate.xml'); % Run simulation. cs = getconfigset(model); cs.SolverType = 'sundials'; cs.StopTime = 10.0; [t_ode, x_ode, names] = sbiosimulate(model); % Plot observables. plot(t_ode, x_ode(:,end-3:end)) xlabel('Time') ylabel('States') legend(names(end-3:end)) % Prepare model for SSA simulations (see https://uk.mathworks.com/matlabcentral/answers/1582584-simbio-running-stochastic-ssa-simulation-of-sbml-imported-model). parameters = sbioselect(model, 'Type', 'parameter'); for paramIndex = 1:numel(parameters) parameter = parameters(paramIndex); [~, usageTable] = findUsages(parameter); % Update any reaction that uses this parameter in its rate. if isempty(usageTable) % if check added by Torkel. continue end reactions = usageTable.Component(usageTable.Property == "ReactionRate"); for reactionIndex = 1:numel(reactions) reaction = reactions(reactionIndex); oldRate = reaction.ReactionRate; kineticLaw = reaction.KineticLaw; if isempty(kineticLaw) % Add a kinetic law kineticLaw = addkineticlaw(reaction, 'MassAction'); else % Update the existing kinetic law to mass action kineticLaw.KineticLawName = 'MassAction'; end kineticLaw.ParameterVariableNames = parameter.Name; newRate = reaction.ReactionRate; if ~strcmp(oldRate, newRate) warning("Reaction rate for reaction %s changed from %s to %s.", ... reaction.Name, oldRate, newRate); end end end % Run simulation. cs = getconfigset(model); cs.SolverType = 'ssa'; cs.StopTime = 10.0; [t_ssa, x_ssa, names] = sbiosimulate(model); % Plot observables. plot(t_ssa, x_ssa(:,end-3:end)) xlabel('Time') ylabel('States') legend(names(end-3:end)) % Non-observables plot still work. plot(t_ssa, x_ssa(:,1:end-4)) xlabel('Time') ylabel('States') legend(names(1:end-4)) % Observable plotting still work for the modified model when using ode. cs = getconfigset(model); cs.SolverType = 'sundials'; cs.StopTime = 10.0; [t_ode_2, x_ode_2, names] = sbiosimulate(model); plot(t_ode_2, x_ode_2(:,end-3:end)) xlabel('Time') ylabel('States') legend(names(end-3:end)) Which produces these plots: The observables can be plotted when the mode is simulated via ode: The observables are all "1" when simualted via ssa: The other species can be plotted without problem though: Finnaly, plotting the observables when the system has been simualted via ode still work, even after the model have been modified. There is something wrong where the observables values are not set when the ssa algorithm is used. Finally, I have attached the model file (extension changed to .txt so that mathworks website would accept it).
Torkel Loman in MATLAB Answers
最後のアクティビティ: 2022 年 2 月 26 日

Hello, I have a biochemical reaction network model defined in the SBML format (attached). I can load the model using the sbmlimport: sbml_mod = sbmlimport('multistate.xml'); I can perform ODE simulations of this model using sbiosimulate: [time,x,names] = sbiosimulate(sbml_mod); However, if I want to perform stochastic SSA (GIllespie) simulations (https://uk.mathworks.com/help/simbio/ug/stochastic-solvers.html), I get problems. Running cs = getconfigset(sbml_mod,'active'); cs.SolverType = 'ssa'; cs.StopTime = 30; [t_ssa, x_ssa] = sbiosimulate(sbml_mod); I get errors: --> Error reported from Stochastic Compilation: Reaction named 'Reaction_2' has an empty kinetic law. For stochastic simulation all kinetic laws must be MassAction. (one for each of my 18 reactions) It turns out that when loading SBML models each reactions get no KineticLaw, which is needed for SSA simulations. E.g. sbml_mod.Reactions(1).KineticLaw simply returns []. However, all reactions in the SBML file are simple MassAction reactions, e.g. sbml_mod.Reactions(1).ReactionRate is 'kon*[R(a,l)]*[L(r)]'. I tried simply looping through all reactions and setting their KineticLaw field to 'MassAction'. But this still yields errors like --> Error reported from KineticLaw Validation: Parameter variable name on kinetic law '' is empty. The number of parameters on the kinetic law must match the number in its definition, and all parameter names must be set. So I somehow need to ftech the right parameters and att that to the MassAction kinetic law. It seems like this should be fairly straightforward (e.g. many other packages, like Copasi can do SSA simulations directly from SBML files). Is there some automatic way of setting all reactions to MassAction kinetic law, or some other way which would enable me to do an SSA simulation of the model?
Daniel Bending in MATLAB Answers
最後のアクティビティ: 2020 年 6 月 5 日

Hello all, I've been using simbiology as part of an effort to run sensitivity analysis on a PDPK model as part of my masters. It's industry sponsored so the image below has the important information blurred but enough to give context. The black lines are simple mass kinetics, easily done in Simbiology. The green lines, howeever, are stimulations, i.e. there's no actual transfer of material, just its pressence causes an effect. I had thought these would be quite easily by creating a reaction from 'null -> x' and but I'm unsure on how to create that custom dependency, i.e. a null -> x where the equation is kyx*[y] -> x. It was easy to do on the GUI, however, the GUI dosn't quite have the freedom I need for sentitivity analysis. I was struggling to get a global sensitivity analysis going, basically. If anyone has any suggestions about either of these topics, that would be greatly appreciated. Many thanks, Dan
Ciaran in MATLAB Answers
最後のアクティビティ: 2015 年 1 月 8 日

I am reproducing a published model and need to view the differential equations produced by the SimBiology functions. I am using a script (rather than the GUI interface) though I can import the model into the SimBiology GUI if the solution requires. Does anybody know how to see the differential equations from a SimBiology model. Thanks in advance.
Ciaran in MATLAB Answers
最後のアクティビティ: 2015 年 1 月 7 日

I am building a SimBiology Model. I want to simulate from randomly generated initial conditions numerous times and find the steady state of a particular specie (PLS). MY current code does this in a graphical sense but I need the actual numbers in a vector (for example) for subsequent use. Does anybody know how to do this? My current code is: %Random Number Generations and Assignment No_of_simulations = 10; %i.e. points number_of_parameters = 4; %i.e. dimenions lb=[1e-3]; ub=[0.1]; x = lhsdesign(number_of_parameters ,No_of_simulations); D = bsxfun(@plus,lb,bsxfun(@times,x,(ub-lb))); for i=x, n1 = i(1); n2 = i(2); n3 = i(3); n4 = i(4); %Model generation. Mobj = sbiomodel('u-PA_parameter_generation'); comp_obj = addcompartment(Mobj, 'plasma'); %Reaction 1 Robj1 = addreaction(Mobj, 'Pro-u-PA + PLG -> PLS + Pro-u-PA'); Kobj1= addkineticlaw(Robj1, 'MassAction'); Pobj1 = addparameter(Kobj1, 'keff_zymogen',0.035); set(Kobj1, 'ParameterVariableNames','keff_zymogen'); %Reaction 2 Robj2 = addreaction(Mobj, 'PLS + Pro-u-PA -> PLS + u-PA'); Kobj2= addkineticlaw(Robj2, 'MassAction'); Pobj2 = addparameter(Kobj2, 'keff_PLS',40); set(Kobj2, 'ParameterVariableNames','keff_PLS'); %Reaction 3 Robj3 = addreaction(Mobj, 'u-PA + PLG -> u-PA + PLS'); Kobj3= addkineticlaw(Robj3, 'MassAction'); Pobj3 = addparameter(Kobj3, 'keff_pos',0.9); set(Kobj3, 'ParameterVariableNames','keff_pos'); %Reaction 4 Robj4 = addreaction(Mobj, 'Pro-u-PA -> null'); Kobj4= addkineticlaw(Robj4, 'MassAction'); Pobj4 = addparameter(Kobj4, 'u1',0.084); set(Kobj4, 'ParameterVariableNames','u1'); %Reaction 5 Robj5 = addreaction(Mobj, 'PLG -> null'); Kobj5= addkineticlaw(Robj5, 'MassAction'); Pobj5 = addparameter(Kobj5, 'u2',0.032); set(Kobj5, 'ParameterVariableNames','u2'); %Reaction 6 Robj6 = addreaction(Mobj, 'PLS -> null'); Kobj6= addkineticlaw(Robj6, 'MassAction'); Pobj6 = addparameter(Kobj6, 'u1',0.084); %Same as R4 set(Kobj6, 'ParameterVariableNames','u1'); %Reaction 7 Robj7 = addreaction(Mobj, 'u-PA -> null'); Kobj7= addkineticlaw(Robj7, 'MassAction'); Pobj7 = addparameter(Kobj7, 'u1',0.084); %Same as R4 set(Kobj7, 'ParameterVariableNames','u1'); %Reaction 8 Robj8 = addreaction(Mobj, 'null -> Pro-u-PA'); Kobj8= addkineticlaw(Robj8, 'MassAction'); Pobj8 = addparameter(Kobj8, 'a1',0.0032); set(Kobj8, 'ParameterVariableNames','a1'); %Reaction 9 Robj9 = addreaction(Mobj, 'null -> PLG'); Kobj9= addkineticlaw(Robj9, 'MassAction'); Pobj9 = addparameter(Kobj9, 'a2',0.01); set(Kobj9, 'ParameterVariableNames','a2'); %setting species concentrations Sobj1 = sbioselect(Mobj,'Type','species','Name','Pro-u-PA'); set(Sobj1, 'InitialAmount',n1) Sobj2 = sbioselect(Mobj,'Type','species','Name','PLG'); set(Sobj2, 'InitialAmount',n2) Sobj3 = sbioselect(Mobj,'Type','species','Name','PLS'); set(Sobj3, 'InitialAmount',n3) Sobj4 = sbioselect(Mobj,'Type','species','Name','u-PA'); set(Sobj4, 'InitialAmount',n4) %simulate config = getconfigset(Mobj); set(config,'StopTime',1000) [t_ode, x_ode, names] = sbiosimulate(Mobj); hold on figure; set(gcf, 'color','white'); plot(t_ode, x_ode(:,1:end)); legend(names) end Thanks in Advance
Ciaran in MATLAB Answers
最後のアクティビティ: 2015 年 1 月 7 日

In other modelling software I can simple use: ' -> protein' for fist order production of a protein however this doesn't seem to be excepted in SimBiology. I have also tried: 'null -> protein' but this also does not work. What is the syntax for producing a species out of nothing in simbiolgy? Thanks