0001 function [setsSorted,setNoSorted,setSize] = identifyCorrelSets(model,samples,corrThr,R)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if (nargin < 3)
0023 corrThr = 1-1e-8;
0024 end
0025
0026 nRxns = length(model.rxns);
0027
0028
0029 if (nargin < 4)
0030 R = corrcoef(samples');
0031 R = R - eye(nRxns);
0032 end
0033
0034
0035 adjMatrix = (abs(R) >= corrThr);
0036
0037
0038 selCorrelRxns = any(adjMatrix)';
0039 rxnList = model.rxns(selCorrelRxns);
0040 adjMatrix = adjMatrix(selCorrelRxns,selCorrelRxns);
0041
0042
0043 hasSet = false(size(rxnList));
0044 currSetNo = 0;
0045 setNoTmp = zeros(size(rxnList));
0046 for i = 1:length(rxnList)
0047 if (~hasSet(i))
0048 currSetNo = currSetNo+1;
0049 setMembers = find(adjMatrix(i,:));
0050 hasSet(setMembers) = true;
0051 hasSet(i) = true;
0052 setNoTmp(setMembers) = currSetNo;
0053 setNoTmp(i) = currSetNo;
0054 end
0055 end
0056 setNo = zeros(size(model.rxns));
0057 [tmp,index1,index2] = intersect(model.rxns,rxnList);
0058 setNo(index1) = setNoTmp(index2);
0059
0060
0061 for i = 1:max(setNo)
0062 sets{i}.set = find(setNo == i);
0063 sets{i}.names = model.rxns(sets{i}.set);
0064 setSize(i) = length(sets{i}.set);
0065 end
0066
0067
0068 [setSize,sortInd] = sort(setSize');
0069 sortInd = flipud(sortInd);
0070 setsSorted = sets(sortInd);
0071 setNoSorted = zeros(size(setNo));
0072 for i = 1:length(sortInd)
0073 setNoSorted(setNo == sortInd(i)) = i;
0074 end
0075 setSize = flipud(setSize);
0076 setsSorted = setsSorted';