我想从包含很多行的热图中删除行标签。我需要在heatmaply和一个aheatmap中做到这一点。然而,我能想到的所有可能的选项要么导致错误,要么从1:nrow重新标记行并显示内部数字。我假设这是因为热图使用了矩阵或数据框的行名,当行名为空时,它缺省为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上的会话信息(不能升级OS,所以坚持使用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
我想要aheatmap版本的heatmap.2,没有行标签:heatmap.2 not so pretty but no row labels
发布于 2017-09-30 02:29:00
尝试在heatmaply中使用参数showticklabels。它控制行和列标签的打印。
https://stackoverflow.com/questions/39176457
复制相似问题