jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.32k stars 228 forks source link

Error in `guess_align_legend`? #531

Closed bblodfon closed 4 years ago

bblodfon commented 4 years ago

Hi,

I recently updated to the development version (2.5.4) and I found this error when I run the default example (the legend is not shown):

set.seed(123)
nr1 = 4; nr2 = 8; nr3 = 6; nr = nr1 + nr2 + nr3
nc1 = 6; nc2 = 8; nc3 = 10; nc = nc1 + nc2 + nc3
mat = cbind(rbind(matrix(rnorm(nr1*nc1, mean = 1,   sd = 0.5), nr = nr1),
          matrix(rnorm(nr2*nc1, mean = 0,   sd = 0.5), nr = nr2),
          matrix(rnorm(nr3*nc1, mean = 0,   sd = 0.5), nr = nr3)),
    rbind(matrix(rnorm(nr1*nc2, mean = 0,   sd = 0.5), nr = nr1),
          matrix(rnorm(nr2*nc2, mean = 1,   sd = 0.5), nr = nr2),
          matrix(rnorm(nr3*nc2, mean = 0,   sd = 0.5), nr = nr3)),
    rbind(matrix(rnorm(nr1*nc3, mean = 0.5, sd = 0.5), nr = nr1),
          matrix(rnorm(nr2*nc3, mean = 0.5, sd = 0.5), nr = nr2),
          matrix(rnorm(nr3*nc3, mean = 1,   sd = 0.5), nr = nr3))
   )
mat = mat[sample(nr, nr), sample(nc, nc)] # random shuffle rows and columns
rownames(mat) = paste0("row", seq_len(nr))
colnames(mat) = paste0("column", seq_len(nc))

ComplexHeatmap::Heatmap(mat)

Error in guess_align_legend(object, object@heatmap_legend_param$size, : 'list' object cannot be coerced to type 'double'

Here is my R session info:

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS, RStudio 1.2.5033

Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
  LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

Package version:
  assertthat_0.2.1     BH_1.72.0.3          bibtex_0.4.2.2       BiocGenerics_0.32.0  circlize_0.4.10     
  Ckmeans.1d.dp_4.3.2  cli_2.0.2            clipr_0.7.0          clue_0.3-57          cluster_2.1.0       
  colorspace_1.4-1     compiler_3.6.3       ComplexHeatmap_2.5.4 crayon_1.3.4         digest_0.6.25       
  dplyr_0.8.5          ellipsis_0.3.1       emba_0.1.5           evaluate_0.14        fansi_0.4.1         
  gbRd_0.4-11          GetoptLong_1.0.0     GlobalOptions_0.1.2  glue_1.4.1           graphics_3.6.3      
  grDevices_3.6.3      grid_3.6.3           highr_0.8            hms_0.5.3            htmltools_0.4.0     
  htmlwidgets_1.5.1    igraph_1.2.5         IRanges_2.20.2       jsonlite_1.6.1       knitr_1.28          
  lattice_0.20.41      lifecycle_0.2.0      magrittr_1.5         markdown_1.1         Matrix_1.2.18       
  methods_3.6.3        mime_0.9             packrat_0.5.0        parallel_3.6.3       pillar_1.4.4        
  pkgconfig_2.0.3      plogr_0.2.0          png_0.1-7            purrr_0.3.4          R6_2.4.1            
  RColorBrewer_1.1-2   Rcpp_1.0.4.6         Rdpack_0.11-1        readr_1.3.1          rje_1.10.15         
  rjson_0.2.20         rlang_0.4.6          rstudioapi_0.11      S4Vectors_0.24.4     shape_1.4.4         
  stats_3.6.3          stats4_3.6.3         stringi_1.4.6        stringr_1.4.0        tibble_3.0.1        
  tidyr_1.1.0          tidyselect_1.1.0     tools_3.6.3          usefun_0.4.7         utf8_1.1.4          
  utils_3.6.3          vctrs_0.3.0          visNetwork_2.0.9     xfun_0.14            yaml_2.2.1
bblodfon commented 4 years ago

Just checked that it works with version 2.4.2.

jokergoo commented 4 years ago

Can you reinstall the package? Version 2.5.4 is a version still under development and at the time you installed, it might be still not usable.

On my laptop, with the newest version, it works fine:

image

bblodfon commented 4 years ago

Hi @jokergoo, I installed the 2.5.4 version like 15 hours ago and I do not see any commits since then, so the problem will be there still. I believe though that it has to do with the R version and dependencies updates. Since it works with the latest version from Bioconductor with the respective R version, I will close this issue (unless it manifests itself later and needs to be reopened :)

anmej commented 4 years ago

@bblodfon @jokergoo

Reverting to commit 808d354 solves the issue.

jokergoo commented 4 years ago

Em... I noticed you are using Rstudio which I haven't tested...

jokergoo commented 4 years ago

Hi, I finally captured this error. It is due to the difference between R3.6 and R4.0. Now I have fixed it. It works for both R versions.

Yingjie4Science commented 4 years ago

Hi, I finally captured this error. It is due to the difference between R3.6 and R4.0. Now I have fixed it. It works for both R versions.

I am using "R version 3.6.2 (2019-12-12) and packageVersion('ComplexHeatmap'): ‘2.5.4’, and I am still facing the error:

Error in guess_align_legend(object, object@heatmap_legend_param$size, : 'list' object cannot be coerced to type 'double'"

jokergoo commented 4 years ago

@YingjieLiScience Can you try to restart your R session? I tried with R3.6.2 and it works fine.

> m = matrix(rnorm(100), 10)
> Heatmap(m)
> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.4

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

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

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

other attached packages:
[1] ComplexHeatmap_2.5.4 colorout_1.2-1      

loaded via a namespace (and not attached):
 [1] circlize_0.4.9      IRanges_2.18.3      png_0.1-7          
 [4] digest_0.6.25       stats4_3.6.2        GlobalOptions_0.1.2
 [7] S4Vectors_0.22.1    GetoptLong_0.1.8    RColorBrewer_1.1-2 
[10] rjson_0.2.20        parallel_3.6.2      compiler_3.6.2     
[13] clue_0.3-57         BiocGenerics_0.30.0 colorspace_1.4-1   
[16] cluster_2.1.0       shape_1.4.4   

If it still fails, can you paste the output of ComplexHeatmap:::draw_legend?

Yingjie4Science commented 4 years ago

Thanks @jokergoo ! my code works well now.

jokergoo commented 4 years ago

Great!