Question: How To Generate A Smaller, Simpler Heatmap Similar To A Tile?
3
gravatar for k.nirmalraman
6.5 years ago by
k.nirmalraman1000
Germany
k.nirmalraman1000 wrote:

I am trying to make a heatmap and the was able to achieve the one I wanted. However, I have a feeling it looks clumpsy. Y is a 4 column matrix with expression values

y<-ave_scaledCounts[Gene_Markers,]
hr <- hclust(as.dist(1-cor(t(y), method="pearson")), method="centroid"); 
hc <- hclust(as.dist(1-cor(y, method="spearman")), method="centroid")  
# Cuts the tree and creates color vector for clusters.
mycl <- cutree(hr,k=4, h=max(hr$height)/2); 
mycolhc <- rainbow(length(unique(mycl)), start=0.1, end=0.9); mycolhc <- mycolhc[as.vector(mycl)] 
myheatcol <- bluered(75) 
pdf("Hierarchial_Clustering/Final_HeatMap Hierarchial clustering.pdf",width=9,height=7)
heatmap.2(y, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), col=myheatcol, scale="row", density.info="none", trace="none",   
     +    RowSideColors= mycolhc,margins=c(10,10),keep.dendro=FALSE)
dev.off()

. I would like the heatmap in itself to be smaller in area... preferable like a tile!! The dendograms are not neccessary and the color key could be even thinner! ANy help would be great! Thanks!

EDIT: Would it just be possible to make a better heatmap if I just have the clusters in order already?? May be ggplot2 package enter image description here

heatmap • 4.0k views
ADD COMMENTlink modified 6.5 years ago by Alex Reynolds29k • written 6.5 years ago by k.nirmalraman1000

clearly this scale is not appropriate for correlations. wouldn't you normally calculate some kind of distance value?

ADD REPLYlink written 6.5 years ago by Jeremy Leipzig18k

I thought I was doing it here as.dist(1-cor(t(y)

Do you mean the color scale is not appropriate? If you dont mind could you expand a bit more??

ADD REPLYlink written 6.5 years ago by k.nirmalraman1000

have you tried just euclidean distances on the raw data?

dists<-dist(t(y))
heatmap( as.matrix( dists ))
ADD REPLYlink modified 6.5 years ago • written 6.5 years ago by Jeremy Leipzig18k

This just made a huge square with same color, I mean the clusters cannot be seen. I added col=myheatcol"

ADD REPLYlink written 6.5 years ago by k.nirmalraman1000
1
gravatar for Alex Reynolds
6.5 years ago by
Alex Reynolds29k
Seattle, WA USA
Alex Reynolds29k wrote:

Perhaps you could try myheatcol <- colorpanel(3, "#0000ff", "#ffffff", "#ff0000") or myheatcol <- bluered(3) to "force" each cell to fall into one of three colors.

Even narrower would be myheatcol <- colorpanel(2, "#0000ff", "#ff0000") or myheatcol <- bluered(2). In that case, a cell is either blue or red.

This probably won't work too well for smaller clusters, but it should work okay for larger ones, I'd think.

If you want to keep a blue-to-white gradient for values from -1.5 to 0 and have all z-scores greater than 0 be painted one shade of red, you could construct a color palette vector like so:

> myheatcol.bluewhite <- colorpanel(128, "#0000ff", "#ffffff") 
> myheatcol.red <- rep("#0000ff", 127)
> myheatcol <- c(myheatcol.bluewhite, myheatcol.red)
ADD COMMENTlink modified 6.5 years ago • written 6.5 years ago by Alex Reynolds29k

Thank you!! Actually, the color gradient is just fine.. I would however like to know how can I

  1. reduce the size of the heatmap (width of the heatmap matrix)
  2. remove the dendogram without changing the order (the data can also be already pre-ordered if required... however, HC does a )good job too
ADD REPLYlink written 6.5 years ago by k.nirmalraman1000
0
gravatar for Fwip
6.5 years ago by
Fwip490
United States
Fwip490 wrote:

Have you tried heatmap.2( ..., dendrogram = "none" ... ) to turn off the dendrogram? Remember to check ? heatmap.2 for usage info.

ADD COMMENTlink written 6.5 years ago by Fwip490

I tried dendogram="none" but did not help :( The problem is I am loosing the clusters if I do not include rowv and colv...

ADD REPLYlink written 6.5 years ago by k.nirmalraman1000
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: 802 users visited in the last hour