1

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

Darren Tsai
  • 32,117
  • 5
  • 21
  • 51
Arturo
  • 342
  • 1
  • 4
  • 14

1 Answers1

2

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().
Darren Tsai
  • 32,117
  • 5
  • 21
  • 51