Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with svg device in ggplot2::ggsave #6275

Closed
amkilpatrick opened this issue Jan 8, 2025 · 4 comments
Closed

Issues with svg device in ggplot2::ggsave #6275

amkilpatrick opened this issue Jan 8, 2025 · 4 comments

Comments

@amkilpatrick
Copy link

I've recently updated my R/Bioconductor installation and am now getting issues with saving svg images via ggsave(). When I try this, I get an error message about vector memory, even for the smallest test cases, eg

> (ggplot(mtcars, aes(x=hp, y=mpg, color=cyl)) + geom_point(size=3)) %>% ggplot2::ggsave(filename = "test.svg")
Saving 9.19 x 6.36 in image
Error: vector memory limit of 100.0 Gb reached, see mem.maxVSize()

I've got svglite installed as suggested elsewhere, and saving to svg via svg() ... dev.off() works fine. Saving to other file types (eg pdf, png etc) with ggsave() also seems to be ok.

I found this similar problem on SO, but I'm not using renv on this project, so that shouldn't be a factor - any advice appreciated, thanks!

Session info:

> sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: x86_64-apple-darwin20
Running under: macOS Big Sur 11.7.8

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

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

time zone: Europe/London
tzcode source: internal

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

other attached packages:
 [1] ggplotify_0.1.2        magrittr_2.0.3         svglite_2.1.3          GSVA_2.0.4            
 [5] e1071_1.7-16           preprocessCore_1.68.0  limSolve_1.5.7.1       limma_3.62.1          
 [9] patchwork_1.3.0        survminer_0.5.0        ggpubr_0.6.0           survival_3.8-3        
[13] lubridate_1.9.4        forcats_1.0.0          stringr_1.5.1          dplyr_1.1.4           
[17] purrr_1.0.2            readr_2.1.5            tidyr_1.3.1            ggplot2_3.5.1         
[21] tidyverse_2.0.0        tibble_3.2.1           clusterProfiler_4.14.4 tidyHeatmap_1.8.1     
[25] ComplexHeatmap_2.22.0 

loaded via a namespace (and not attached):
  [1] splines_4.4.2               R.oo_1.27.0                 graph_1.84.0               
  [4] XML_3.99-0.18               lifecycle_1.0.4             rstatix_0.7.2              
  [7] doParallel_1.0.17           lattice_0.22-6              MASS_7.3-64                
 [10] dendextend_1.19.0           backports_1.5.0             ggtangle_0.0.6             
 [13] cowplot_1.1.3               DBI_1.2.3                   RColorBrewer_1.1-3         
 [16] abind_1.4-8                 zlibbioc_1.52.0             GenomicRanges_1.58.0       
 [19] quadprog_1.5-8              R.utils_2.12.3              BiocGenerics_0.52.0        
 [22] yulab.utils_0.1.9           circlize_0.4.16             GenomeInfoDbData_1.2.13    
 [25] IRanges_2.40.1              KMsurv_0.1-5                S4Vectors_0.44.0           
 [28] enrichplot_1.26.5           ggrepel_0.9.6               irlba_2.3.5.1              
 [31] tidytree_0.4.6              annotate_1.84.0             codetools_0.2-20           
 [34] DelayedArray_0.32.0         DOSE_4.0.0                  tidyselect_1.2.1           
 [37] shape_1.4.6.1               aplot_0.2.4                 UCSC.utils_1.2.0           
 [40] farver_2.1.2                ScaledMatrix_1.14.0         viridis_0.6.5              
 [43] matrixStats_1.5.0           stats4_4.4.2                jsonlite_1.8.9             
 [46] GetoptLong_1.0.5            Formula_1.2-5               iterators_1.0.14           
 [49] systemfonts_1.1.0           foreach_1.5.2               tools_4.4.2                
 [52] ragg_1.3.3                  treeio_1.30.0               Rcpp_1.0.13-1              
 [55] glue_1.8.0                  gridExtra_2.3               SparseArray_1.6.0          
 [58] mgcv_1.9-1                  xfun_0.50                   qvalue_2.38.0              
 [61] MatrixGenerics_1.18.0       GenomeInfoDb_1.42.1         HDF5Array_1.34.0           
 [64] withr_3.0.2                 fastmap_1.2.0               rhdf5filters_1.18.0        
 [67] digest_0.6.37               rsvd_1.0.5                  timechange_0.3.0           
 [70] R6_2.5.1                    gridGraphics_0.5-1          textshaping_0.4.1          
 [73] colorspace_2.1-1            GO.db_3.20.0                lpSolve_5.6.23             
 [76] RSQLite_2.3.9               R.methodsS3_1.8.2           generics_0.1.3             
 [79] renv_1.0.11                 data.table_1.16.4           class_7.3-23               
 [82] httr_1.4.7                  S4Arrays_1.6.0              pkgconfig_2.0.3            
 [85] gtable_0.3.6                blob_1.2.4                  SingleCellExperiment_1.28.1
 [88] XVector_0.46.0              survMisc_0.5.6              carData_3.0-5              
 [91] fgsea_1.32.0                GSEABase_1.68.0             clue_0.3-66                
 [94] scales_1.3.0                Biobase_2.66.0              png_0.1-8                  
 [97] SpatialExperiment_1.16.0    ggfun_0.1.8                 knitr_1.49                 
