📄 aggllayout.m
字号:
function aggllayout
% This function will layout the gui controls. Eventually, this will be
% included in the complete function. Just have it now for simplicity.
% First get the user data from the root. See if anything is stored there.
% H.fig Handle to the figure
% H.plots Handles to plots opened with this GUI.
%
% H.Z Z matrix for hierarchical clustering and plotting.
%
% H.data Handle to the popupmenu for data selection - this is VARIABLE
% H.type Handle to the popupmenu for type of clustering - regular/model-based
% H.dist Handle to the popupmenu for the distance used:
% 'euclidean' - Euclidean distance
% 'seuclidean' - Standardized Euclidean distance
% 'cityblock' - City Block distance
% 'mahalanobis' - Mahalanobis distance
% 'minkowski' - Minkowski distance with exponent 2
% H.link Handle to the popupmenu for the type of linkage used:
% 'single' --- nearest distance
% 'complete' --- furthest distance
% 'average' --- average distance
% 'ward' --- inner squared distance
% H.plotyp Handle to the popupmenu for the type of plot:
% 'Dendrogram';'Treemap';'Rectangle';'Graphical EDA';'ReClus'
% H.k Handle to the edit box for number of clusters to output (IDs)
% H.leaves Handle to the edit box for the number of leaves in the display
ud = get(0,'userdata');
H.fig = figure('Tag','agcgui',...
'position',[150 150 726 524],...
'resize','off',...
'toolbar','none',...
'menubar','none',...
'numbertitle','off',...
'name','Agglomerative Clustering GUI',...
'CloseRequestFcn','agcgui(''close'')');
if strcmp(version('-release'),'14')
set(0,'DefaultUicontrolFontname','Sans Serif');
end
H.plots = [];
H.Z = [];
if ~isempty(ud)
% Then something is there already. Add necessary handles to the
% structure.
ud.guis = [ud.guis(:); H.fig];
else
% Set the usual stuff and save in root.
ud = userdata;
set(0,'userdata',ud)
end
% set up all of the frames first.
uicontrol(H.fig, 'style','frame',...
'position',[15 225 700 150]);
uicontrol(H.fig, 'style','frame',...
'position',[15 30 275 180]);
uicontrol(H.fig,'style','frame',...
'position',[300 30 415 180]);
%%%%%%% TEXT BOXES %%%%%%%%%%%%%%
% set up all of the text boxes
uicontrol(H.fig,'style','text',...
'position',[220 485 300 27],...
'fontweight','bold',...
'fontsize',14,...
'backgroundcolor',[.8 .8 .8],...
'string','Agglomerative Clustering')
uicontrol(H.fig,'style','text',...
'position',[45 375 650 44],...
'horizontalalignment','left',...
'backgroundcolor',[.8 .8 .8],...
'string','This provides a complete partition/grouping of the data for any given number of groups. You must specify the distance used and the type of linkage (how distance between clusters is determined.')
% title text
uicontrol(H.fig,'style','text',...
'position',[40 330 170 20],...
'fontsize',10,...
'fontweight','bold',...
'horizontalalignment','left',...
'string','I. Create the Clusters')
uicontrol(H.fig,'style','text',...
'position',[40 180 205 20],...
'fontsize',10,...
'fontweight','bold',...
'horizontalalignment','left',...
'string','II. Visualize the Clusters')
uicontrol(H.fig,'style','text',...
'position',[330 180 230 20],...
'fontsize',10,...
'fontweight','bold',...
'horizontalalignment','left',...
'string','III. Output the Cluster IDs')
% Steps - text - Section I
uicontrol(H.fig,'style','text',...
'position',[40 265 100 40],...
'fontsize',9,...
'horizontalalignment','left',...
'string','1. Select data set:')
uicontrol(H.fig,'style','text',...
'position',[185 265 100 40],...
'fontsize',9,...
'horizontalalignment','left',...
'string','2. Choose type:')
uicontrol(H.fig,'style','text',...
'position',[305 265 100 40],...
'fontsize',9,...
'horizontalalignment','left',...
'string','3. Choose distance:')
uicontrol(H.fig,'style','text',...
'position',[440 265 100 40],...
'fontsize',9,...
'horizontalalignment','left',...
'string','4. Specify linkage:')
uicontrol(H.fig,'style','text',...
'position',[570 265 100 40],...
'fontsize',9,...
'horizontalalignment','left',...
'string','5. Push to cluster:')
% Text - Section II:
uicontrol(H.fig,'style','text',...
'position',[40 140 182 21],...
'fontsize',9,...
'horizontalalignment','left',...
'string','1. Number of leaves:')
uicontrol(H.fig,'style','text',...
'position',[175 140 100 21],...
'fontsize',9,...
'horizontalalignment','left',...
'string','2. Select plot type:')
% Text - Section III:
uicontrol(H.fig,'style','text',...
'position',[330 140 180 21],...
'fontsize',9,...
'horizontalalignment','left',...
'string','1. Choose number of clusters:')
uicontrol(H.fig,'style','text',...
'position',[530 140 130 21],...
'fontsize',9,...
'horizontalalignment','left',...
'string','2. Push to output IDs:')
%%%%%%% BUTTONS %%%%%%%%%%%%%%%%%%%%
uicontrol(H.fig,'style','pushbutton',...
'position',[14 491 170 23],...
'string','LOAD DATA',...
'tooltipstring','This will bring up the Load Data GUI',...
'callback','loadgui')
uicontrol(H.fig,'style','pushbutton',...
'position',[14 463 170 23],...
'string','TRANSFORM',...
'tooltipstring','This will bring up the Transform Data GUI.',...
'callback','transformgui')
uicontrol(H.fig,'style','pushbutton',...
'position',[14 434 170 23],...
'string','DIMENSIONALITY REDUCTION',...
'tooltipstring','This will bring up the Dimensionality Reduction GUI.',...
'callback','dimredgui')
uicontrol(H.fig,'style','pushbutton',...
'position',[570 245 100 25],...
'string','DO CLUSTERING',...
'tooltipstring','This will perform the clustering procedure.',...
'callback','agcgui(''doclus'')')
uicontrol(H.fig,'style','pushbutton',...
'position',[100 60 75 22],...
'string','DO PLOT',...
'tooltipstring','This will plot the data.',...
'callback','agcgui(''doplot'')')
uicontrol(H.fig,'style','pushbutton',...
'position',[525 105 150 25],...
'string','OUTPUT CLUSTER IDs',...
'tooltipstring','This will save an n-dimensional vector of cluster IDs to the workspace. It will also save the IDs so you can color by groups in the GEDA GUI.',...
'callback','agcgui(''cidsout'')')
% Close button
uicontrol(H.fig,'style','pushbutton',...
'position',[620 485 66 25],...
'string','CLOSE',...
'callback','agcgui(''close'')',...
'tooltipstring','Push this button to close the GUI window.')
%%%%%%% POPUPMENUS %%%%%%%%%%%%%%%%%%%%%%%
% This will vary - depending on what the user has chosen and done before.
% Provide the option to cluster the data that has been reduced in
% dimensionality.
% Possibilities are: X, PCA, ISOMAP, LLE, hLLE
H.data = uicontrol('style','popupmenu',...
'String',ud.dimred,...
'position',[40 245 75 22],...
'backgroundcolor','white',...
'tooltipstring','Use this to select the data set to cluster.');
H.type = uicontrol('style','popupmenu',...
'String',{'Basic Aggl.','Model-Based Aggl.'},...
'position',[175 245 100 22],...
'backgroundcolor','white',...
'tooltipstring','Use this to select the method of agglomerative clustering.');
H.dist = uicontrol('style','popupmenu',...
'String',{'euclidean';'seuclidean';'cityblock';'mahalanobis';'minkowski'},...
'position',[315 245 75 22],...
'backgroundcolor','white',...
'tooltipstring','Use this to choose the type of distance for clustering.');
H.link = uicontrol('style','popupmenu',...
'String',{'single';'complete';'average';'ward'},...
'position',[450 245 75 22],...
'backgroundcolor','white',...
'tooltipstring','This governs the way distance between clusters is measured (regular only).');
H.plotyp = uicontrol('style','popupmenu',...
'String',{'Dendrogram';'Treemap';'Rectangle';'Graphical EDA';'ReClus'},...
'position',[175 105 100 22],...
'backgroundcolor','white',...
'tooltipstring','Visualize the results using one of these methods.');
%%%%%% EDIT BOXES %%%%%%%%%%%%%%%%%%%%%%
H.k = uicontrol('style','edit',...
'string','2',...
'position',[350 105 50 22],...
'backgroundcolor','white',...
'tooltipstring','The number of clusters that will be output.');
H.leaves = uicontrol('style','edit',...
'string','30',...
'position',[50 105 50 22],...
'backgroundcolor','white',...
'tooltipstring','Number of leaves displayed in the relevant plots.');
% Save Handles for THIS GUI in the UserData for this figure.
set(gcf,'userdata',H)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -