[R] Heatmap construction problems

Hadley Wickham hadley at rice.edu
Sun Nov 7 17:35:28 CET 2010


It's hard to know without a minimal reproducible example, but you
probably want scale_fill_gradient or scale_fill_gradientn.

Hadley

On Thu, Oct 28, 2010 at 9:42 AM, Struchtemeyer, Chris
<strucht at okstate.edu> wrote:
> I am very new to R and don't have any computer program experience
> whatsoever.  I am trying to generate a heatmap of the following data:
>
>
>
>  Phylum,AI,AJT,BY,GA,Grt,Sm
>  Acidobacteria,0.5,0.7,2.7,0.1,2.6,1.0
>  Actinobacteria,33.7,65.1,9.7,2.0,3.9,2.1
>  Bacteroidetes,9.7,5.6,0.7,13.2,41.1,21.6
>  CCM11b,0.0,0.0,0.0,0.0,0.0,0.1
>  Chlamydiae,0.1,0.1,0.0,0.0,1.0,0.2
>  Chlorobi,0.0,0.0,0.0,0.0,0.7,1.0
>  Chloroflexi,0.1,0.2,0.6,0.2,0.8,0.6
>  Cyanobacteria,18.7,0.0,1.0,1.5,0.9,0.3
>  Ellusimicrobiales,0.0,0.0,0.0,0.0,0.0,0.0
>  Firmicutes,1.0,7.6,8.3,31.9,2.1,6.9
>  Gemmatimonadetes,5.0,0.3,0.3,0.0,0.1,0.0
>  GN02,0.0,0.0,0.0,0.0,0.0,0.5
>  Nitrospirae,0.0,0.2,1.1,0.0,0.0,0.0
>  NKB19,0.0,0.0,0.9,0.0,0.0,0.0
>  OP8,0.0,0.1,0.0,0.0,0.0,0.0
>  OP10,0.6,0.2,0.5,0.0,0.6,0.6
>  Planctomycetes,0.9,0.5,6.5,2.2,2.0,2.3
>  Alphaproteobacteria,7.8,10.7,21.8,12.2,5.3,26.8
>  Betaproteobacteria,9.9,2.8,8.9,21.7,8.3,21.9
>  Deltaproteobacteria,0.5,0.2,1.8,2.0,1.2,7.1
>  Epsilonproteobacteria,0.0,0.0,0.0,0.1,0.0,0.2
>  Gammaproteobacteria,4.0,2.5,8.0,9.4,24.7,5.4
>  SC4,0.0,0.0,0.0,0.0,0.7,0.0
>  SM2F11,0.0,0.0,0.0,0.0,0.2,0.0
>  SPAM,0.0,0.1,0.0,0.0,0.1,0.1
>  Synergistes,0.0,0.0,0.0,0.1,0.0,0.0
>  Deinococcus-Thermus,0.0,0.0,0.0,0.0,0.0,0.0
>  TM6,0.1,0.0,0.0,0.0,0.1,0.0
>  TM7,0.0,0.1,0.4,0.0,0.4,0.1
>  Verrucomicrobia,3.8,2.1,23.2,2.9,1.3,0.5
>  WPS-2,0.0,0.0,0.1,0.0,0.0,0.0
>  WS3,0.0,0.0,0.0,0.0,0.0,0.1
>  Uncl Bacteria,3.7,1.2,3.7,0.4,1.9,0.8
>
> I am a microbiologist.  What I want to do is construct a heatmap showing the
> relative abundance of each phylum.  The far left column of my table contains
> all of the phylum names I observed in a set of 6 water samples and each of
> the columns to the right contains the relative abundance (%) of each phylum
> in each water sample.  I have tried constructing a heatmap using the ggplot
> guidelines listed at the following site:
> http://learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting/
>
> I can generate a heatmap using this method, but would like to alter the
> scale.  I would like it so that I can have a little more complex gradient
> ranging from 0% to the highest relative abundance that I observe in the
> above table (65.1%).  The default scale I get using the link above is just a
> relative intensity scale ranging from 1 to 5 (where white represent low
> percentages and steelblue represented high percentages).  This is alright
> but for phyla that are present at relative abundance of less than 5% all
> appear to be white (or non-existant).  Is there anyway to fix this?  Any
> help would be greatly appreciated.
>
> Thanks,
>
> Chris
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-help mailing list