[100] km.ci_0.5-6                 rstudioapi_0.17.1           tzdb_0.4.0                 
[103] reshape2_1.4.4              rjson_0.2.23                nlme_3.1-166               
[106] rhdf5_2.50.1                proxy_0.4-27                cachem_1.1.0               
[109] zoo_1.8-12                  GlobalOptions_0.1.2         parallel_4.4.2             
[112] AnnotationDbi_1.68.0        pillar_1.10.1               vctrs_0.6.5                
[115] car_3.1-3                   BiocSingular_1.22.0         beachmat_2.22.0            
[118] xtable_1.8-4                cluster_2.1.8               evaluate_1.0.1             
[121] magick_2.8.5                cli_3.6.3                   compiler_4.4.2             
[124] rlang_1.1.4                 crayon_1.5.3                ggsignif_0.6.4             
[127] labeling_0.4.3              plyr_1.8.9                  fs_1.6.5                   
[130] stringi_1.8.4               viridisLite_0.4.2           BiocParallel_1.40.0        
[133] munsell_0.5.1               Biostrings_2.74.1           lazyeval_0.2.2             
[136] GOSemSim_2.32.0             Matrix_1.7-1                hms_1.1.3                  
[139] sparseMatrixStats_1.18.0    bit64_4.5.2                 Rhdf5lib_1.28.0            
[142] KEGGREST_1.46.0             statmod_1.5.0               SummarizedExperiment_1.36.0
[145] igraph_2.1.2                broom_1.0.7                 memoise_2.0.1              
[148] ggtree_3.14.0               fastmatch_1.1-6             bit_4.5.0.1                
[151] ape_5.8-1                   gson_0.1.0   
@teunbrand
Copy link
Collaborator

I'm sorry I can't reproduce this issue. Does the problem occur when you use this in a fresh R session (based on some unexpected attached packages in the session info)?

@amkilpatrick
Copy link
Author

Hi Teun,
Thanks for the suggestion, just as you replied I'd thought to try via R at command line, and it worked! It seems there is(/was?) some kind of issue with Rstudio attaching packages at startup regardless of whether they were explicitly requested, which may or may not have been triggered by me updating R.
Anyway, forced deletion of ~/.RData and clearing Rstudio seems to have fixed this.

Now I have a different problem, but it's apparently with RStudio...... Thanks for your response!

@amkilpatrick
Copy link
Author

Just for completeness for anyone else who encounters the same problem, the RStudio fix appeared to be to turn off all R diagnostics, otherwise Rstudio will silently attach packages from scripts in all open tabs on startup, even if not requested.

NB I suspect this behaviour isn't a problem the majority of the time, but one (or more) of the packages in one of my analysis scripts seems to be causing the conflict - I'm guessing IOBR but not 100% sure.

@teunbrand
Copy link
Collaborator

Yeah I can understand this is frustrating. For these and other sorts of reasons, we recommend using the reprex package to produce self-contained examples. Anyway, as the problem appears to have originated elsewhere, I don't have the feeling ggplot2 needs to change somethings, so I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants