0001 function sampleScatterMatrix(rxnNames,model,sample,nPoints,fontSize,dispRFlag,rxnNames2)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 [isInModel,rxnInd] = ismember(rxnNames,model.rxns);
0032 rxnNames = rxnNames(isInModel);
0033 rxnInd = rxnInd(isInModel);
0034 nRxns = length(rxnNames);
0035
0036 if (nargin < 4)
0037 nPoints = 100;
0038 end
0039
0040 if (nargin < 6)
0041 dispRFlag = false;
0042 end
0043
0044 if (nargin > 6)
0045
0046 [isInModel2,rxnInd2] = ismember(rxnNames2,model.rxns);
0047
0048 rxnNames2 = rxnNames2(isInModel2);
0049 rxnInd2 = rxnInd2(isInModel2);
0050
0051 nRxns2 = length(rxnNames2);
0052 twoSetsFlag = true;
0053
0054 else
0055
0056 nRxns2 = nRxns;
0057 rxnNames2 = rxnNames;
0058 twoSetsFlag = false;
0059
0060 end
0061
0062 if (twoSetsFlag)
0063 nRxns = nRxns+1;
0064 nRxns2 = nRxns2+1;
0065 end
0066
0067 if (nargin < 5)
0068 nPanels = nRxns*nRxns2;
0069 fontSize = 10+ceil(50/sqrt(nPanels));
0070 end
0071
0072 height = 0.8/nRxns;
0073 width = 0.8/nRxns2;
0074
0075 fontSize = 10;
0076 clf
0077 h = waitbar(0,'Drawing scatterplots ...');
0078 for i = 1:nRxns
0079
0080 for j = 1:nRxns2
0081 waitbar(((i-1)*nRxns+j)/(nRxns*nRxns2),h);
0082 left = 0.1+(j-1)*width;
0083 bottom = 0.9-i*height;
0084 if (twoSetsFlag)
0085 if (i == 1 & j == 1)
0086 else
0087
0088 subplot('position',[left bottom width height]);
0089 if (j >1 & i >1)
0090 sampleScatterPlot(sample,rxnInd2(j-1),rxnInd(i-1),nPoints,fontSize,dispRFlag);
0091 elseif (i == 1)
0092 sampleHistInternal(sample,rxnInd2(j-1),fontSize);
0093 elseif (j == 1)
0094 sampleHistInternal(sample,rxnInd(i-1),fontSize);
0095 end
0096 if (i == 1)
0097 title(rxnNames2{j-1},'FontSize',fontSize);
0098 end
0099 if (j == 1)
0100 ylabel(rxnNames{i-1},'FontSize',fontSize);
0101 end
0102 end
0103 else
0104 if (j == i)
0105
0106 subplot('position',[left bottom width height]);
0107 sampleHistInternal(sample,rxnInd(i),fontSize);
0108
0109 elseif (j > i)
0110
0111 subplot('position',[left bottom width height]);
0112 sampleScatterPlot(sample,rxnInd(j),rxnInd(i),nPoints,fontSize,dispRFlag);
0113 end
0114 if (i == 1)
0115 title(rxnNames2{j},'FontSize',fontSize);
0116 end
0117 if (j == nRxns2)
0118 set(gca,'YAxisLocation','right');
0119 ylabel(rxnNames{i},'FontSize',fontSize);
0120 end
0121 end
0122 end
0123
0124 end
0125 close(h);
0126
0127 function sampleScatterPlot(sample,id1,id2,nPoints,fontSize,dispRFlag)
0128
0129 selPts = randperm(size(sample,2));
0130 selPts = selPts(1:nPoints);
0131
0132 plot(sample(id1,selPts),sample(id2,selPts),'r.');
0133 set(gca,'YTickLabel',[]);
0134 set(gca,'XTickLabel',[]);
0135 maxx = max(sample(id1,:));
0136 maxy = max(sample(id2,:));
0137 minx = min(sample(id1,:));
0138 miny = min(sample(id2,:));
0139 axis([minx maxx miny maxy]);
0140
0141 if (dispRFlag)
0142 r = corrcoef(sample(id1,:)',sample(id2,:)');
0143
0144
0145 xlabel(num2str(round(100*r(1,2))/100),'FontSize',fontSize-5);
0146 end
0147
0148 function sampleHistInternal(sample,id,fontSize)
0149
0150 [n,bins] = hist(sample(id,:),30);
0151 if (exist('smooth'))
0152 plot(bins,smooth(bins,n')/sum(n'));
0153 else
0154 plot(bins,n'/sum(n'));
0155 end
0156 maxx = max(bins);
0157 minx = min(bins);
0158 set(gca,'XTick',linspace(minx,maxx,4));
0159 set(gca,'XTickLabel',round(10*linspace(minx,maxx,4))/10);
0160 set(gca,'YTickLabel',[]);
0161 set(gca,'FontSize',fontSize-5);
0162 axis tight