ComplexHeatmap icon indicating copy to clipboard operation
ComplexHeatmap copied to clipboard

imagemagick error with large matrix

Open ppaxisa opened this issue 2 years ago • 7 comments

I get this the error when trying to plot a matrix > 100,000 rows: Error in magick_image_write_frame(image, format = format, i = i) : Image must have at least 1 frame to write a bitmap

I believe this is the sample issue that was posted on the EnrichedHeatmap repo: https://github.com/jokergoo/EnrichedHeatmap/issues/58

I did follow the recommendations to make changes to the /etc/ImageMagick-6/policy.xml file and that solved the issue, but I am wondering if there's a more stable way to fix that within R. It was also pointed out that the issue might come from having cairo enabled/disabled. It's disabled on my machine but not sure how to change that. I have Cairo, imagemagick and R running on Ubuntu:

> library(magick) Linking to ImageMagick 6.9.10.23 Enabled features: fontconfig, freetype, fftw, lcms, pango, webp, x11 Disabled features: cairo, ghostscript, heic, raw, rsvg Using 4 threads

> sessionInfo() R version 4.2.0 (2022-04-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.4 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3 LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8
[4] LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] Cairo_1.6-0 magick_2.7.3 qs_0.25.3
[4] vsn_3.64.0 ashr_2.2-54 edgeR_3.38.1
[7] limma_3.52.1 DESeq2_1.36.0 SummarizedExperiment_1.26.1 [10] Biobase_2.56.0 MatrixGenerics_1.8.1 matrixStats_0.62.0
[13] GenomicRanges_1.48.0 GenomeInfoDb_1.32.2 IRanges_2.30.0
[16] S4Vectors_0.34.0 BiocGenerics_0.42.0 Matrix_1.4-1
[19] wesanderson_0.3.6 kableExtra_1.3.4 ggridges_0.5.3
[22] ggsci_2.9 hdf5r_1.3.5 sp_1.5-0
[25] SeuratObject_4.1.0 Seurat_4.1.1 data.table_1.14.2
[28] gtable_0.3.0 cowplot_1.1.1 gplots_3.1.3
[31] RColorBrewer_1.1-3 circlize_0.4.15 ggrepel_0.9.1
[34] scales_1.2.0 viridis_0.6.2 viridisLite_0.4.0
[37] ggExtra_0.10.0 knitr_1.39 gridExtra_2.3
[40] rlang_1.0.3 forcats_0.5.1 stringr_1.4.0
[43] dplyr_1.0.9 purrr_0.3.4 readr_2.1.2
[46] tidyr_1.2.0 tibble_3.1.7 ggplot2_3.3.6
[49] tidyverse_1.3.1

