Home > FMAToolbox > Plot > PlotLinkage.m

PlotLinkage

PURPOSE ^

PlotLinkage - Plot network clustering obtained e.g. by FCA analysis.

SYNOPSIS ^

function PlotLinkage(linkage,varargin)

DESCRIPTION ^

PlotLinkage - Plot network clustering obtained e.g. by FCA analysis.

  USAGE

    PlotLinkage(linkage,<options>)

  INPUT

    linkage        network similarity matrix obtained using <a href="matlab:help FunctionalClustering">FunctionalClustering</a>
    <options>      optional list of property-value pairs (see table below)

    =========================================================================
     Properties    Values
    -------------------------------------------------------------------------
     'threshold'   minimum value for significant linkage (default = 1)
    =========================================================================

  SEE

  See also FunctionalClustering.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function PlotLinkage(linkage,varargin)
0002 
0003 %PlotLinkage - Plot network clustering obtained e.g. by FCA analysis.
0004 %
0005 %  USAGE
0006 %
0007 %    PlotLinkage(linkage,<options>)
0008 %
0009 %  INPUT
0010 %
0011 %    linkage        network similarity matrix obtained using <a href="matlab:help FunctionalClustering">FunctionalClustering</a>
0012 %    <options>      optional list of property-value pairs (see table below)
0013 %
0014 %    =========================================================================
0015 %     Properties    Values
0016 %    -------------------------------------------------------------------------
0017 %     'threshold'   minimum value for significant linkage (default = 1)
0018 %    =========================================================================
0019 %
0020 %  SEE
0021 %
0022 %  See also FunctionalClustering.
0023 
0024 % Copyright (C) 2015 by Ralitsa Todorova, Michaƫl Zugaro
0025 %
0026 % This program is free software; you can redistribute it and/or modify
0027 % it under the terms of the GNU General Public License as published by
0028 % the Free Software Foundation; either version 3 of the License, or
0029 % (at your option) any later version.
0030 
0031 % Default values
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 % Parse parameter list
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 % We will renumber IDs from 1 to N because 'dendrogram' cannot handle missing IDs
0062 % We first save the original IDs, then renumber them
0063 original = pairs;
0064 [id,~,i] = unique(pairs(:),'rows');
0065 index = 1:length(id);
0066 pairs(:) = index(i);
0067 
0068 % Plot ranked dendrogram
0069 ranks = 1:size(pairs,1);
0070 [~,~,labels] = dendrogram([pairs ranks'],0);
0071 % Update x labels to show the original IDs
0072 tmp(pairs(:)) = original(:);
0073 labels = tmp(labels);
0074 set(gca,'xticklabel',labels,'ytick',[]);
0075 % Adjust axes and plot threshold
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 % Plot side panel
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)');

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005