Why does my CLUSTERGRAM object not display the full text of my row labels?

7 views (last 30 days)
I am creating a clustergram figure using the Bioinformatics Toolbox in MATLAB 7.6.0 (R2008a) as follows:
Data = rand(20,20).* repmat(floor(5.*(rand(1,20))),20,1);
LB = strcat('LOONNNNNGGGRow',arrayfun(@num2str,1:20,'UniformOutput',0));
SB = strcat('Column',arrayfun(@num2str,1:20,'UniformOutput',0));
CGobj=clustergram(Data,'RowLabels',LB,'ColumnLabels',SB,'Standardize',3, 'Cluster',1, 'DisplayRange',10);
set(CGobj,'Linkage', 'complete','Dendrogram', 5);
But when the clustergram is displayed, the row labels are cut off.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 1 Jul 2011
This enhancement has been incorporated in Release 2009b (R2009b). For previous product releases, read below for any possible workarounds:
The Bioinformatics Toolbox does not guarantee that the row labels are contained within the extent of the clustergram window. There are several options for workarounds.
One option is to increase the size of the clustergram figure window. This will create more space for the labels to be displayed.
A second option is to create a figure out of the clustergram and interactively decrease the width of the clustergram or change the row label font size. This can be done as follows:
1. Go to the menu bar of the clustergram object and navigate to File->Print to Figure. This will create a figure object whose properties you can modify.
2. On the Menu bar of the new figure, select Edit->Axes Properties.
3. In the Property Editor that opens up, choose "More Properties" and then find the "Position" subgrouping.
4. From here, you can modify the "width" component of "Position". This will decrease the width of the clustergram allowing row labels to display completely.
5. Alternatively, you may edit the font of the row labels by clicking on each TEXT object and modifying the font property.
A third option is to make the above changes programmatically. This requires grabbing a handle to the figure associated with the clustergram and then manipulating the figure properties.
First obtain the figure handle:
%Make all handles visible. This is necessary because clustergram
%objects are created with 'HandleVisibility' property set to 'off'.
set(0,'ShowHiddenHandles','on')
%Get all handles from root
allhnds = get(0,'Children');
%Find the handles that correspond to clustergram objects
cgfigidx = strmatch('Clustergram',get(allhnds,'Tag'));
cffighnd = allhnds(cgfigidx);
%Make the non-visible handles hidden again
set(0,'ShowhiddenHandles','off')
%If there is more than one clustergram object, operate on the last one in
%the list.
if length(cffighnd)>1
warning('More than one clustergram handle found. Using most recent clustergram') %#ok<WNTAG>
cffighnd = cffighnd(end);
end
Now modify the width of the axes:
% Make a handle to the axes of the current figure
fch = get(cffighnd,'Children');
fch = fch(strmatch('axes',get(fch,'Type')));
%Define the new Clustergram position
pos = get(fch,'Position');
newcgpos = pos{2}-[0 0 .2 0];
%Set the new clustergram position
set(fch,'Position',newcgpos)
Alternatively, you could modify the font size of the TEXT objects in the clustergram:
set(0,'ShowHiddenHandles','on')
%Find all the text objects
txtobj = findall(fch,'Type','Text');
%Set the font size of all text objects in clustergram
set(txtobj,'FontSize',5)
To learn more about figure properties, please open the documentation by typing "doc" at the MATLAB command prompt and type "figure properties" in the Help Navigator Search Bar.

More Answers (0)

Categories

Find more on Genomics and Next Generation Sequencing in Help Center and File Exchange

Products


Release

R2008a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!