sampleScatterMatrix

PURPOSE ^

sampleScatterMatrix Draws a scatterplot matrix with pairwise scatterplots

SYNOPSIS ^

function sampleScatterMatrix(rxnNames,model,sample,nPoints,fontSize,dispRFlag,rxnNames2)

DESCRIPTION ^

sampleScatterMatrix Draws a scatterplot matrix with pairwise scatterplots
for multiple reactions
 
 sampleScatterMatrix(rxnNames,model,sample,nPoints,dispRFlag,rxnNames2)

INPUTS
 rxnNames      Cell array of reaction names to be plotted
 model         Model structure
 sample        Samples to be analyzed (nRxns x nSamples)

OPTIONAL INPUTS
 nPoints       How many sample points to plot (Default 100)
 fontSize      Font size for labels (Default calculated based on
               number of reactions)
 dispRFlag     Display correlation coefficients (Default false)
 rxnNames2     Optional second set of reaction names

 Examples of usage:

 1) sampleScatterMatrix({'PFK','PYK','PGL'},model,sample);
    Plots the scatterplots only between the three reactions listed -
    histograms for each reaction will be on the diagonal

 2) sampleScatterMatrix({'PFK','PYK','PGL'},model,sample,100,10,true,{'ENO','TPI');
    Plots the scatterplots between each of the first set of reactions and 
    each of the second set of reactions. No histograms will be shown.

 Markus Herrgard 9/14/06

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function sampleScatterMatrix(rxnNames,model,sample,nPoints,fontSize,dispRFlag,rxnNames2)
0002 %sampleScatterMatrix Draws a scatterplot matrix with pairwise scatterplots
0003 %for multiple reactions
0004 %
0005 % sampleScatterMatrix(rxnNames,model,sample,nPoints,dispRFlag,rxnNames2)
0006 %
0007 %INPUTS
0008 % rxnNames      Cell array of reaction names to be plotted
0009 % model         Model structure
0010 % sample        Samples to be analyzed (nRxns x nSamples)
0011 %
0012 %OPTIONAL INPUTS
0013 % nPoints       How many sample points to plot (Default 100)
0014 % fontSize      Font size for labels (Default calculated based on
0015 %               number of reactions)
0016 % dispRFlag     Display correlation coefficients (Default false)
0017 % rxnNames2     Optional second set of reaction names
0018 %
0019 % Examples of usage:
0020 %
0021 % 1) sampleScatterMatrix({'PFK','PYK','PGL'},model,sample);
0022 %    Plots the scatterplots only between the three reactions listed -
0023 %    histograms for each reaction will be on the diagonal
0024 %
0025 % 2) sampleScatterMatrix({'PFK','PYK','PGL'},model,sample,100,10,true,{'ENO','TPI');
0026 %    Plots the scatterplots between each of the first set of reactions and
0027 %    each of the second set of reactions. No histograms will be shown.
0028 %
0029 % Markus Herrgard 9/14/06
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                 %subplot(nRxns,nRxns2,(i-1)*nRxns2+j);
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                 %subplot(nRxns,nRxns2,(i-1)*nRxns2+j);
0106                 subplot('position',[left bottom width height]);
0107                 sampleHistInternal(sample,rxnInd(i),fontSize);
0108                 
0109             elseif (j > i)
0110                 %subplot(nRxns,nRxns2,(i-1)*nRxns2+j);
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 % Display correlation coefficients
0141 if (dispRFlag)
0142     r = corrcoef(sample(id1,:)',sample(id2,:)');
0143     %h = text(minx+0.66*(maxx-minx),miny+0.2*(maxy-miny),num2str(round(100*r(1,2))/100));
0144     %set(h,'FontSize',fontSize-5);
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

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003