R heatmaply and pheatmap output

試著忘記壹切 提交于 2020-06-17 01:01:09

问题


I am using the R heatmaply package to produce interactive heatmaps. I like the software, but I would like to get from it the same color output I get using the pheatmap package. Therefore, I would like the two commands to produce the same ouput:

heatmaply (scale (mtcars))
pheatmap  (scale (mtcars))

Is there a way to do this? Thanks in advance. Arturo


回答1:


You can use formals() to get the default color argument of pheatmap().

formals(pheatmap)$color
# colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(100)

Then set the color argument of heatmaply() to the same one:

col <- colorRampPalette(rev(RColorBrewer::brewer.pal(n = 7, name = "RdYlBu")))(100)
heatmaply(scale(mtcars), colors = col, grid_color = "grey60")
  • The color function brewer.pal() is from the RColorBrewer package, so you need to install and load it with :: or library() in advance.
  • grid_color in heatmaply() is corresponding to border_color in pheatmap().


来源:https://stackoverflow.com/questions/61931334/r-heatmaply-and-pheatmap-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!