pheatmap: Color for NA

前端 未结 5 1706
梦谈多话
梦谈多话 2021-02-05 17:41

Using R package pheatmap to draw heatmaps. Is there a way to assign a color to NAs in the input matrix? It seems NA gets colored in white by default. E.g.:

libra         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 18:31

    You can enable assigning a colour by using the developer version of pheatmap from github. You can do this using devtools:

    #this part loads the dev pheatmap package from github
    if (!require("devtools")) {
      install.packages("devtools", dependencies = TRUE)
      library(devtools)
    }
    install_github("raivokolde/pheatmap")
    

    Now you can use the parameter "na_col" in the pheatmap function:

    pheatmap(..., na_col = "grey", ...)
    

    (edit) Don't forget to load it afterwards. Once it is installed, you can treat it as any other installed package.

提交回复
热议问题