问题
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 theRColorBrewerpackage, so you need to install and load it with::orlibrary()in advance. grid_colorinheatmaply()is corresponding toborder_colorinpheatmap().
来源:https://stackoverflow.com/questions/61931334/r-heatmaply-and-pheatmap-output