talgalili / d3heatmap

A D3.js-based heatmap htmlwidget for R
Other
236 stars 95 forks source link

large matrices cannot be opened in any browser #65

Open stanstrup opened 8 years ago

stanstrup commented 8 years ago

I know this is not really a bug but I was hoping there would be some solution.

I am trying to visualized a 1500x1500 correlation matrix. R crashes if I try to show it directly. I can write it to a file with saveWidget but no browsers are able to show it (most crashes or simply shows nothing in the end waiting for a script to finish). The html file is 25MB.

Is there something I can try to make this work or can d3heatmap be optimized somehow?

talgalili commented 8 years ago

Hi @stanstrup -

You can have a look at the new heatmaply package: https://github.com/talgalili/heatmaply

It uses the plotly.js engine and can deal with larger matrix sizes (which was one of the reason I started working on it).

However, I suspect that 1500x1500 may be a bit too much (because of the overhead of parts of the code, actually plot.ly CAN deal with such a matrix). Try it, and if it doesn't work you can use the native haetmap of plot.ly (which wouldn't include the dendrograms)

n <- 200
x <- matrix(rnorm(n*n), nrow = n)

library(heatmaply)
heatmaply(x)

For larger n:

library(plotly)
plot_ly(z = x, type = "heatmap")
stanstrup commented 8 years ago

Thanks. That does seem to work. Even heatmaply. There seem to be some other smaller issues that I will report in your repo when I have investigated a bit more the minimal trigger.

talgalili commented 7 years ago

The heatmaply R package is a new implementation of interactive cluster heatmaps in R which relies on the plotly R package. This is based on a fork of my work in d3heatmap.

The package is availabale from CRAN: https://cran.r-project.org/package=heatmaply

The feature you've requested is now available by using the new plotly plot_method, for example, using the following code (you can play with larger numbers, and it can still handle them much better than d3heatmap):

library(heatmaply)
bix_x <- matrix(1:10000, 100,100)
heatmaply(bix_x, plot_method = "plotly")

image