forked from opencobra/cobratoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doubleRobustnessAnalysis.m
89 lines (78 loc) · 2.74 KB
/
doubleRobustnessAnalysis.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
78
79
80
81
82
83
84
85
86
87
88
89
function [controlFlux1, controlFlux2, objFlux] = doubleRobustnessAnalysis(model, controlRxn1, controlRxn2, nPoints, plotResFlag, objRxn,objType)
%doubleRobustnessAnalysis Performs robustness analysis for a pair of reactions of
% interest and an objective of interest
%
% [controlFlux1, controlFlux2, objFlux] = doubleRobustnessAnalysis(model, controlRxn1, controlRxn2, nPoints, plotResFlag, objRxn, objType)
%
%INPUTS
% model COBRA model structure
% controlRxn1 Reaction of interest whose value is to be controlled
% controlRxn2 Reaction of interest whose value is to be controlled
%
%OPTIONAL INPUTS
% nPoints Number of flux values per dimension (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/20/07
if (nargin < 4)
nPoints = 20;
end
if (nargin < 5)
plotResFlag = true;
end
if (nargin > 6)
baseModel = changeObjective(model,objRxn);
else
baseModel = model;
end
if (nargin <7)
objType = 'max';
end
if (findRxnIDs(model,controlRxn1))
tmpModel = changeObjective(model,controlRxn1);
solMin1 = optimizeCbModel(tmpModel,'min');
solMax1 = optimizeCbModel(tmpModel,'max');
else
error('Control reaction 1 does not exist!');
end
if (findRxnIDs(model,controlRxn2))
tmpModel = changeObjective(model,controlRxn2);
solMin2 = optimizeCbModel(tmpModel,'min');
solMax2 = optimizeCbModel(tmpModel,'max');
else
error('Control reaction 2 does not exist!');
end
objFlux = [];
controlFlux1 = linspace(solMin1.f,solMax1.f,nPoints)';
controlFlux2 = linspace(solMin2.f,solMax2.f,nPoints)';
h = waitbar(0,'Double robustness analysis in progress ...');
for i=1:nPoints
for j = 1:nPoints
waitbar(((i-1)*nPoints+j)/nPoints^2,h);
modelControlled = changeRxnBounds(baseModel,controlRxn1,controlFlux1(i),'b');
modelControlled = changeRxnBounds(modelControlled,controlRxn2,controlFlux2(j),'b');
solControlled = optimizeCbModel(modelControlled,objType);
objFlux(i,j) = solControlled.f;
end
end
if ( regexp( version, 'R20') )
close(h);
end
if (plotResFlag)
clf
surf(controlFlux1,controlFlux2,objFlux);
%shading interp
xlabel(strrep(controlRxn1,'_','-'));
ylabel(strrep(controlRxn2,'_','-'));
axis tight
end