[BioC] heatplot() 1. red-*black*-green palette, 2.suppress drawing of the row dendrogram (but NOT row reordering)

Karl Brand k.brand at erasmusmc.nl
Mon Aug 9 15:48:53 CEST 2010


Hi Heidi,

That's *exactly* what i wanted- an example of how to adjust these major 
aspects of a heat map, which i hope will help biologists in the future 
attempting this. Additionally the actual metrics are precisely what my 
data appear to 'like'.

But i still cant move over to heatmap.2 having discovered the usefulness 
of heatplot's "dualScale=" argument which really 'tames' one or two 
outlying samples in my data (but may ultimately be discarded). And the 
"zlim=" arg is also very convenient. Both absent in heatmap.2 and too 
complex for me to 'port' them to heatmap.2 .

I did also successfully mod heatplot() to use any 3 colors by replacing 
the following line in heatplot:
hmcol <- colorRampPalette(brewer.pal(10, "RdBu"))(256)

with, eg:

hmcol <- redgreen(256)		#To yield the red/black/green
or, per your suggestion:
hmcol <- colorpanel(256, "blue", "black", "yellow")

So for now, its heatplot with the unwanted row dendrogram, or heatmap 
without the additional row & column scaling.

Thanks again for your help, really appreciated,

karl


On 8/8/2010 9:51 PM, Heidi Dvinge wrote:
>> Hi Heidi,
>>
>> Thank you for your thoughts and suggestions,
>>
>> On 8/7/2010 6:49 PM, Heidi Dvinge wrote:
>>> Hello Karl,
>>>
>>> I'm not familiar with the made4 package, but it looks like some of the
>>> changes you want cannot override the defaults from heatplot. Are there
>>> any
>>> particular reason why you don't want to use heatmap.2 directly? Using
>>> your
>>> example from below, then
>>
>> The stated defaults of heatplot() follow the methodology by Eisen et al
>> 1998. This is my starting point, and i must admit, my data 'looks' v.
>> good using these distance (Pearson Correlation coefficient) and linkage
>> (average) methods.
>>
> Is something like this more what you're after?
>
> library(gplots)
> my.mat<- matrix(rnorm(250), nrow=50, ncol=5)
> dist.pear<- function(x) as.dist(1-cor(t(x)))
> hclust.ave<- function(x) hclust(x, method="average")
>
> heatmap.2(my.mat, col=c(redgreen(256)), dendrogram="col", trace="none",
> density.info="none", distfun=dist.pear, hclustfun=hclust.ave)
>
> Although, looking at the heatplot function they use a slightly different
> function to calculate the distance.
>
> distEisen<- function(x, use = "pairwise.complete.obs") {
>          co.x<- cor(x, use = use)
>          dist.co.x<- 1 - co.x
>          return(as.dist(dist.co.x))
> }
>
> HTH
> \Heidi
>
>> *If* i knew how to implement these in heatmap.2() i would. I assume the
>> arguments: "hclustfun =" and "distfun =" could be modified to deliver
>> what ever i want, including Pearson Correlation coefficient and linkage
>> average linkage methods. But it would be trial, error and googling to
>> acheive this. Which is my next step, unless some one has the patience to
>> provide an example or point me to one (cheers!). So this is my sole
>> reason for using heatplot over heatmap.2 (or heatmap).
>>
>>>
>>> library(gplots)
>>> my.mat<- matrix(rnorm(250), nrow=50, ncol=5)
>>> heatmap.2(my.mat, col=c(redgreen(256)), dendrogram="col", trace="none",
>>> density.info="none")
>>>
>>> will give you something similar to
>>>
>>> heatplot(my.mat, dend="both", cols.default=TRUE)
>>>
>>> only with the colours you want, and without the row dendrogram (but with
>>> row reordering).
>>>
>>> If you want to use heatplot() because you actually have some made4
>>> defined
>>> object and not a matrix to begin with, then note that the first couple
>>> of
>>> lines in the heatplot() code are
>>>
>>> data<- array2ade4(dataset)
>>> data<- as.matrix(data)
>>>
>>> Presumably you can call something like that on your data first, to get a
>>> matrix that can be plotted with heatmap.2
>>>
>>> On an different note, then green-black-red isn't really the optimal
>>> colour
>>> scheme due to the number of red/green colour blind people. Consider
>>> using
>>> maybe blue-black-yellow or something else instead.
>>
>> I never considered this aspect. Indeed i will.
>>
>> Thanks again for your thoughts and any further ones you (or anyone else)
>> may have,
>>
>> Karl
>>
>> The RColorBrewer
>>> package also has a range of pre-defined colour schemes. Check out e.g.
>>> display.brewer.all(9)
>>>
>>> HTH
>>> \Heidi
>>>
>>>> Hi Jim,
>>>>
>>>> Sorry- guilty of impatience/laziness.
>>>>
>>>> Find below what i ran on my machine and the errors i received. I
>>>> thought
>>>> given heatplot() is based on heatmap.2(), i could just use some
>>>> heatmap.2() arguments to get what i wanted. I failed and lack the
>>>> understanding to modify heatplot() myself to achieve my goal-
>>>> red-BLACK-green colors and suppressing drawing of the row dendrogram.
>>>>
>>>> All tips greatly appreciated,
>>>>
>>>> Karl
>>>>
>>>> ###run local###
>>>> # Bioc examples heatplot() returned errors:
>>>> library(made4)
>>>> my.mat<- matrix(rnorm(250), nrow=50, ncol=5)
>>>>
>>>> # 1. default works fine:
>>>> windows()
>>>> plot.new()
>>>> heatplot(my.mat, dend="both", cols.default=TRUE)
>>>>
>>>> # 2. attempt  red/black/green palette with hetamap.2 col= arg
>>>> windows()
>>>> plot.new()
>>>> heatplot(my.mat, dend="both", cols.default=FALSE, col =
>>>> c(redgreen(256)))
>>>>
>>>> # 3. attempt to supress drawing row dendrogram tree not NOT row
>>>> reordering
>>>> windows()
>>>> plot.new()
>>>> heatplot(my.mat, dend="both", cols.default=TRUE, dendrogram = "column")
>>>>
>>>> ###end
>>>>
>>>> #2. returned:
>>>>    >Error in heatmap.2(data, Colv = Colv, Rowv = Rowv, col = plotcols,
>>>> scale = scale,  :
>>>>    >    formal argument "col" matched by multiple actual arguments
>>>>
>>>> #3. returned:
>>>>    >Error in heatmap.2(data, Colv = Colv, Rowv = Rowv, col = plotcols,
>>>> scale = scale,  :
>>>>    >    formal argument "dendrogram" matched by multiple actual arguments
>>>>
>>>>    >   sessionInfo()
>>>> R version 2.10.0 (2009-10-26)
>>>> i386-pc-mingw32
>>>>
>>>> locale:
>>>> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
>>>> States.1252
>>>> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>>>>
>>>> [5] LC_TIME=English_United States.1252
>>>>
>>>> attached base packages:
>>>>     [1] grid      grDevices datasets  splines   graphics  stats
>>>> tcltk
>>>>        utils     methods
>>>> [10] base
>>>>
>>>> other attached packages:
>>>>     [1] made4_1.20.0         scatterplot3d_0.3-29 RColorBrewer_1.0-2
>>>> ade4_1.4-14
>>>>     [5] gplots_2.7.4         caTools_1.10         bitops_1.0-4.1
>>>> gtools_2.6.1
>>>>     [9] reshape_0.8.3        plyr_0.1.9           gdata_2.7.1
>>>> svSocket_0.9-48
>>>> [13] TinnR_1.0.3          R2HTML_1.59-1        Hmisc_3.7-0
>>>> survival_2.35-7
>>>>
>>>> loaded via a namespace (and not attached):
>>>> [1] cluster_1.12.1  lattice_0.17-26 svMisc_0.9-56   tools_2.10.0
>>>>
>>>>
>>>>
>>>> On 8/6/2010 7:34 PM, James W. MacDonald wrote:
>>>>> Hi Karl,
>>>>>
>>>>> You need to show us the function call you used rather than saying what
>>>>> you did. The errors indicate that you used the 'col' argument twice in
>>>>> the first attempt and the 'dendrogram' argument twice in the second
>>>>> attempt. But without seeing exactly what you did, nobody can say for
>>>>> sure.
>>>>>
>>>>> Best,
>>>>>
>>>>> Jim
>>>>>
>>>>>
>>>>>
>>>>> On 8/6/10 11:55 AM, Karl Brand wrote:
>>>>>> Esteemed BioC Users,
>>>>>>
>>>>>> Could some one help me obtain the garden variety microarray heatmap
>>>>>> "red-*black*-green" palette in heatplot()? Using-
>>>>>>
>>>>>> lowcol="green", highcol="red"
>>>>>>
>>>>>> -has no black transition between red and green.
>>>>>>
>>>>>> Since its based on heatmap.2, i thought i could achieve this by
>>>>>> passing the following argument to heatplot():
>>>>>>
>>>>>> cols.default=FASLE #to suppress default color palette
>>>>>> col = c(redgreen(256))
>>>>>>
>>>>>> but get the error-
>>>>>>
>>>>>>> Error in heatmap.2(data, Colv = Colv, Rowv = Rowv, col = plotcols,
>>>>>> scale = scale, :
>>>>>>> formal argument "col" matched by multiple actual arguments
>>>>>>
>>>>>> I'd also like to suppress drawing of the row dendrogram (but NOT the
>>>>>> reordering or rows), but again the heatmap.2 argument to do this-
>>>>>>
>>>>>> dendrogram = "column" #draw only column dendrograms
>>>>>>
>>>>>> returned-
>>>>>>
>>>>>>> Error in heatmap.2(data, Colv = Colv, Rowv = Rowv, col = plotcols,
>>>>>> scale = scale, :
>>>>>>> formal argument "dendrogram" matched by multiple actual arguments
>>>>>>
>>>>>> With thanks in advance, cheers,
>>>>>>
>>>>>> Karl
>>>>>>
>>>>>
>>>>
>>>> --
>>>> Karl Brand
>>>> Department of Genetics
>>>> Erasmus MC
>>>> Dr Molewaterplein 50
>>>> 3015 GE Rotterdam
>>>> T +31 (0)10 704 3457 |F +31 (0)10 704 4743 |M +31 (0)642 777 268
>>>>
>>>> _______________________________________________
>>>> Bioconductor mailing list
>>>> Bioconductor at stat.math.ethz.ch
>>>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>>>> Search the archives:
>>>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>>>
>>>
>>>
>>
>> --
>> Karl Brand
>> Department of Genetics
>> Erasmus MC
>> Dr Molewaterplein 50
>> 3015 GE Rotterdam
>> T +31 (0)10 704 3457 |F +31 (0)10 704 4743 |M +31 (0)642 777 268
>>
>
>

-- 
Karl Brand <k.brand at erasmusmc.nl>
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268



More information about the Bioconductor mailing list