从aheatmap和heatmaply中删除行标签(heatmapr)

时间:2016-08-27 00:52:12

标签: r heatmap labels heatmaply

我想从包含许多行的热图中删除行标签。我需要在heatmaply和aheatmap中执行此操作。但是,我能想到的所有可能选项都会导致错误或重新标记1:nrow中的行并显示数字intead。我假设这是因为热图使用矩阵或数据框的rownames,当rownames为空时,默认为rownames = 1:nrow。但是,heatmap.2会适当地处理这个并将它们从图中一起删除。我可以用aheatmap和heatmaply这样做吗?可重现的例子如下:

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

我尝试在Mac和带有最新R操作系统的Windows上运行它。这是我的mac会话信息(无法升级操作系统,因此坚持使用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       
> 

aheatmap产生: aheatmap with row NUMBERS

我喜欢hotmap.2的aheatat版本,没有行标签: heatmap.2 not so pretty but no row labels

1 个答案:

答案 0 :(得分:1)

在heatmaply中尝试参数showticklabels。它控制行和列标签的打印。