jokergoo / ComplexHeatmap

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

Multiple row splices using ComplexHeatmap_2.3.5 / R 4.0 lead to messed up heatmap #466

Closed Baurice closed 4 years ago

Baurice commented 4 years ago

Curious to know whether this is a reproducible problem in R 4.0 / ComplexHeatmap_2.3.5 - currently running:

R Under development (unstable) (2020-04-27 r78310)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

When splitting a heatmap by more than two row splices the graph is messed up. (Working fine with R 3.6.2 and ComplexHeatmap_2.2.0; issue existed on Ubuntu 19.10 and earlier R-devel versions a well). See example from the vignette:

suppressPackageStartupMessages(library(ComplexHeatmap))
# examples from the vignette:
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))
## works:
Heatmap(mat, name = "mat", 
        row_split = rep(c("A", "B"), 9), column_split = rep(c("C", "D"), 12))

## fails:
Heatmap(mat, name = "mat", 
        row_split = data.frame(rep(c("A", "B"), 9), rep(c("C", "D"), each = 9)))

BiocManager::valid()
#> Warning: 0 packages out-of-date; 1 packages too new
#> 
#> * sessionInfo()
#> 
#> R Under development (unstable) (2020-04-27 r78310)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04 LTS
#> 
#> Matrix products: default
#> BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] grid      stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#> [1] ComplexHeatmap_2.3.5
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.4.6        knitr_1.28          cluster_2.1.0      
#>  [4] magrittr_1.5        colorspace_1.4-1    clue_0.3-57        
#>  [7] rjson_0.2.20        rlang_0.4.5         stringr_1.4.0      
#> [10] highr_0.8           tools_4.1.0         parallel_4.1.0     
#> [13] circlize_0.4.8      xfun_0.13           png_0.1-7          
#> [16] htmltools_0.4.0     yaml_2.2.1          digest_0.6.25      
#> [19] BiocManager_1.30.10 RColorBrewer_1.1-2  GlobalOptions_0.1.1
#> [22] shape_1.4.4         evaluate_0.14       rmarkdown_2.1      
#> [25] stringi_1.4.6       compiler_4.1.0      GetoptLong_0.1.8   
#> 
#> Bioconductor version '3.11'
#> 
#>   * 0 packages out-of-date
#>   * 1 packages too new
#> 
#> create a valid installation with
#> 
#>   BiocManager::install("ComplexHeatmap", update = TRUE, ask = FALSE)
#> 
#> more details: BiocManager::valid()$too_new, BiocManager::valid()$out_of_date
sessionInfo()
#> R Under development (unstable) (2020-04-27 r78310)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04 LTS
#> 
#> Matrix products: default
#> BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] grid      stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#> [1] ComplexHeatmap_2.3.5
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.4.6        knitr_1.28          cluster_2.1.0      
#>  [4] magrittr_1.5        colorspace_1.4-1    clue_0.3-57        
#>  [7] rjson_0.2.20        rlang_0.4.5         stringr_1.4.0      
#> [10] highr_0.8           tools_4.1.0         parallel_4.1.0     
#> [13] circlize_0.4.8      xfun_0.13           png_0.1-7          
#> [16] htmltools_0.4.0     yaml_2.2.1          digest_0.6.25      
#> [19] BiocManager_1.30.10 RColorBrewer_1.1-2  GlobalOptions_0.1.1
#> [22] shape_1.4.4         evaluate_0.14       rmarkdown_2.1      
#> [25] stringi_1.4.6       compiler_4.1.0      GetoptLong_0.1.8

Created on 2020-04-27 by the reprex package (v0.3.0)

jokergoo commented 4 years ago

Hi, please use version 2.3.5. The version 2.3.4 is not stable.

crazyhottommy commented 4 years ago

FYI, there is some weirdness for Complexheatmap using R4.0 https://twitter.com/markrobinsonca/status/1254167035417964547

jokergoo commented 4 years ago

No that one has nothing to do with R 4.0. See my reply:

https://github.com/jokergoo/ComplexHeatmap/issues/464#issuecomment-619550877

I updated 2.3.5 to bioc someday last week. Maybe you can try this new version.

Baurice commented 4 years ago

I have no problem with #464, and upgraded today to 2.3.5, based on your suggestion (via devtools::install_github). This seems to be an unrelated issue.

jokergoo commented 4 years ago

Now I also saw this problem on my side. The plot looks fine with R-3.* but similar as yours with R-4.0.0.

And it always happens from the third slice, on rows or columns......

jokergoo commented 4 years ago

I have fixed this bug. It is a problem from the new grid package.

Please update to version 2.5.1 from Github.

Baurice commented 4 years ago

Awesome job! It fixes my problem. Thanks a lot.