Tutorial: Heatmaps in R
43
gravatar for Jean-Karim Heriche
2.5 years ago by
EMBL Heidelberg, Germany
Jean-Karim Heriche18k wrote:

As heatmaps in R are a recurring theme, I thought I'd collect information here:

1. List of heatmap functions (and packages) in R:
- heatmap
- heatmap.2 (package gplots)
- heatmap.3 (package GMD)
- heatmap.plus
- aheatmap (package NMF)
- pheatmap
- ggheat (code in this blog post)
- heatmaply
- d3heatmap
- ComplexHeatmap
- Superheat
- Heatplus

2. Tutorials:
- Using heatmap()
- Using heatmap.2()
- Using ComplexHeatmap
- Using Superheat
- Guide to heatmaps in R

3. Biostars posts:
- How Do I Draw A Heatmap In R With Both A Color Key And Multiple Color Side Bars?

EDIT 2017-02-03: Added more heatmaps. Thanks to people contributing below.
EDIT 2017-03-14: Added another one.

heatmap tutorial R • 7.4k views
ADD COMMENTlink modified 23 months ago • written 2.5 years ago by Jean-Karim Heriche18k
9

We need to modify this xkcd strip to replace "standards" with "heatmap functions in R".

enter image description here

ADD REPLYlink modified 2.5 years ago by Istvan Albert ♦♦ 79k • written 2.5 years ago by Devon Ryan88k
1

...or "pipeline frameworks written in python." :) I find it is interesting there are so many tools/packages in the same application space, especially when they are implemented almost the same way.

ADD REPLYlink modified 2.5 years ago • written 2.5 years ago by SES8.1k
6

Heatmaps in R are a curious beast as they do a lot more than "just" draw the heatmap.

They promote that endemic and flawed ideology that is very common of R based software. Instead of breaking down the steps into their logical units that one can easily build upon:

  1. compute distances
  2. perform a clustering
  3. scale the data (this can be an earlier step actually and that could also matter)
  4. draw the heatmap

They give you one "convenient" function with lots of parameters - but all that leads to is a misleading simplicity. It is really not clear what takes place and whether those steps are universally applicable. Hence the many options - neither of which takes on what the real problem is - overly tightly coupled concepts.

The majority of the people that use heatmaps probably do not fully understand how these heatmaps were created and that there are essential data processing steps involved that fundamentally alter what the heatmap will look like.

ADD REPLYlink modified 2.5 years ago • written 2.5 years ago by Istvan Albert ♦♦ 79k

This reminds me of the "Quilt plot" paper a few years ago. This paper received a lot of hate but it proposed a much simpler implementation of the heatmap function in R (without clustering). I think such a paper would never have existed if the base R function was more intuitive/simple.

ADD REPLYlink written 2.5 years ago by Carlo Yague4.4k
1

And also ComplexHeatmap https://bioconductor.org/packages/release/bioc/html/ComplexHeatmap.html

ADD REPLYlink modified 2.5 years ago • written 2.5 years ago by Naga450

nice

ADD REPLYlink written 2.5 years ago by EagleEye6.2k
1

Someone mentioned to me in the office that the list is missing d3heatmap and superheat.

ADD REPLYlink written 2.5 years ago by Devon Ryan88k
1

Don't forget aheatmap from the NMF package. I also often roll my own with image() and layout(), and it is TERRIBLE!

ADD REPLYlink written 2.5 years ago by Madelaine Gogol5.0k

I do it with ggplot2 and it is awful, but I like the flexibility it gives me with the layout.

ADD REPLYlink written 23 months ago by reilly.brian.m50

Also add corrplot for correlation heatmaps.

Tutorials are here,

https://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro.html

ADD REPLYlink modified 2.5 years ago • written 2.5 years ago by EagleEye6.2k

I just wrote up a post for heatmap´╝î check here http://rpubs.com/crazyhottommy/a-tale-of-two-heatmap-functions

ADD REPLYlink written 2.4 years ago by Ming Tang2.4k

Hi Jean-Karim Heriche,

I haven't tried it (yet*) but this one looks pretty: Superheat: An R package for creating beautiful and extendable heatmaps for visualizing complex data. Also on github

*PhD-student-slang for "I would certainly like to but never will"

ADD REPLYlink written 2.0 years ago by WouterDeCoster36k

Hi Jean-Karim Heriche, I am wondering how can I make cluster heatmap, where I can assign samples to per-defiend clusters? thanks!

ADD REPLYlink written 5 days ago by h.moosavi570

Just reorder the matrix as per your clustering. If you're working with hierarchical clustering, you can do something like this with base R:

tree <- hclust(dist(data.matrix, method = ...), method = ...)
data.matrix.reordered <- data.matrix[tree$order, tree$order]
heatmap(data.matrix.reordered, Rowv= as.dendrogram(tree), Colv=as.dendrogram(tree))

Check also the various heatmap packages. For example pheatmap and ComplexHeatmap allow to split a heatmap based on clusters.

ADD REPLYlink written 5 days ago by Jean-Karim Heriche18k
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: 640 users visited in the last hour