loaded via a namespace (and not attached): [1] utf8_1.2.2 reticulate_1.25 tidyselect_1.1.2
[4] RSQLite_2.2.14 AnnotationDbi_1.58.0 htmlwidgets_1.5.4
[7] BiocParallel_1.30.3 grid_4.2.0 Rtsne_0.16
[10] munsell_0.5.0 preprocessCore_1.58.0 codetools_0.2-18
[13] ica_1.0-2 future_1.26.1 miniUI_0.1.1.1
[16] withr_2.5.0 audio_0.1-10 spatstat.random_2.2-0 [19] colorspace_2.0-3 progressr_0.10.1 rstudioapi_0.13
[22] ROCR_1.0-11 tensor_1.5 listenv_0.8.0
[25] GenomeInfoDbData_1.2.8 mixsqp_0.3-43 polyclip_1.10-0
[28] bit64_4.0.5 parallelly_1.32.0 vctrs_0.4.1
[31] generics_0.1.3 xfun_0.31 R6_2.5.1
[34] doParallel_1.0.17 clue_0.3-61 invgamma_1.1
[37] locfit_1.5-9.5 cachem_1.0.6 DelayedArray_0.22.0
[40] bitops_1.0-7 spatstat.utils_2.3-1 assertthat_0.2.1
[43] promises_1.2.0.1 rgeos_0.5-9 affy_1.74.0
[46] globals_0.15.0 goftest_1.2-3 beepr_1.3
[49] genefilter_1.78.0 systemfonts_1.0.4 GlobalOptions_0.1.2
[52] splines_4.2.0 lazyeval_0.2.2 spatstat.geom_2.4-0
[55] broom_0.8.0 BiocManager_1.30.18 yaml_2.3.5
[58] reshape2_1.4.4 abind_1.4-5 modelr_0.1.8
[61] backports_1.4.1 httpuv_1.6.5 tools_4.2.0
[64] affyio_1.66.0 ellipsis_0.3.2 spatstat.core_2.4-4
[67] Rcpp_1.0.8.3 plyr_1.8.7 zlibbioc_1.42.0
[70] RCurl_1.98-1.7 rpart_4.1.16 deldir_1.0-6
[73] pbapply_1.5-0 GetoptLong_1.0.5 zoo_1.8-10
[76] haven_2.5.0 cluster_2.1.3 fs_1.5.2
[79] magrittr_2.0.3 scattermore_0.8 lmtest_0.9-40
[82] reprex_2.0.1 RANN_2.6.1 truncnorm_1.0-8
[85] SQUAREM_2021.1 fitdistrplus_1.1-8 stringfish_0.15.7
[88] hms_1.1.1 patchwork_1.1.1 mime_0.12
[91] evaluate_0.15 xtable_1.8-4 XML_3.99-0.10
[94] readxl_1.4.0 shape_1.4.6 compiler_4.2.0
[97] KernSmooth_2.23-20 crayon_1.5.1 htmltools_0.5.2
[100] mgcv_1.8-40 later_1.3.0 tzdb_0.3.0
[103] geneplotter_1.74.0 RcppParallel_5.1.5 RApiSerialize_0.1.0
[106] lubridate_1.8.0 DBI_1.1.3 dbplyr_2.2.0
[109] ComplexHeatmap_2.12.0 MASS_7.3-57 cli_3.3.0
[112] parallel_4.2.0 igraph_1.3.2 pkgconfig_2.0.3
[115] plotly_4.10.0 spatstat.sparse_2.1-1 xml2_1.3.3
[118] foreach_1.5.2 annotate_1.74.0 svglite_2.1.0
[121] XVector_0.36.0 webshot_0.5.3 rvest_1.0.2
[124] digest_0.6.29 sctransform_0.3.3 RcppAnnoy_0.0.19
[127] Biostrings_2.64.0 spatstat.data_2.2-0 rmarkdown_2.14
[130] cellranger_1.1.0 leiden_0.4.2 uwot_0.1.11
[133] shiny_1.7.1 gtools_3.9.2.2 rjson_0.2.21
[136] lifecycle_1.0.1 nlme_3.1-157 jsonlite_1.8.0
[139] fansi_1.0.3 pillar_1.7.0 lattice_0.20-45
[142] KEGGREST_1.36.2 fastmap_1.1.0 httr_1.4.3
[145] survival_3.3-1 glue_1.6.2 png_0.1-7
[148] iterators_1.0.14 bit_4.0.4 stringi_1.7.6
[151] blob_1.2.3 memoise_2.0.1 caTools_1.18.2
[154] irlba_2.3.5 future.apply_1.9.0

ppaxisa avatar Jul 15 '22 10:07 ppaxisa

Em, I think I need to have a machine with Ubuntu installed.

jokergoo avatar Jul 26 '22 20:07 jokergoo

Also ran into this issue on ubuntu 22.04.2

jamesdalg avatar Aug 25 '23 17:08 jamesdalg

Hi, similar issue found when plotting a large matix (8873 x 45044)

> dim(mat)
[1] 45044  8873

> sessionInfo()          
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=C.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       

time zone: Europe/Berlin
tzcode source: system (glibc)

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

