|
| 1 | +function R2 = growthOld(model_origin,writeOutput) |
| 2 | +% This is for growth test: Fig S4c for yeast8 paper |
| 3 | +% here we use several chemostat data: 'N-limited aerobic' 'C-limited |
| 4 | +% aerobic' 'C-limited anaerobic' 'N-limited anaerobic' |
| 5 | +% when simulating N-limited condition, protein content was rescaled, and |
| 6 | +% when simulate anaerobic condtion, heme NADH NADP NADPH NAD were rescaled |
| 7 | +% to be 0. |
| 8 | + |
| 9 | +funcDir = dbstack('-completenames'); |
| 10 | +funcDir = regexprep(funcDir(1).file,[funcDir(1).name '\.m'],''); |
| 11 | + |
| 12 | +if nargin<1 |
| 13 | + model_origin = loadYeastModel; |
| 14 | +end |
| 15 | +if nargin<2 |
| 16 | + writeOutput = false; |
| 17 | +end |
| 18 | + |
| 19 | +%Load chemostat data: |
| 20 | +fid = fopen(fullfile(funcDir,'..','..','data','physiology','chemostatData_Tobias2013.tsv'),'r'); |
| 21 | +exp_data = textscan(fid,'%f32 %f32 %f32 %f32','Delimiter','\t','HeaderLines',1); |
| 22 | +exp_data = [exp_data{1} exp_data{2} exp_data{3} exp_data{4}]; |
| 23 | +fclose(fid); |
| 24 | +exp_data1 = exp_data(1:9,:); |
| 25 | +exp_data2 = exp_data(10:20,:); |
| 26 | +exp_data3 = exp_data(21:26,:); |
| 27 | +exp_data4 = exp_data(27:32,:); |
| 28 | + |
| 29 | +%'N-limited aerobic' |
| 30 | +mod_data(1:9,:) = simulateChemostat(model_origin,exp_data(1:9,:),1,'N'); |
| 31 | +%'C-limited aerobic' |
| 32 | +mod_data(10:20,:) = simulateChemostat(model_origin,exp_data(10:20,:),1,'C'); |
| 33 | +%'C-limited anaerobic' |
| 34 | +mod_data(21:26,:) = simulateChemostat(model_origin,exp_data(21:26,:),2,'C'); |
| 35 | +%'N-limited anaerobic' |
| 36 | +mod_data(27:32,:) = simulateChemostat(model_origin,exp_data(27:32,:),2,'N'); |
| 37 | + |
| 38 | +% plot the figure |
| 39 | +figure |
| 40 | +hold on |
| 41 | +cols = [215,25,28;253,174,97;171,217,233;44,123,182]/256; |
| 42 | +b(1) = plot(exp_data(1:9,4),mod_data(1:9,4),'o','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor',cols(2,:)); |
| 43 | +b(2) = plot(exp_data(10:20,4),mod_data(10:20,4),'s','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor',cols(1,:)); |
| 44 | +b(3) = plot(exp_data(21:26,4),mod_data(21:26,4),'d','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor',cols(3,:)); |
| 45 | +b(4) = plot(exp_data(27:32,4),mod_data(27:32,4),'>','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor',cols(4,:)); |
| 46 | +exp_max = max(exp_data(:,4)); |
| 47 | +mod_max = max(mod_data(:,4)); |
| 48 | +lim = max(exp_max,mod_max)+0.05; |
| 49 | +xlim([0 lim]) |
| 50 | +ylim([0 lim]) |
| 51 | +x=0:0.001:lim; |
| 52 | +y = x; |
| 53 | +plot(x,y,'--','MarkerSize',6,'Color',[64,64,64]/256) |
| 54 | +xlabel('Experimental growth rate [1/h]','FontSize',14,'FontName','Helvetica') |
| 55 | +ylabel('In silico growth rate [1/h]','FontSize',14,'FontName','Helvetica') |
| 56 | +legend(b,'N-limited aerobic','C-limited aerobic','C-limited anaerobic','N-limited anaerobic','Location','northwest') |
| 57 | + |
| 58 | +% meanerror = sqrt(sum(([exp_data1(:,4);exp_data2(:,4);exp_data3(:,4);exp_data4(:,4)]-[mod_data1(:,4);mod_data2(:,4);mod_data3(:,4);mod_data4(:,4)]).^2)/32)/sqrt(32); |
| 59 | +% text(0.25,0.1,['SEM:',num2str(meanerror)]) |
| 60 | +hold off |
| 61 | +R2=corrcoef(exp_data(:,4),mod_data(:,4)); |
| 62 | +R2=R2(2)^2; |
| 63 | + |
| 64 | +if writeOutput |
| 65 | + saveas(gcf,fullfile(funcDir,'..','..','data','testResults','growth.png')); |
| 66 | + fid = fopen(fullfile(funcDir,'..','..','data','testResults','growth.md'),'w'); |
| 67 | + fprintf(fid,'%s\n','## R2 of growth rate prediction'); |
| 68 | + fprintf(fid,'%.4g\n\n',R2); |
| 69 | + fprintf(fid,'%s\n',''); |
| 70 | + fclose(fid); |
| 71 | +end |
| 72 | +end |
| 73 | + |
| 74 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 75 | +function [mod_data,solresult] = simulateChemostat(model_origin,exp_data,mode1,mode2) |
| 76 | +%Relevant positions: |
| 77 | +pos(1) = find(strcmp(model_origin.rxns,'r_1714')); %glc |
| 78 | +pos(2) = find(strcmp(model_origin.rxns,'r_1992')); %O2 |
| 79 | +pos(3) = find(strcmp(model_origin.rxns,'r_1654')); %NH3 |
| 80 | +pos(4) = find(strcmp(model_origin.rxns,'r_2111')); %growth |
| 81 | + |
| 82 | +%Simulate chemostats: |
| 83 | +mod_data = zeros(size(exp_data)); |
| 84 | +solresult = zeros(length(model_origin.rxns),length(exp_data(:,1))); |
| 85 | +if mode1 == 2 |
| 86 | + model_origin = anaerobicModelOld(model_origin); |
| 87 | +end |
| 88 | +if strcmp(mode2,'N') |
| 89 | + % P content in NH3-lim 0.1/h chemostat, per 10.1016/j.femsyr.2005.04.003 |
| 90 | + model_origin = scaleBioMassOld(model_origin,'protein',0.28,'',false); |
| 91 | + % Assume that RNA decreased by the same amount (40%) |
| 92 | + model_origin = scaleBioMassOld(model_origin,'RNA',0.0329,'carbohydrate',false); |
| 93 | + model_origin = setParam(model_origin,'ub','r_0472',1000); %Glutamate synthase repressed in excess nitrogen |
| 94 | +end |
| 95 | +for i = 1:length(exp_data(:,1)) |
| 96 | + model_test= model_origin; |
| 97 | + %Fix glucose uptake rate and maximize growth: |
| 98 | + for j = 1:length(exp_data(1,:))-1 |
| 99 | + |
| 100 | + if abs(exp_data(i,j))==1000 |
| 101 | + model_test = setParam(model_test,'lb',model_test.rxns(pos(j)),-exp_data(i,j)); |
| 102 | + else |
| 103 | + model_test = setParam(model_test,'eq',model_test.rxns(pos(j)),-exp_data(i,j)); |
| 104 | + end |
| 105 | + end |
| 106 | + |
| 107 | + model_test = setParam(model_test,'obj',model_test.rxns(pos(4)),1); |
| 108 | + sol = solveLP(model_test,1); |
| 109 | + %Store relevant variables: |
| 110 | + try |
| 111 | + mod_data(i,:) = abs(sol.x(pos)'); |
| 112 | + solresult(:,i) = sol.x; |
| 113 | + catch |
| 114 | + mod_data(i,:) = 0; |
| 115 | + solresult(:,i) = 0; |
| 116 | + end |
| 117 | +end |
| 118 | +end |
0 commit comments