This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how do you remove the trace in heatmap.2 in R?

Im using the heatmap.2 function in R to create a clustered heatmap of some microarray data. My commands are written as this:

  heatmap.2 (as.matrix(highly_variable_genes,col=rev(morecols(50)),trace="none", main="Top 500 most variable genes across samples",ColSideColors=col.cell,scale="row"))

But even though I have specified that I don't want that hideous cyan squiggly 'trace' over my cells, which obscures everything, it keeps coming up. I've tried re-writing the command a few different ways and cannot get rid of it. Does anyone see what I have done wrong?

This command is taken wholesale from a tutorial that has no trace over its heatmap cells so I really dont know whats going on here...unless the commands have been updated in R.

Many thanks for your help.

heatmap.2 r microarray heat map

haha, hideous is right

1 answer

I agree that the tracing leaves much to be desired and I have never used it.

There is something peculiar about the way you have written your code - take a closer look at it. You are passing all of the following to as.matrix(), which fails to issue any warning: x,col=rev(morecols(50)),trace="none", main="Top 500 most variable genes across samples",,scale="row"

Here is a simple solution:

require(gplots)

generate random data

x <- matrix(rexp(200, rate=.1), ncol=20)

reproduce the 'bug' with trace lines

heatmap.2(as.matrix(x,col=rev(morecols(50)), trace="none", main="Top 500 most variable genes across samples",,scale="row"))

g

get rid of trace lines

heatmap.2(as.matrix(x), trace="none", main="Top 500 most variable genes across samples", scale="row")

b

Those commands for the random dataset certainly work. It must be a bug in my code, I'll look at it again and redo the whole thing. Thanks for the fix!

Log in to answer this question.