talgalili / heatmaply

Interactive Heat Maps for R Using plotly
380 stars 73 forks source link

width/height arguments unused #86

Closed danielcanueto closed 1 year ago

danielcanueto commented 7 years ago

Hi,

I'm performing interactive heatmaps with dozens of observations and features for a Shiny app. There was a change after March/April that stopped making the heatmap adapt to the size of the Shiny app window. It is very difficult to analyze the heatmap patterns in such a small heatmap. I try to change the width and height in the heatmapr function, but it doesn't seem to work.

Thank you for the reply.

Daniel

alanocallaghan commented 7 years ago

Can you post a working example please?

danielcanueto commented 7 years ago

Here there is an example:

heatmaply(heatmapr(matrix(rnorm(5000),100,50))) heatmaply(heatmapr(matrix(rnorm(5000),100,50)),height=600,width=800)

alanocallaghan commented 7 years ago

You can adjust the size of the heatmap here:

heatmaply(heatmapr(matrix(rnorm(5000),100,50))) %>% layout(height=600,width=800)

# Warning message:
# Specifying width/height in layout() is now deprecated.
# Please specify in ggplotly() or plot_ly()

I can have a look into passing the arguments in correctly, but this should work for now.

alanocallaghan commented 7 years ago

fyi, width and height in heatmapr() currently do nothing.

danielcanueto commented 7 years ago

Problem solved with layout option. Thank you for the quick reply.

alanocallaghan commented 7 years ago

@danielcanueto just going to keep this issue open so I can make the package use the width and height arguments correctly, feel free to unfollow the issue if you want

SynBioTek commented 6 years ago

@Alanocallaghan using the layout option to specify the height and width works, but the margins=c(l,r,t,b) respond differently or not at all. Why do you think that is?

alanocallaghan commented 6 years ago

Can you post an example?

tomsing1 commented 6 years ago

It seems like the use of the plotly::layout function to set width and height parameters is being deprecated in plotly. For example, the following example leads to the warning shown below:

library(heatmaply)
heatmaply(iris[,-5], k_row = 3, k_col = 2) %>%
  layout(width = 500)

causes

Warning message:
Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly() 
> sessionInfo()
R version 3.4.3 Patched (2017-12-05 r73849)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] heatmaply_0.14.1     viridis_0.5.0        viridisLite_0.3.0    plotly_4.7.1.9000   
[5] ggplot2_2.2.1.9000   BiocInstaller_1.28.0 devtools_1.13.5     

loaded via a namespace (and not attached):
 [1] httr_1.3.1          tidyr_0.8.0         jsonlite_1.5        foreach_1.4.4      
 [5] gtools_3.5.0        shiny_1.0.5         assertthat_0.2.0    stats4_3.4.3       
 [9] yaml_2.1.18         robustbase_0.92-8   pillar_1.2.1        lattice_0.20-35    
[13] glue_1.2.0          digest_0.6.15       RColorBrewer_1.1-2  colorspace_1.3-2   
[17] htmltools_0.3.6     httpuv_1.3.6.2      plyr_1.8.4          pkgconfig_2.0.1    
[21] xtable_1.8-2        purrr_0.2.4         mvtnorm_1.0-7       scales_0.5.0.9000  
[25] webshot_0.5.0       gdata_2.18.0        whisker_0.3-2       tibble_1.4.2       
[29] withr_2.1.2         nnet_7.3-12         lazyeval_0.2.1      mime_0.5           
[33] magrittr_1.5        mclust_5.4          memoise_1.1.0       MASS_7.3-49        
[37] gplots_3.0.1        class_7.3-14        Cairo_1.5-9         tools_3.4.3        
[41] registry_0.5        data.table_1.10.4-3 trimcluster_0.1-2   stringr_1.3.0      
[45] kernlab_0.9-25      munsell_0.4.3       cluster_2.0.6       fpc_2.1-11         
[49] bindrcpp_0.2        compiler_3.4.3      caTools_1.17.1      rlang_0.2.0.9001   
[53] grid_3.4.3          iterators_1.0.9     htmlwidgets_1.0     crosstalk_1.0.0    
[57] bitops_1.0-6        labeling_0.3        gtable_0.2.0        codetools_0.2-15   
[61] flexmix_2.3-14      TSP_1.1-5           reshape2_1.4.3      R6_2.2.2           
[65] seriation_1.2-3     gridExtra_2.3       prabclus_2.2-6      dplyr_0.7.4        
[69] bindr_0.1.1         KernSmooth_2.23-15  dendextend_1.7.0    modeltools_0.2-21  
[73] stringi_1.1.7       Rcpp_0.12.16        gclus_1.3.1         DEoptimR_1.0-8     
[77] diptest_0.75-7 
alanocallaghan commented 6 years ago

Hi @tomsing1, yep I think this was still the case last year (at least I noted a deprecation message above). Unfortunately I don't think one can easily specify the size of subploted figures.

PeterGrossmann commented 6 years ago

You can specify width and height when you plot to a file with the plotly::export function. Borrowing @tomsing1's example:

library(heatmaply)
h <- heatmaply(iris[, -5])
h$width <- 400
h$height <- 1200
export(h, file = "scaled_iris.png")

Ubuntu 16.04; R 3.4.2; heatmaply_0.14.1; plotly_4.7.1

alanocallaghan commented 6 years ago

Controlling file size on export is already supported in heatmaply.

export                 package:plotly                  R Documentation

Export a plotly graph to a static file

Description:

     Export a plotly graph to a static file
alanocallaghan commented 5 years ago

I guess the way to fix this without angering the plotly gods is to specify width and height based on subplot_widths/heights and the total width/height argument, which is going to be... interesting.