Question: Labelling heatmap dendrogram
2
gravatar for mjoyraj
2.9 years ago by
mjoyraj50
Taiwan
mjoyraj50 wrote:

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.

rna-seq R • 1.2k views
ADD COMMENTlink modified 2.9 years ago by ivivek_ngs4.7k • written 2.9 years ago by mjoyraj50
1
gravatar for andrew.j.skelton73
2.9 years ago by
London
andrew.j.skelton735.5k wrote:

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

ADD COMMENTlink written 2.9 years ago by andrew.j.skelton735.5k
1
gravatar for ivivek_ngs
2.9 years ago by
ivivek_ngs4.7k
Seattle,WA, USA
ivivek_ngs4.7k wrote:

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

ADD COMMENTlink written 2.9 years ago by ivivek_ngs4.7k

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 REPLYlink modified 2.9 years ago • written 2.9 years ago by mjoyraj50

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 REPLYlink written 2.9 years ago by ivivek_ngs4.7k

Thanks for your suggestions.

ADD REPLYlink written 2.9 years ago by mjoyraj50
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1633 users visited in the last hour