Code covered by the BSD License  

Highlights from
uidendrogram

uidendrogram

by

 

Interactive dendrogram viewer using nested boxes

testuidendrogram
%
%
% test code for ui dendrogram
%
%
function testuidendrogram

    % load our data from a fasta file
    [header seq] = fastaread('catdata.fasta');
    dist = seqpdist(seq);
    linkcats = linkage(dist); 
    catnames = strrep(header, 'conserved sequence', '');
   
    scrsz = get(0, 'ScreenSize');
    f = figure('Visible', 'off', 'Position', [scrsz(3)/2-370 scrsz(4)/2-150 540 400], ...
    'Name', 'Test ui dendrogram', ... 
    'MenuBar', 'none');

   uicontrol('Style', 'pushbutton', 'Position', [250, 5, 40, 25], 'String', 'Load',  'Callback', @loadme); 
   label = uicontrol('Style', 'text', 'Position', [70 350 400 40], 'String', 'Phylogenetic tree', 'Fontsize', 20);
   textbox = uicontrol('Style', 'text', 'Position', [70 30 400 40]);

   %
   % Create the dendrogram browser
   % Position (pixels), the linkage tree, callback function, leaf names 
   %
   dend = uidendrogram([20 100 500 200+30], linkcats, @selectionmade, catnames);
   set(f, 'Visible', 'on');
   
    function loadme(hObject, eventdata)
        [filename pathname] = uigetfile('*.fasta');
        fname = fullfile(pathname, filename);
        [header seq] = fastaread(fname);
        dist = seqpdist(seq);
        link = linkage(dist);
        dend.names = header;
        dend.setlink(link);
    end
   % callback when the user selects a node
    function selectionmade(hObject, eventdata, selection)
        str = sprintf('You selected %d objects\n', length(find(selection)));
        set(textbox, 'String', str);
    end

end

Contact us