0001 function PlotLinkage(linkage,varargin)
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
0032 threshold = 1;
0033
0034 if nargin < 1,
0035 error('Incorrect number of parameters (type ''help <a href="matlab:help PlotLinkage">PlotLinkage</a>'' for details).');
0036 end
0037 if size(linkage,2) < 3 || ~isimatrix(linkage(:,1:2)) || ~isdvector(linkage(:,3)),
0038 error('Incorrect linkage (type ''help <a href="matlab:help PlotLinkage">PlotLinkage</a>'' for details).');
0039 end
0040
0041
0042 for i = 1:2:length(varargin),
0043 if ~ischar(varargin{i}),
0044 error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help PlotLinkage">PlotLinkage</a>'' for details).']);
0045 end
0046 switch(lower(varargin{i})),
0047 case 'threshold',
0048 threshold = varargin{i+1};
0049 if ~isdscalar(threshold),
0050 error('Incorrect value for property ''threshold'' (type ''help <a href="matlab:help PlotLinkage">PlotLinkage</a>'' for details).');
0051 end
0052 otherwise,
0053 error(['Unknown property ''' num2str(varargin{i}) ''' (type ''help <a href="matlab:help PlotLinkage">PlotLinkage</a>'' for details).']);
0054
0055 end
0056 end
0057
0058 pairs = linkage(:,1:2);
0059 linkage = linkage(:,3);
0060
0061
0062
0063 original = pairs;
0064 [id,~,i] = unique(pairs(:),'rows');
0065 index = 1:length(id);
0066 pairs(:) = index(i);
0067
0068
0069 ranks = 1:size(pairs,1);
0070 [~,~,labels] = dendrogram([pairs ranks'],0);
0071
0072 tmp(pairs(:)) = original(:);
0073 labels = tmp(labels);
0074 set(gca,'xticklabel',labels,'ytick',[]);
0075
0076 yLim1 = ylim;
0077 ylim([0 yLim1(2)]);
0078 PlotIntervals([find(linkage<threshold,1,'first')-0.5 yLim1(2)],'direction','h');
0079 xlabel('ID');
0080 title('(grey area not significant)');
0081
0082
0083 SideAxes(gca,'left',0.3);
0084 plot(ranks,linkage,'k.:');
0085 box off;
0086 xlim(yLim1);
0087 yLim2 = ylim;
0088 ylim([yLim2(1) max([threshold+0.5 yLim2(2)])]);
0089 PlotIntervals([find(linkage<threshold,1,'first')-0.5 yLim1(2)],'direction','v');
0090 PlotHVLines(threshold,'h','r');
0091 set(gca,'xticklabel',id);
0092 xlabel('Pair #');
0093 ylabel('linkage');
0094 title('(grey area not significant)');