如何使用R中的下拉菜单在热图中更改热图的颜色?

时间:2018-03-26 21:47:57

标签: r plotly heatmaply

我想使用R中的下拉菜单在heatmaply中更改热图的颜色。 我写下面的代码,但无法正常工作。感谢您的帮助。

 df<- 
 structure(c(5.91907, 3.05747, 5.73896, 5.30454, 4.74619, 6.60657, 
 5.81497, -12.425, 1.93861, 5.16512, 5.93555, 2.78618, 5.67026, 
 5.2143, 4.76254, 6.61845, 5.88446, -12.425, 1.80812, 5.21011, 
 5.95742, 2.67871, 5.62981, 5.29438, 4.81968, 6.65069, 5.91714, 
-12.425, 1.88218, 5.18672, 7.47528, 10.18474, 7.36668, 3.29509, 
 6.09987, 5.10079, 6.48144, 3.0804, 0.00595, 5.7687, 7.49799, 
 10.44368, 7.29894, 3.28727, 6.12365, 5.20986, 6.51248, 1.88641, 
 -0.13119, 5.69689, 7.53807, 10.44435, 7.32447, 3.31082, 6.15386, 
 5.11612, 6.49, 3.01725, 0.19859, 5.76166), .Dim = c(10L, 6L), .Dimnames = list(
 c("Rrp9", "Prm1", "Gprc5a", "Fzd2", "Aen", "Cdkn2c", "Eps8", 
 "Mir6924", "Lpin1", "E2f8"), c("A", "B", 
 "C", "D", "E", "F"
  )))
library(magrittr)
library(heatmaply)
library(gplots)

clus <- hclust(dist(df))
d <- df[clus$order,]

 heatmaply(d , na.rm = TRUE, showticklabels =c (TRUE,FALSE) , k_col = 4, 
 k_row = 5, col=greenred(10),
  main = "HeatMap for all DE genes across all sets") %>%
 layout( updatemenus = list(
list(
 y = 0.8,
 buttons = list(
 list(method = "update",
     args = list("colors", "greenred(10)"),
     label = "GreenRed"),

list(method = "update",
     args = list("colors", "bluered(10)"),
     label = "BlueRed")))
  )) %>%  config(displayModeBar = TRUE , modeBarButtons= FALSE,setBackground= "transparent")

0 个答案:

没有答案