11

Which package is best for a heatmap/image with sorting on rows only, but don't show any dendrogram or other visual clutter (just a 2D colored grid with automatic named labels on both axes). I don't need fancy clustering beyond basic numeric sorting. The data is a 39x10 table of numerics in the range (0,0.21) which I want to visualize.

I searched SO (see this) and the R sites, and tried a few out. Check out R Graphical Manual to see an excellent searchable list of screenshots and corresponding packages.

The range of packages is confusing - which one is the preferred heatmap (like ggplot2 is for most other plotting)? Here is what I found out so far:

base::heatmap is annoying, even with args heatmap(..., Colv=NA, keep.dendro=FALSE) it still plots the unwanted dendrogram on rows.

For now I'm going with pheatmap(..., cluster_cols=FALSE, cluster_rows=FALSE) and manually presorting my table, like this guy: Order of rows in heatmap?

Addendum: to display the value inside each cell, see: display a matrix, including the values, as a heatmap . I didn't need that but it's nice-to-have.

Community
  • 1
  • 1
smci
  • 32,567
  • 20
  • 113
  • 146
  • I'm not entirely sure what you are asking. Are you asking how to make a heatmap in ggplot? If so, you need to use `geom_tile()` – Andrie May 12 '12 at 08:44
  • @Andrie: I'm just asking which package you all recommend (how do I get sorting without clustering? and no dendrograms?). I didn't think *ggplot2* could do heatmaps, but after you mention geom_tile I found that [learnr article](http://learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting/). – smci May 12 '12 at 08:48
  • If you just want to sort, why not use `sort()`? – Andrie May 12 '12 at 08:51
  • (I know how to sort manually, but I thought we could get that for free with some of the heatmap fns.) Regardless, which package do you recommend for my use case? – smci May 12 '12 at 09:49
  • 1
    I would cluster using `hclust` or `kmeans`, or alternatively just `sort`, then plot using `ggplot2`. – Andrie May 12 '12 at 11:25

2 Answers2

6

With pheatmap you can use options treeheight_row and treeheight_col and set these to 0.

Raivo Kolde
  • 729
  • 6
  • 14
1

just another option you have not mentioned...package bipartite as it is as simple as you say

library(bipartite)
mat<-matrix(c(1,2,3,1,2,3,1,2,3),byrow=TRUE,nrow=3)
rownames(mat)<-c("a","b","c")
colnames(mat)<-c("a","b","c")
visweb(mat,type="nested")
user1317221_G
  • 15,087
  • 3
  • 52
  • 78
  • Here are screenshots of [bipartite:visweb](http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=bipartite:visweb). Looks nice, not sure how to repurpose the extra labeling options from their biological purpose. – smci May 12 '12 at 10:00