Heatmap Visualisations?
4
5
Entering edit mode
13.0 years ago

Given a distance matrix - does anybody have any suggestions for software for producing heatmaps that is compatible with Linux. I have tried in R but it just doesn't look 'nice'.

Thanks, D.

heatmap software • 15k views
ADD COMMENT
9
Entering edit mode

in short: use ggplot (or heatmap.2) instead of the standard heatmap command

ADD REPLY
7
Entering edit mode

What do you mean by not nice, which function did you use, how do you want it to look?

There were some tools listed in these questions:

ADD REPLY
6
Entering edit mode
13.0 years ago

Nice is a relative term, what you probably mean that you want to customize it in a way that is not immediately available with the existing heatmap.

As it has been already mentioned by Michael in a comment (I'll add it here since I'd consider that an answer as well) you might want to consider alternative plotting libraries such as:

ADD COMMENT
3
Entering edit mode
13.0 years ago
Michi ▴ 990

Biostar has the answer here:

First option is also my recommendation: gitools. since it is written in java you may use it on your linux machine without problems I hope.

ADD COMMENT
3
Entering edit mode
13.0 years ago
hadasa ★ 1.0k

Here is an awesome function using ggplot to generate a heatmap(ggheat) and producing visually appealing heatmaps. Available at this post: http://rforcancer.drupalgardens.com/content/ggheat-ggplot2-style-heatmap-function

 ## m=matrix(data=sample(rnorm(100,mean=0,sd=2)), ncol=10)
 ## this function makes a graphically appealing heatmap (no dendrogram) using ggplot
 ## whilst it contains fewer options than gplots::heatmap.2 I prefer its style and flexibility

 ggheat=function(m, rescaling='none', clustering='none', labCol=T, labRow=T, border=FALSE, 
 heatscale= c(low='blue',high='red'))
 {
   ## the function can be be viewed as a two step process
   ## 1. using the rehape package and other funcs the data is clustered, scaled, and reshaped
   ## using simple options or by a user supplied function
   ## 2. with the now reshaped data the plot, the chosen labels and plot style are built

   require(reshape)
   require(ggplot2)

   ## you can either scale by row or column not both! 
   ## if you wish to scale by both or use a different scale method then simply supply a scale
   ## function instead NB scale is a base funct

   if(is.function(rescaling))
   { 
     m=rescaling(m)
   } 
   else 
   {
     if(rescaling=='column') 
       m=scale(m, center=T)
     if(rescaling=='row') 
       m=t(scale(t(m),center=T))
   }

   ## I have supplied the default cluster and euclidean distance- and chose to cluster after scaling
   ## if you want a different distance/cluster method-- or to cluster and then scale
   ## then you can supply a custom function 

   if(is.function(clustering)) 
   {
     m=clustering(m)
   }else
   {
   if(clustering=='row')
     m=m[hclust(dist(m))$order, ]
   if(clustering=='column')  
     m=m[,hclust(dist(t(m)))$order]
  if(clustering=='both')
     m=m[hclust(dist(m))$order ,hclust(dist(t(m)))$order]
   }
     ## this is just reshaping into a ggplot format matrix and making a ggplot layer

   numrows=dim(m)[1]
   numcols=dim(m)[2]
   melt.m=cbind(rowInd=rep(1:numrows, times=numcols), colInd=rep(1:numcols, each=numrows) ,melt(m))
     g=ggplot(data=melt.m)

   ## add the heat tiles with or without a white border for clarity

   if(border==TRUE)
     g2=g+geom_rect(aes(xmin=colInd-1,xmax=colInd,ymin=rowInd-1,ymax=rowInd, fill=value),colour='white')
   if(border==FALSE)
     g2=g+geom_rect(aes(xmin=colInd-1,xmax=colInd,ymin=rowInd-1,ymax=rowInd, fill=value))

   ## add axis labels either supplied or from the colnames rownames of the matrix
   if(length(labCol)==numcols)
   {
     g2=g2+scale_x_continuous(breaks=(1:numcols)-0.5, labels=labCol)
   }else
   {
     if(labCol==T) 
       g2=g2+scale_x_continuous(breaks=(1:numcols)-0.5, labels=colnames(m))
     if(labCol==F) 
       g2=g2+scale_x_continuous(breaks=(1:numcols)-0.5, labels=rep('',numcols))
   }

   if(length(labRow)==numrows)
   {
     g2=g2+scale_y_continuous(breaks=(1:numrows)-0.5, labels=labRow)
   }else
   {
     if(labRow==T)
       g2=g2+scale_y_continuous(breaks=(1:numrows)-0.5, labels=rownames(m))    
       if(labRow==F) 
       g2=g2+scale_y_continuous(breaks=(1:numrows)-0.5, labels=rep('',numrows))    
   }
   ## get rid of grey panel background and gridlines

   g2=g2+opts(panel.grid.minor=theme_line(colour=NA), panel.grid.major=theme_line(colour=NA),
   panel.background=theme_rect(fill=NA, colour=NA))

   ## finally add the fill colour ramp of your choice (default is blue to red)-- and return
   return(g2+scale_fill_continuous("", heatscale[1], heatscale[2]))

 }

Usage:(ripped from the same page)

data(mtcars)
x=as.matrix(mtcars)
ggheat(x, clustering='column', rescaling='row', heatscale=c(low='red', high='yellow'))
ADD COMMENT
2
Entering edit mode
13.0 years ago
Burke ▴ 290

I have found the following web app / source code to be a great way to visualize data as a heatmap. It is customizable enough for my needs while having almost no learning curve. Platform independant as well as it is written in C.

http://www.bioinformatics.ubc.ca/matrix2png/index.html

Update: If you are not opposed to doing a little programming, the python graphing class matlibplot has a nice heatmap output. An example with code can be found here: http://stackoverflow.com/questions/2369492/generate-a-heatmap-in-matplotlib-using-a-scatter-data-set

ADD COMMENT

Login before adding your answer.

Traffic: 1441 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