Open DoaneAS opened 6 years ago
Hi Ashley,
When saving a static version, it renders the heatmap and then takes a snapshot, which is why it would be a raster image even if saving as a pdf.
I think it would be nicer if the heatmaps could be saved as vector graphics. I had looked into whether that would be possible sometime in the past, and remember that it seemed like it would be difficult. I might revisit this sometime in the future, but likely not anytime soon.
Ok, thank you Alicia. Great package!
Hi, Is it possible to save heatmaps with plotly::orca()? I have been unable to succeed in this task.
mtcars %>% as.matrix() %>% main_heatmap() %>% plotly::orca(file = "foo.svg")
The above R code returns an error: Error in UseMethod("plotly_build") : no applicable method for 'plotly_build' applied to an object of class "c('IheatmapHorizontal', 'Iheatmap')"
Do you have suggestions on what I might do to make the heatmap usable by plotly::orca? I'm afraid that I don't yet know enough about the methods that you use in iheatmapr. Thank you.
@fboehm: I have no time to check right now but I think there is an as.plotly
function (or the like) that should do what you need.
Thanks, @mschilli87! Do you know which package contains the as.plotly
function? It looks like it is not exported from iheatmapr or plotly.
Thanks!
@fboehm: Looks like it was called as_plotly
but was removed in 3e09ad680d848f380681c63f8d317e0eb4859338. Not sure if to_widget
can be exploited to use orca
but probably not. You might be able to look at plotly
's (the R package) implementation of the orca
(R) function though to come up with a way to pass the iheatmapr
object to an external orca
(binary) call. Sorry that I can't be of more help as of now.
Thank you, @mschilli87! I will check out the R code for the function plotly::orca. Thanks again!
@fboehm: OK - I gave this a couple of minutes and the best I came up with is this:
library(magrittr)
library(iheatmapr)
library(plotly)
hm <-
mtcars %>%
as.matrix %>%
main_heatmap
pl <- iheatmapr:::to_plotly_list(hm)
pl %>%
orca(file = "foo.svg")
This at least renders the heatmap and legend in the SVG but as to_plotly_list
is internal (hence the three :
) this expectedly doesn't go all the way. But I hope it helps to figure out the rest and maybe @AliciaSchep has some additional pointers for you.
Thank you @mschilli87! I'll use your code and see if I can extend it. Thanks again!!
Thanks @mschilli87 for your solution! It seems like it might make sense to export (and probably rename) the to_plotly_list
function to ease this use case.
An update on this issue -- latest 'dev' version of the package (0.4.10, master branch) exports the to_plotly_list
function as well as a companion to_plotly_json
which additionally converts to JSON.
Hi,
Thanks for this package it's very useful.
Wondering is it possible to save as a vector graphic?
Here's a heatmap of some analysis, saved as pdf.
motifsGainedExpressed.inpeaks.eta0.1.pdf
It seems the matrix is encoded as a raster image. Maybe something I am doing with the pdf device in R?
Thanks!
Ashley