Home > src > geckomat > utilities > plotEcFVA.m

plotEcFVA

PURPOSE ^

plotEcFVA

SYNOPSIS ^

function plotEcFVA(minFlux, maxFlux)

DESCRIPTION ^

 plotEcFVA
   Plots cumulative distribution functions of ecFVA results from one or
   model ecModel(s) and/or GEM(s).

 Input:
   minFlux     vector of minimum flux values, coming from ecFVA. If
               multiple ecModels/GEMs are to be visualized, then each
               column represents a separate model.
   maxFlux     vector of maximum flux values, matching minFlux.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function plotEcFVA(minFlux, maxFlux)
0002 % plotEcFVA
0003 %   Plots cumulative distribution functions of ecFVA results from one or
0004 %   model ecModel(s) and/or GEM(s).
0005 %
0006 % Input:
0007 %   minFlux     vector of minimum flux values, coming from ecFVA. If
0008 %               multiple ecModels/GEMs are to be visualized, then each
0009 %               column represents a separate model.
0010 %   maxFlux     vector of maximum flux values, matching minFlux.
0011 
0012 numMods = size(minFlux,2);
0013 fluxRanges = cell(3,1);
0014 % Ignore zero flux reactions
0015 for i=1:numMods
0016     zeroFlux = abs(minFlux(:,i)) < 1e-10 & abs(maxFlux(:,i)) < 1e-10;
0017     minFlux(zeroFlux,i) = NaN;
0018     maxFlux(zeroFlux,i) = NaN;
0019     fluxRange = maxFlux(:,i) - minFlux(:,i);
0020     fluxRange(isnan(fluxRange)) = [];
0021     fluxRanges{i} = fluxRange;
0022 end
0023 
0024 % Plot all together
0025 hold on
0026 legendText = cell(1,numel(numMods));
0027 for i=1:numMods
0028     fluxRange = fluxRanges{i};
0029     cdfplot(fluxRange)
0030     legendText{i} = (['Model #' num2str(i) ' (median: ' num2str(median(fluxRange,'omitnan')) ')']);
0031 end
0032 set(gca, 'XScale', 'log', 'Xlim', [1e-7 1e4])
0033 set(findall(gca, 'Type', 'Line'), 'LineWidth', 2)
0034 legend(legendText,  'Location','northwest')
0035 title('Flux variability (cumulative distribution)');
0036 xlabel('Variability range (mmol/gDCWh)');
0037 ylabel('Cumulative distribution');
0038 hold off
0039 end
0040 
0041 function cdfplot(X)
0042 % cdfplot(X)
0043 % displays a plot of the Empirical Cumulative Distribution Function
0044 % (CDF) of the input array X in the current figure. The empirical
0045 % CDF y=F(x) is defined as the proportion of X values less than or equal to x.
0046 % If input X is a matrix, then cdfplot(X) parses it to the vector and
0047 % displays CDF of all values.
0048 %
0049 % EXAMPLE:
0050 % figure;
0051 % cdfplot(randn(1,100));
0052 % hold on;
0053 % cdfplot(-log(1-rand(1,100)));
0054 % cdfplot(sqrt(randn(1,100).^2 + randn(1,100).^2))
0055 % legend('Normal(0,1) CDF', 'Exponential(1) CDF', 'Rayleigh(1) CDF', 4)
0056 
0057 % Version 1.0
0058 % Alex Podgaetsky, September 2003
0059 % alex@wavion.co.il
0060 %
0061 % Revisions:
0062 %       Version 1.0 -   initial version
0063 
0064 tmp = sort(reshape(X,prod(size(X)),1));
0065 Xplot = reshape([tmp tmp].',2*length(tmp),1);
0066 
0067 tmp = [1:length(X)].'/length(X);
0068 Yplot = reshape([tmp tmp].',2*length(tmp),1);
0069 Yplot = [0; Yplot(1:(end-1))];
0070 
0071 figure(gcf);
0072 hp = plot(Xplot, Yplot);
0073 
0074 ColOrd = get(gca, 'ColorOrder'); 
0075 ord = mod(length(get(gca,'Children')), size(ColOrd,1)); 
0076 set(hp, 'Color', ColOrd((ord==0) + (ord>0)*ord, :));
0077 if ~ishold
0078      xlabel('X', 'FontWeight','b','FontSize',12);
0079      ylabel('F(X)', 'FontWeight','b','FontSize',12);
0080      title('Empirical CDF', 'FontWeight','b','FontSize',12);
0081      grid on;
0082 end
0083 end

Generated by m2html © 2005