other attached packages:
[1] ComplexHeatmap_2.16.0 infercnv_1.16.0       workflowr_1.7.0      

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.21            splines_4.3.1              
  [3] later_1.3.1                 bitops_1.0-7               
  [5] tibble_3.2.1                polyclip_1.10-4            
  [7] lifecycle_1.0.3             fastcluster_1.2.3          
  [9] edgeR_3.42.4                doParallel_1.0.17          
 [11] rprojroot_2.0.3             globals_0.16.2             
 [13] processx_3.8.1              lattice_0.21-8             
 [15] MASS_7.3-60                 magrittr_2.0.3             
 [17] limma_3.56.2                plotly_4.10.2              
 [19] rmarkdown_2.22              yaml_2.3.7                 
 [21] httpuv_1.6.11               Seurat_4.3.0.1             
 [23] sctransform_0.3.5           sp_1.6-1                   
 [25] spatstat.sparse_3.0-1       reticulate_1.30            
 [27] cowplot_1.1.1               pbapply_1.7-2              
 [29] RColorBrewer_1.1-3          multcomp_1.4-23            
 [31] abind_1.4-5                 zlibbioc_1.46.0            
 [33] Rtsne_0.16                  GenomicRanges_1.52.0       
 [35] purrr_1.0.1                 BiocGenerics_0.46.0        
 [37] RCurl_1.98-1.12             TH.data_1.1-2              
 [39] sandwich_3.0-2              git2r_0.32.0               
 [41] circlize_0.4.15             GenomeInfoDbData_1.2.10    
 [43] IRanges_2.34.1              S4Vectors_0.38.1           
 [45] ggrepel_0.9.3               irlba_2.3.5.1              
 [47] listenv_0.9.0               spatstat.utils_3.0-3       
 [49] goftest_1.2-3               spatstat.random_3.1-5      
 [51] fitdistrplus_1.1-11         parallelly_1.36.0          
 [53] leiden_0.4.3                codetools_0.2-19           
 [55] coin_1.4-2                  DelayedArray_0.26.7        
 [57] shape_1.4.6                 tidyselect_1.2.0           
 [59] futile.logger_1.4.3         rjags_4-14                 
 [61] matrixStats_1.0.0           stats4_4.3.1               
 [63] spatstat.explore_3.2-1      jsonlite_1.8.5             
 [65] GetoptLong_1.0.5            ellipsis_0.3.2             
 [67] progressr_0.14.0            ggridges_0.5.4             
 [69] survival_3.5-5              iterators_1.0.14           
 [71] foreach_1.5.2               tools_4.3.1                
 [73] ica_1.0-3                   Rcpp_1.0.10                
 [75] glue_1.6.2                  gridExtra_2.3              
 [77] xfun_0.39                   MatrixGenerics_1.12.3      
 [79] GenomeInfoDb_1.36.1         dplyr_1.1.2                
 [81] formatR_1.14                fastmap_1.1.1              
 [83] fansi_1.0.4                 callr_3.7.3                
 [85] caTools_1.18.2              digest_0.6.31              
 [87] parallelDist_0.2.6          R6_2.5.1                   
 [89] mime_0.12                   colorspace_2.1-0           
 [91] scattermore_1.2             gtools_3.9.4               
 [93] tensor_1.5                  spatstat.data_3.0-1        
 [95] utf8_1.2.3                  tidyr_1.3.0                
 [97] generics_0.1.3              data.table_1.14.8          
 [99] httr_1.4.6                  htmlwidgets_1.6.2          
[101] S4Arrays_1.0.5              whisker_0.4.1              
[103] uwot_0.1.16                 pkgconfig_2.0.3            
[105] gtable_0.3.3                modeltools_0.2-23          
[107] lmtest_0.9-40               SingleCellExperiment_1.22.0
[109] XVector_0.40.0              htmltools_0.5.5            
[111] clue_0.3-64                 SeuratObject_4.1.3         
[113] scales_1.2.1                Biobase_2.60.0             
[115] png_0.1-8                   phyclust_0.1-33            
[117] knitr_1.43                  lambda.r_1.2.4             
[119] rstudioapi_0.14             rjson_0.2.21               
[121] reshape2_1.4.4              coda_0.19-4                
[123] nlme_3.1-162                GlobalOptions_0.1.2        
[125] zoo_1.8-12                  stringr_1.5.0              
[127] KernSmooth_2.23-21          parallel_4.3.1             
[129] miniUI_0.1.1.1              libcoin_1.0-9              
[131] pillar_1.9.0                vctrs_0.6.2                
[133] gplots_3.1.3                RANN_2.6.1                 
[135] promises_1.2.0.1            xtable_1.8-4               
[137] cluster_2.1.4               evaluate_0.21              
[139] locfit_1.5-9.8              mvtnorm_1.2-2              
[141] cli_3.6.1                   compiler_4.3.1             
[143] futile.options_1.0.1        rlang_1.1.1                
[145] crayon_1.5.2                future.apply_1.11.0        
[147] ps_1.7.5                    getPass_0.2-2              
[149] argparse_2.2.2              plyr_1.8.8                 
[151] fs_1.6.2                    stringi_1.7.12             
[153] viridisLite_0.4.2           deldir_1.0-9               
[155] munsell_0.5.0               lazyeval_0.2.2             
[157] spatstat.geom_3.2-1         Matrix_1.6-1               
[159] patchwork_1.1.3             future_1.32.0              
[161] ggplot2_3.4.2               shiny_1.7.4                
[163] SummarizedExperiment_1.30.2 ROCR_1.0-11                
[165] igraph_1.4.3                RcppParallel_5.1.7         
[167] ape_5.7-1

The error is Error: Image must have at least 1 frame to write a bitmap.

YiweiNiu avatar Aug 31 '23 08:08 YiweiNiu

Hello, I am having the same error message, has anyone been able to solve this?

acv21 avatar Nov 17 '23 12:11 acv21

I'm getting the same error too. Any help on this would be greatly appreciated.

kithpradhan avatar Mar 15 '24 14:03 kithpradhan

Emm.. Currently, I don't have a machine where I can install Ubuntu.

Or you can suppress using imagemagick?

Heatmap(..., raster_by_magick = FALSE)

jokergoo avatar Mar 15 '24 21:03 jokergoo

Hello, I am having the same error message, has anyone been able to solve this?

Maybe you need to set the raster related options to Flase, like jokergoo commented^_^

249125914 avatar Apr 29 '24 12:04 249125914