R Heatmaply和Pheatmap输出 [英] R heatmaply and pheatmap output

查看:385
本文介绍了R Heatmaply和Pheatmap输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R heatmaply包来生成交互式热图.我喜欢该软件,但我想从中获得与使用pheatmap包时相同的颜色输出.因此,我希望这两个命令产生相同的输出:

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

推荐答案

您可以使用formals()获取默认的颜色参数pheatmap().

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

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

然后将heatmaply()的color参数设置为相同的参数:

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")

  • 颜色功能brewer.pal()来自RColorBrewer软件包,因此您需要预先安装并加载::library().
  • heatmaply()中的
  • grid_color对应于pheatmap()中的border_color.
    • 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().
    • 这篇关于R Heatmaply和Pheatmap输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