4

Using the heatmap function of made4, I made this heatmap dendrogram from the example file:

data(khan)
heatplot(khan$train[1:30,], lowcol="blue", highcol="red")

How can I add a panel of labels for the samples on the edges of the heatmap, like in this figure?

enter image description here

The labels in this case are the squares that are adjacent to the heatmap first col and top row, used to denote a label for each sample so that one can see if the labels correspond with the clustering shown by the heatmap/dendrogram. In this particular plot they chose to make those labels correspond exactly to the colors of the dendrogram clusters but it doesn't have to be this way, I'm looking for way to just add a generic column and row of labels to the samples which might not correspond to the clustering resulting from applying a particular threshold of the dendrogram.

The heatmap function and the khan data is from made4:

require(made4)

see http://www.bioinf.ucd.ie/people/aedin/R/pages/made4/html/heatplot.html

I'm happy to use alternatives to heatplot that can draw the same thing, a heatmap with two dendrograms along the side based on hierarchical clustering. heatplot is just an example.

When I try heatmap.2 like @HeatherTurner suggested I get this image (not sure how to turn off row/column labels on matrix to make it less clustered):

enter image description here

The heatmap looks corrupted. Here's code that reproduces this with a small data set:

require(gplots)
data(khan)
heatmap.2(as.matrix(khan$train[1:30,])

which generates this: enter image description here

What is causing these corrupted looking heatmaps?

update: apologies, I think the heatmaps are not corrupted it's just the trace column is on which causes the cyan line to be drawn through heatmap. setting trace=none resolves the issue.

ps it looks like heatmap has RowSideCols, which might be same argument?

  • You will probably have to explain where the function `heatplot` is from, and possibly where the `khan` data came from as well. (I can't seem to find either.) – joran Jul 25 '13 at 14:33
  • @joran: it's `made4`, added clarification, thanks –  Jul 25 '13 at 14:38
  • Ah, that explains it. Not on CRAN. – joran Jul 25 '13 at 14:39
  • @joran: I'm happy to use some thing other than heatplot if it can draw the same thing, that's just the easiest thing I found –  Jul 25 '13 at 14:40
  • if you want to use ggplot2, maybe [this helps](http://stackoverflow.com/questions/17370853/align-ggplot2-plots-vertically/17371177#17371177) (I never know what those rooty things mean) – baptiste Jul 25 '13 at 14:53
  • @baptiste: always prefer ggplot! thanks. which rooty things? –  Jul 25 '13 at 15:06

2 Answers2

2

Try the heatmap.2 function from the gplots package, which has arguments RowSideColors and ColSideColors to create side bars.

If this doesn't meet your needs, the heatmap.plus package allows further customisation, such as multiple colour side bars.

Heather Turner
  • 3,264
  • 23
  • 30
  • see my edits. I think `heatmap` has the same argument you refer to from `gplots` and `heatmap.2` does not work for me for some reason - it gives a messed up image –  Jul 27 '13 at 20:10
0

There is a new package called 'fheatmap' in R .

cpan fheatmap

I couldn't post image as I am new to blog.But check out examples in the manual.

Jose Ricardo Bustos M.
  • 8,016
  • 6
  • 40
  • 62
advert pub
  • 11
  • 1