datapointier
datapointier

Reputation: 21

Remove row labels from aheatmap and heatmaply (heatmapr)

I would like to remove the row labels from a heatmap with many rows. I need to do this in both heatmaply and aheatmap. However, all the possible options I could think of either result in an error or relabel the rows from 1:nrow and show the numbers intead. I'm assuming this is because the heatmap uses the rownames of the matrix or data frame and when the rownames are empty it defaults to the rownames= 1:nrow. However, heatmap.2 deals with this appropriately and removes them all together from the plot. Can I do this with aheatmap and heatmaply? A reproducible example is below:

library(NMF)
library(heatmaply)
library(pheatmap)
library(gplots)


NMF::aheatmap(mtcars,labRow="") # numbers as rownames & row labels
NMF::aheatmap(mtcars,labRow=NA) # numbers as rownames & row labels

heatmaply(mtcars,labRow="")
# Error in `rownames<-`(`*tmp*`, value = "") : 
#  length of 'dimnames' [1] not equal to array extent heatmaply(mtcars,labRow=FALSE)
# Error in `rownames<-`(`*tmp*`, value = "") : 
#  length of 'dimnames' [1] not equal to array extent heatmaply(mtcars,labRow=NULL)  # numbers as rownames & row labels

# including pheatmap just in case this does work, but it doesn't
pheatmap::pheatmap(mtcars,  labels_row=FALSE) # NA as rownames pheatmap::pheatmap(mtcars,   labels_row="") # NA as rownames pheatmap::pheatmap(mtcars,labRow=FALSE) # does not remove rownames

heatmap.2(as.matrix(mtcars),labRow="") # works

I tried running this both on a mac and on a windows with the latest R operating system. This is my session info for the mac (can't upgrade OS so stuck with R 3.2.1):

    sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
Running under: OS X 10.8.5 (Mountain Lion)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] gplots_3.0.1        pheatmap_1.0.8      heatmaply_0.3.2     viridis_0.3.4       plotly_3.6.0        ggplot2_2.1.0      
 [7] NMF_0.20.6          cluster_2.0.4       rngtools_1.2.4      pkgmaker_0.22       registry_0.3        RColorBrewer_1.1-2 
[13] Biobase_2.28.0      BiocGenerics_0.14.0

loaded via a namespace (and not attached):
 [1] gtools_3.5.0       modeltools_0.2-21  reshape2_1.4.1     kernlab_0.9-24     lattice_0.20-33    colorspace_1.2-6   htmltools_0.3.5   
 [8] stats4_3.2.1       yaml_2.1.13        base64enc_0.1-3    withr_1.0.2        prabclus_2.2-6     fpc_2.1-10         foreach_1.4.3     
[15] plyr_1.8.4         robustbase_0.92-6  stringr_1.0.0      munsell_0.4.3      gtable_0.2.0       caTools_1.17.1     htmlwidgets_0.7   
[22] devtools_1.12.0    mvtnorm_1.0-5      codetools_0.2-14   memoise_1.0.0      labeling_0.3       doParallel_1.0.10  flexmix_2.3-13    
[29] class_7.3-14       DEoptimR_1.0-6     trimcluster_0.1-2  Rcpp_0.12.6        KernSmooth_2.23-15 xtable_1.8-2       scales_0.4.0      
[36] diptest_0.75-7     gdata_2.17.0       jsonlite_1.0       gridExtra_2.2.1    digest_0.6.10      stringi_1.1.1      grid_3.2.1        
[43] bitops_1.0-6       tools_3.2.1        magrittr_1.5       lazyeval_0.2.0     tibble_1.1         whisker_0.3-2      tidyr_0.5.1       
[50] dendextend_1.2.0   MASS_7.3-45        gridBase_0.4-7     rstudioapi_0.6     assertthat_0.1     httr_1.2.1         iterators_1.0.8   
[57] R6_2.1.2           mclust_5.2         nnet_7.3-12       
> 

The aheatmap produces: aheatmap with row NUMBERS

I'd like the aheatmap version of the heatmap.2 with no row labels: heatmap.2 not so pretty but no row labels

Upvotes: 2

Views: 3055

Answers (1)

alan ocallaghan
alan ocallaghan

Reputation: 3038

Try the argument showticklabels in heatmaply. It controls the printing of row and column labels.

For example

showticklabels = c(TRUE, FALSE)

Shows column but not row labels.

Upvotes: 5

Related Questions