How do I resolve, error in resample ?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
RAMYA BODDEPALLI
am 30 Mai 2022
Kommentiert: RAMYA BODDEPALLI
am 1 Jun. 2022
I am trying to model a positive autoregulation network.
I ran it for 1000 ensemble runs, while trying to get the statistics, it shows the following error. Could you please help me with this?
model = sbiomodel('PAR Model');
c = addcompartment(model,'C');
c.CapacityUnits = 'meter^3';
Enter Reactions
r1 = addreaction(model,'off + P -> on + P')
r2 = addreaction(model,'on -> off')
r3 = addreaction(model,'on -> on + R ')
r4 = addreaction(model, 'R -> null')
r5 = addreaction(model, 'R -> R + P')
r6 = addreaction(model, 'P -> null')
Set Reactions to be MassAction
k1 = addkineticlaw(r1, 'MassAction');
k2 = addkineticlaw(r2, 'MassAction');
k3 = addkineticlaw(r3, 'MassAction');
k4 = addkineticlaw(r4, 'MassAction');
k5 = addkineticlaw(r5, 'MassAction');
k6 = addkineticlaw(r6, 'MassAction');
Add Rate Constants for Each Reaction
p1 = addparameter(k1, 'kpar', 'Value', 1 , 'ValueUnits', '1/(minute*molecule)');
p2 = addparameter(k2, 'koff', 'Value', 28, 'ValueUnits', '1/minute' );
p3 = addparameter(k3, 'ktransc', 'Value', 1.2, 'ValueUnits', '1/minute' );
p4 = addparameter(k4, 'kdegR', 'Value', 0.36,'ValueUnits', '1/minute' );
p5 = addparameter(k5, 'ktransl', 'Value', 6,'ValueUnits', '1/minute' );
p6 = addparameter(k6, 'kdegP', 'Value', 2.5, 'ValueUnits', '1/minute' );
Set the Kinetic Law Constants for Each Kinetic Law.
k1.ParameterVariableNames = {'kpar'};
k2.ParameterVariableNames = {'koff'};
k3.ParameterVariableNames = {'ktransc'};
k4.ParameterVariableNames = {'kdegR'};
k5.ParameterVariableNames = {'ktransl'};
k6.ParameterVariableNames = {'kdegP'};
Specify Initial Amounts of Each Species
model.species(1).InitialAmount = 1 ;
model.species(1).InitialAmountUnits = 'molecule' % off
model.species(2).InitialAmount = 25 ;
model.species(2).InitialAmountUnits = 'molecule' % P
model.species(3).InitialAmount = 0 ;
model.species(3).InitialAmountUnits = 'molecule' % on
model.species(4).InitialAmount = 1 ;
model.species(4).InitialAmountUnits = 'molecule' % R
Get the Active Configuration Set for the Model.
cs = getconfigset(model,'active');
Simulate Model Using SSA Stochastic Solver
numRuns = 1000;
cs.SolverType = 'ssa';
cs.SolverOptions.LogDecimation = 100;
simdata = sbioensemblerun(model, numRuns);
figure;
speciesNames = {'R'};
[t, x] = selectbyname(simdata, speciesNames);
hold on;
for i = 1:numRuns
plot(t{i}, x{i});
end
grid on;
xlabel('Time in seconds');
ylabel('Species amount');
title('Raw Ensemble Data');
legend(speciesNames);
[timeVals, meanVals, varianceVals] = sbioensemblestats(simdata, speciesNames);
0 Kommentare
Akzeptierte Antwort
Rick Paxson
am 30 Mai 2022
Bearbeitet: Rick Paxson
am 30 Mai 2022
Thank you for reporting this. It appears to be a bug in sbioensemblestats. The default interpolation method used requires at least 2 points for each simulation profile and your example does not satisfly that requirement. You can see this by looking at the Time property of the simdata array (e.g. >> simdata.Time). Until we fix this with a better warning/error message, I can suggest a workaround.
The decimation of the resulting simulation data is set to 100 in your example. If you set that to a lower number (I tried 10) you will get more points and the interpolation onto a common time vector will work.
cs.SolverOptions.LogDecimation = 10;
simdata = sbioensemblerun(model, numRuns);
sbioensembleplot(simdata, 'R');
Hope this helps, and thank you again for reporting this problem.
Weitere Antworten (1)
Jeremy Huard
am 30 Mai 2022
Hi Ramya,
many of the simulations generated with this code contains only one data point. sbioensemblestats tries first to synchronize all simulation to the same time vector and it fails in this case.
In your example, this is due to the large value of LogDecimation. You could set to 1 here.
Also, UnitConversion is set to false, so your model is simulated with the current time unit in your model (minute). Which is probably what you want. But I still recommend to turn on UnitConversion and adapt the simulation stopTime accordingly:
cs.StopTime = 10;
cs.TimeUnits = 'minute';
cs.CompileOptions.UnitConversion = true;
cs.SolverType = 'ssa';
cs.SolverOptions.LogDecimation = 1;
With these settings, your code should run:
model = sbiomodel('PAR Model');
c = addcompartment(model,'C');
c.CapacityUnits = 'meter^3';
r1 = addreaction(model,'off + P -> on + P');
r2 = addreaction(model,'on -> off');
r3 = addreaction(model,'on -> on + R ');
r4 = addreaction(model, 'R -> null');
r5 = addreaction(model, 'R -> R + P');
r6 = addreaction(model, 'P -> null');
k1 = addkineticlaw(r1, 'MassAction');
k2 = addkineticlaw(r2, 'MassAction');
k3 = addkineticlaw(r3, 'MassAction');
k4 = addkineticlaw(r4, 'MassAction');
k5 = addkineticlaw(r5, 'MassAction');
k6 = addkineticlaw(r6, 'MassAction');
p1 = addparameter(k1, 'kpar', 'Value', 1 , 'ValueUnits', '1/(minute*molecule)');
p2 = addparameter(k2, 'koff', 'Value', 28, 'ValueUnits', '1/minute' );
p3 = addparameter(k3, 'ktransc', 'Value', 1.2, 'ValueUnits', '1/minute' );
p4 = addparameter(k4, 'kdegR', 'Value', 0.36,'ValueUnits', '1/minute' );
p5 = addparameter(k5, 'ktransl', 'Value', 6,'ValueUnits', '1/minute' );
p6 = addparameter(k6, 'kdegP', 'Value', 2.5, 'ValueUnits', '1/minute' );
k1.ParameterVariableNames = {'kpar'};
k2.ParameterVariableNames = {'koff'};
k3.ParameterVariableNames = {'ktransc'};
k4.ParameterVariableNames = {'kdegR'};
k5.ParameterVariableNames = {'ktransl'};
k6.ParameterVariableNames = {'kdegP'};
model.species(1).InitialAmount = 1 ;
model.species(1).InitialAmountUnits = 'molecule'; % off
model.species(2).InitialAmount = 25 ;
model.species(2).InitialAmountUnits = 'molecule'; % P
model.species(3).InitialAmount = 0 ;
model.species(3).InitialAmountUnits = 'molecule'; % on
model.species(4).InitialAmount = 1 ;
model.species(4).InitialAmountUnits = 'molecule'; % R
cs = getconfigset(model,'active');
numRuns = 1000;
cs.StopTime = 10;
cs.TimeUnits = 'minute';
cs.CompileOptions.UnitConversion = true;
cs.SolverType = 'ssa';
cs.SolverOptions.LogDecimation = 1;
simdata = sbioensemblerun(model, numRuns, cs);
figure;
speciesNames = {'R'};
[t, x] = selectbyname(simdata, speciesNames);
hold on;
for i = 1:numRuns
plot(t{i}, x{i});
end
set(gca, 'XLimitMethod','padded','YLimitMethod','padded')
grid on;
xlabel("Time in " + cs.TimeUnits);
ylabel('Species amount');
title('Raw Ensemble Data');
[timeVals, meanVals, varianceVals] = sbioensemblestats(simdata, speciesNames);
figure;
plot(timeVals, meanVals, '-', ...
timeVals, sqrt(varianceVals), 'r:', LineWidth=1.5);
grid on;
box off;
set(gca, 'XLimitMethod','padded','YLimitMethod','padded')
xlabel("Time in " + cs.TimeUnits);
title('Mean and Standard Deviation');
legend('Mean', 'Standard Deviation',Box='off');
Best regards,
Jérémy
Communitys
Weitere Antworten in SimBiology Community
Siehe auch
Kategorien
Mehr zu Biotech and Pharmaceutical 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!