[BioC] using cutree() to figure out the labels of the left cluster on a heatmap

Thomas Girke thomas.girke at ucr.edu
Mon May 28 06:28:27 CEST 2007


Andrew,

If I understand you correctly, then the hclust components 'labels' and 'order' contain 
the information you are looking for. Below is a short example that illustrates how to 
access this data. More details on this topic including dendrogram coloring utilities 
can be found on this page:
http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/R_BioCondManual.html#R_clustering

# Generate a sample hclust object and plot it with heatmap
y <- matrix(rnorm(50), 10, 5, dimnames=list(paste("g", 1:10, sep=""), paste("t", 1:5, sep="")))
hr <- hclust(as.dist(1-cor(t(y), method="pearson")), method="complete")
hc <- hclust(as.dist(1-cor(y, method="spearman")), method="complete")
heatmap(y, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), scale="row") 

# Print the dendrogram labels (hr) in the order they appear in the tree.
hr$labels[hr$order]

# Cut the row tree by height level
mycl <- cutree(hr, h=max(hr$height)/1.5)

# Print the obtained cluster numbers in tree order
mycl[hr$order]

# Plot the heatmap with color bar where the row colors correspond to the obtained clusters
mycol <- sample(rainbow(256)); mycol <- mycol[as.vector(mycl)]
heatmap(y, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), scale="row",	RowSideColors=mycol) 



Thomas
	

On Sun 05/27/07 22:22, Andrew Yee wrote:
> I've been using heatmap(), hclust(), and cutree(), and I'm trying to figure
> out the column labels of the left (as opposed to the right) cluster.
> 
> Using cutree(x, k=2), I get two clusters labeled 1 and 2.  How do you figure
> out if cluster 2 is the one associated with the left cluster on the heatmap
> (instead of manually going to the heatmap)?
> 
> Thanks,
> Andrew
> 
> Andrew Yee, MD
> MGH Cancer Center
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
> 

-- 
Dr. Thomas Girke
Assistant Professor of Bioinformatics
Director, Bioinformatics Facility
Center for Plant Cell Biology
Department of Botany and Plant Sciences
1008 Noel T. Keen Hall
University of California
Riverside, CA 92521

E-mail: thomas.girke at ucr.edu
Website: http://faculty.ucr.edu/~tgirke
Ph: 951-827-2469
Fax: 951-827-4437



More information about the Bioconductor mailing list