1

I created a heatmap in R using plotly (and tried with heatmaply too). Plotly allows for some pretty standard interactivity, like drag-select to zoom. I'd like to be able to "group" parts of the heatmap together, for example, if I have a 10x10 heatmap, columns 1:3 and rows 1:3, such that when a user mouse-overs anywhere within that area, the whole block is selected and displays a tool-tip of summary statistics for that block, or for an entire column, etc. Alternatively, I'd like to be able to click on parts of the dendrogram's tree and zoom in on that.

For the latter, it looks like I can bind to on-click using Plotly, but I'm not exactly sure what function to bind to it. Any thoughts?

Versipellis
  • 121
  • 1
  • 1
  • 6
  • 1
    This is a pretty advanced request for R code, you might be better off writing your own htmlwidget using the plotly JS library. What you probably want to do is to add an extra heatmap `trace` (plotly's equivalent of ggplot2's `geom`) which contains the mouseover information. Alternatively go really advanced and have the JS generate summary statistics for selected areas on the fly. `heatmaply` already supports zooming on the dendrogram, btw – alan ocallaghan Sep 29 '17 at 18:03
  • @aocall I wonder if we would add another ggplot2 layer on top of the heatmap, if that would show up. The function in heatmaply to create the ggplot object is heatmaply:::ggplot_heatmap – Tal Galili Sep 29 '17 at 18:08
  • The difficulty there is how to control the hovertext. By default `heatmaply:::ggplot_heatmap` uses `x+y+fill` – alan ocallaghan Sep 29 '17 at 19:10
  • Is this useful? `m <- reshape2::melt(as.matrix(mtcars[1:5, 1:5]))` `heatmaply(mtcars, dendrogram="none", heatmap_layers=geom_tile(data=m, aes(y=Var1, x=Var2, fill=value, label=mean(value))))` – alan ocallaghan Sep 29 '17 at 19:19
  • Not quite too helpful :( Was hoping to have some kind of overlay for showing pre-defined groupings or something. My initial thoughts were to do this with d3.js, but d3 can't do dendrograms, or handle the amount of data I'm feeding it. With regards to zooming on the dendrogram, I was hoping for clicking on the dendrogram and automatic zooming to the rows/columns in that cut of the tree that was clicked on. – Versipellis Oct 02 '17 at 20:34

0 Answers0