forked from opencobra/cobratoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
robustnessAnalysis.m
77 lines (65 loc) · 2.11 KB
/
robustnessAnalysis.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function [controlFlux, objFlux] = robustnessAnalysis(model, controlRxn, nPoints, plotResFlag, objRxn,objType)
%robustnessAnalysis Performs robustness analysis for a reaction of
% interest and an objective of interest
%
% [controlFlux, objFlux] = robustnessAnalysis(model, controlRxn, nPoints, plotResFlag, objRxn, objType)
%
%INPUTS
% model COBRA model structure
% controlRxn Reaction of interest whose value is to be controlled
%
%OPTIONAL INPUTS
% nPoints Number of points to show on plot (Default = 20)
% plotResFlag Plot results (Default true)
% objRxn Objective reaction to be maximized
% (Default = whatever is defined in model)
% objType Maximize ('max') or minimize ('min') objective
% (Default = 'max')
%
%OUTPUTS
% controlFlux Flux values within the range of the maximum and minimum for
% reaction of interest
% objFlux Optimal values of objective reaction at each control
% reaction flux value
%
% Monica Mo and Markus Herrgard 8/17/06
if (nargin < 3)
nPoints = 20;
end
if (nargin < 4)
plotResFlag = true;
end
if (nargin > 4)
baseModel = changeObjective(model,objRxn);
else
baseModel = model;
end
if (nargin <6)
objType = 'max';
end
if (findRxnIDs(model,controlRxn))
tmpModel = changeObjective(model,controlRxn);
solMin = optimizeCbModel(tmpModel,'min');
solMax = optimizeCbModel(tmpModel,'max');
else
error('Control reaction does not exist!');
end
objFlux = [];
controlFlux = linspace(solMin.f,solMax.f,nPoints)';
h = waitbar(0,'Robustness analysis in progress ...');
for i=1:length(controlFlux)
waitbar(i/length(controlFlux),h);
modelControlled = changeRxnBounds(baseModel,controlRxn,controlFlux(i),'b');
solControlled = optimizeCbModel(modelControlled,objType);
objFlux(i) = solControlled.f;
end
if ( regexp( version, 'R20') )
close(h);
end
objFlux = objFlux';
if (plotResFlag)
plot(controlFlux,objFlux)
xlabel(strrep(controlRxn,'_','-'));
ylabel('Objective');
axis tight;
end