Labelling heatmap dendrogram
2
2
Entering edit mode
8.6 years ago
mjoyraj ▴ 80

Hi, can somebody help me fix this problem. I have gene expression data of 2314 genes for 15 conditions (alpha6; normalized and log2 transformed). I did hierarchical clustering of the genes based on expression and extracted clusters with the following scripts:

hc <- hclust(dist(alpha6))

pdf("test_clustering_tree1.pdf")

plot(hc)

clusters_name <- cutree(hc, h=15.15)

rect.hclust(hc, h=15.5)

dev.off()

table_clusters_name <- data.frame(clusters_name)

write.table(table_clusters_name,file="test_table_clusters_name.csv")

I also prepared a heatmap with ‘gplots’ packagae with the following scripts

library(gplots)

pdf("Rdataoutput1.pdf")

heatmap.2((alpha6), Rowv=as.dendrogram(hc), RowSideColors=as.character(clusters_name), trace="none", scale="row", density.info="none", col=bluered(2766))

dev.off()

I got 47 clusters. I want to have the cluster no. in the heatmap dendrogram. Can any body help me to do this? Any help will be appreciated.

R RNA-Seq • 2.7k views
ADD COMMENT
1
Entering edit mode
8.6 years ago

I'd check out the complexHeatmap package in bioconductor, that might have more flexibility than heatmap2 to achieve what you want.

ADD COMMENT
1
Entering edit mode
8.6 years ago
ivivek_ngs ★ 5.2k

Take a look at the pheatmap package in R and also take a look at this link

ADD COMMENT
0
Entering edit mode

I did it in another way, which may be partially okay. For example, I know I have 47 clusters, I choose to specify the color of the clusters rather than using the default color like this:

install.packages("plyr")

library(plyr)

new_colors <- revalue(as.character(clusters_name), c("1"="yellow4", "2"="aliceblue","3"="antiquewhite","4"="white", "5"="azure", "6"="beige", "7"="bisque","8"="black","9"="blue", "10"="blueviolet", "11"="brown", "12"="burlywood","13"="cadetblue","14"="chartreuse", "15"="chocolate", "16"="coral", "17"="cornflowerblue","18"="cornsilk","19"="cyan", "20"="darkblue", "21"="darkgray", "22"="darkgreen","23"="darkmagenta","24"="darkorange", "25"="darkred", "26"="darkviolet", "27"="gold","28"="gray","29"="green", "30"="greenyellow", "31"="honeydew", "32"="hotpink","33"="ivory","34"="khaki", "35"="lavender", "36"="lawngreen", "37"="lightblue","38"="lightcoral","39"="lightgreen", "40"="lightseagreen", "41"="magenta", "42"="maroon","43"="mediumaquamarine","44"="mediumorchid", "45"="navy", "46"="olivedrab", "47"="orange"))

heatmap.2((alpha6), Rowv=as.dendrogram(hc), RowSideColors=new_colors, trace="none", scale="row", density.info="none", col=redblue(2766))

This tells me cluster 1 has 'yellow4' color and so in. Using the color code, I can manually update the cluster no. in the dendrogram. If my technique is useful somebody may use it.

ADD REPLY
0
Entering edit mode

Yes that is fine as long as it serves your purpose but then you can also take a look at this link and see if you can make a cleaner and neat one for your future use as well or may be this link.

ADD REPLY
0
Entering edit mode

Thanks for your suggestions.

ADD REPLY

Login before adding your answer.

Traffic: 1842 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6