2

我想从包含多行的热图中删除行标签。我需要在热图和热图中都这样做。但是,我能想到的所有可能选项要么导致错误,要么从 1:nrow 重新标记行并显示数字。我假设这是因为热图使用矩阵或数据框的行名,当行名为空时,它默认为行名 = 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

我想要没有行标签的 heatmap.2 的 aheatmap 版本: heatmap.2 不太漂亮,但没有行标签

4

1 回答 1

4

试试showticklabelsheatmaply 中的论点。它控制行和列标签的打印。

于 2017-09-29T18:29:00.003 回答