Question: heatmap.2 row clustering does not look right
0
gravatar for moxu
23 months ago by
moxu440
moxu440 wrote:

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 next-gen R software error • 1.8k views
ADD COMMENTlink modified 23 months ago by Kevin Blighe51k • written 23 months ago by moxu440
3
gravatar for Kevin Blighe
23 months ago by
Kevin Blighe51k
Kevin Blighe51k wrote:

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, 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 COMMENTlink written 23 months ago by Kevin Blighe51k

Scaling is the answer! Thanks much!

ADD REPLYlink written 23 months ago by moxu440

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 REPLYlink written 23 months ago by Kevin Blighe51k
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: 1473 users visited in the last hour