[BioC] heatmap 'contrast': suggestions for a zlim adjustment in heatmap.2

Kevin Coombes kevin.r.coombes at gmail.com
Thu Aug 19 23:13:53 CEST 2010


I've had the best results by treating heatmap as purely a display 
function, and breaking out all of the processing in previous steps. To 
make that more explicit, you can do something like

rowclust <- hclust(mydDist(mat, "myMetric"), "myLinkage")
colclust <- hclust(myDist(mat, "anotherMetric"), "anotherLinkage")
stdizedmat <- t(scale(t(mat)))
clipper <- 3
stdizedmat[stdizedmat < -clipper]<- -clipper
stdidezmat[stdizedmat > clipper] <- clipper

heatmap(stdizedmat,
       Rowv=as.dendrogram(rowclust),
       Colv=as.dendrogram(colclust),
       scale='none', zlim=c(-clipper, clipper))

Karl Brand wrote:
> Esteemed BioC Users,
>
> In pursuit of a simple method to adjust the "contrast" of a heatmap i 
> attempted to use the image() argument "zlim" in heatmap.2, both 
> directly and using add.expr. These attempts failed (shown below on my 
> example heatmap.2).
>
> heatplot() from library(made4) includes just such a convenient zlim= 
> argument, but for now i'd trying to use heatmap.2 for all my heatmap 
> needs. For the record, i can achieve what a zlim adjustment using the 
> breaks argument to specify the effective range of zlim, but specifying 
> breaks interferes with the scale argument in heatmap.2. So no good.
>
> So any suggestions for a zlim adjustment in heatmap.2 are greatly 
> appreciated, cheers,
>
> Karl
>
>
>
> #example
> toy.mat <- matrix(rnorm(1000), nrow=100, ncol=10)
> library(gplots)
>  windows()
>  plot.new()
> heatmap.2(toy.mat,
>   Rowv=T, Colv=T,
>   dendrogram="column",
>   scale= "row",
>   col=c(greenred(256)),
> #  breaks = c(seq(-10, 10, length.out = 257)),#interferes with 'scale'
>   trace="none",
>   density.info="none",
>   zlim=c(-10, 10)                     #no error, but no effect
> #  add.expr = (zlim=c(-10, 10))       #no error, but no effect
> #  add.expr = "zlim", zlim=c(-10, 10) #no error, but no effect
> #  add.expr = zlim, zlim=c(-10, 10)   #produces error
>     )
> #end
>



More information about the Bioconductor mailing list