This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error: could not find function "heatmap.2"

I'm using DESeq2 and Bioconductor. When loading the heatmap I got the following error message :

Error: could not find function "heatmap.2"

Here is my pipeline:

> library( "genefilter" )

> topVarGenes <- head( order( rowVars( assay(rld) ), decreasing=TRUE ), 35 )

> heatmap.2( assay(rld)[ topVarGenes, ], scale="row",
+ trace="none", dendrogram="column",
+ col = colorRampPalette( rev(brewer.pal(9, "RdBu")) )(255))
Error: could not find function "heatmap.2"

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.1252    

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] genefilter_1.44.0       Biobase_2.22.0          DESeq2_1.2.10           RcppArmadillo_0.4.320.0 Rcpp_0.11.2             GenomicRanges_1.14.4   
[7] XVector_0.2.0           IRanges_1.20.7          BiocGenerics_0.8.0     

loaded via a namespace (and not attached):
 [1] annotate_1.40.1      AnnotationDbi_1.24.0 colorspace_1.2-4     DBI_0.2-7            digest_0.6.4         ggplot2_1.0.0       
 [7] grid_3.0.2           gtable_0.1.2         lattice_0.20-29      locfit_1.5-9.1       MASS_7.3-33          munsell_0.4.2       
[13] plyr_1.8.1           proto_0.3-10         RColorBrewer_1.0-5   reshape2_1.4         RSQLite_0.11.4       scales_0.2.4        
[19] splines_3.0.2        stats4_3.0.2         stringr_0.6.2        survival_2.37-7      XML_3.98-1.1         xtable_1.7-3        
deseq2 rna-seq heatmap

If you fail to find any function while using R just google it and see which package it comes from.

Sometimes you can even get their without bothering with a mouse. Though it seems this is not one of those times RSiteSearch("heatmap.2", restrict="functions") turns up another function but not the gplots on

3 answers

Just for those who are running into the same issue:

  1. Install the package gplots: install.packages("gplots")
  2. Run the library gplots: library(gplots)

I believe this tutorial has instructions on how to install and use the heatmap functions (including heatmap.2):

http://www2.warwick.ac.uk/fac/sci/moac/people/students/peter_cock/r/heatmap/

More specifically, you need to have the 'gplots' package installed.

heatmap.2 needs the package gplots

Log in to answer this question.