heatmap.2 row clustering does not look right
1
0
Entering edit mode
6.4 years ago
moxu ▴ 510

Heatmap Example

Image is at https://imgur.com/CDzSiLU

I am using R heatmap.2.

Take a look at the above heatmap generated by heatmap.2. There are 5 big clusters of rows: 1 yellow/red, 2 red/yellow, 3 yellow/red, 4 red/yellow, 5 yellow/red.

Shouldn't the yellow/red clusters cluster together, and red/yellow ones cluster together, and then form the biggest cluster?

The R code is as follows:

heatmap.2(data.matrix(heatmapEntries), main="xxx", dendrogram="row", Rowv = TRUE, Colv=FALSE, margins=c(11.3333333333333,5), scale="row", trace = "none", cexRow=1, lhei=c(1,10), lwid=c(1,3));

Thanks in advance!

RNA-Seq software error next-gen R • 4.4k views
ADD COMMENT
3
Entering edit mode
6.4 years ago

Not necessarily, but you can modify the ordering of the heatmap with the reorderfun parameter to heatmap.2. For example, try:

heatmap.2(..., reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean), ...)

You can choose any mathematical parameter here, including min, max, var, sd, etc.


You can also modify the scaling to see how that modifies the heatmap ordering. For example, to scale to Z-scores (by gene), use:

heatZ <- t(scale(t(heatmapEntries)))

heatmap.2(data.matrix(heatZ),
  ...,
  scale = 'none',
  reorderfun = function(d,w) reorder(d, w, agglo.FUN=mean),
  ...)

For other suggestions, see my answer here: A: How to cluster the upregulated and downregulated genes in heatmap?

ADD COMMENT
0
Entering edit mode

Scaling is the answer! Thanks much!

ADD REPLY
0
Entering edit mode

Okay, but, as per the other thread, scaling is usually combined with a 'breaks' parameter:

heatZ <- t(scale(t(heatmapEntries)))
myBreaks <- seq(-3, 3, length.out=101)
heatmap.2(data.matrix(heatZ), ..., breaks=myBreaks, scale="none", reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean), ...)

Also important to realise that the heatmap / hierarchical clustering is just for the purposes of visualisation. The genes that you supplied to your heatmap would have presumably been derived from expression data on a different scale (if RNA-seq, most like negative binomial).

ADD REPLY

Login before adding your answer.

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