ArchR icon indicating copy to clipboard operation
ArchR copied to clipboard

Error in g$grobs[[legend]]: no such index at level 2

Open danli349 opened this issue 1 year ago • 3 comments
trafficstars

When run the tutorial "https://greenleaflab.github.io/ArchR_2020/Ex-Analyze-Multiome.html" The output figures are all correct but when I tried to save them:

#Save Plot
plotPDF(p1, p2, p3, name = "UMAP-scATAC-scRNA-Combined", addDOC = FALSE)
Plotting Ggplot!

Error in g$grobs[[legend]]: no such index at level 2

Traceback:

1. tryCatch({
 .     pdf(filename, width = width, height = height, useDingbats = useDingbats)
 .     for (i in seq_along(plotList)) {
 .         if (inherits(plotList[[i]], "gg")) {
 .             if (inherits(plotList[[i]], "patchwork")) {
 .                 if (getArchRVerbose()) 
 .                   message("Plotting Patchwork!")
 .                 print(plotList[[i]])
 .             }
 .             else {
 .                 if (getArchRVerbose()) 
 .                   message("Plotting Ggplot!")
 .                 if (!is.null(attr(plotList[[i]], "ratioYX"))) {
 .                   .fixPlotSize(plotList[[i]], plotWidth = width, 
 .                     plotHeight = height, height = attr(plotList[[i]], 
 .                       "ratioYX"), newPage = FALSE)
 .                 }
 .                 else {
 .                   .fixPlotSize(plotList[[i]], plotWidth = width, 
 .                     plotHeight = height, newPage = FALSE)
 .                 }
 .             }
 .             if (i != length(plotList)) {
 .                 grid::grid.newpage()
 .             }
 .         }
 .         else if (inherits(plotList[[i]], "gtable")) {
 .             if (getArchRVerbose()) 
 .                 message("Plotting Gtable!")
 .             print(grid::grid.draw(plotList[[i]]))
 .             if (i != length(plotList)) {
 .                 grid::grid.newpage()
 .             }
 .         }
 .         else if (inherits(plotList[[i]], "HeatmapList") | inherits(plotList[[i]], 
 .             "Heatmap")) {
 .             if (getArchRVerbose()) 
 .                 message("Plotting ComplexHeatmap!")
 .             padding <- 15
 .             draw(plotList[[i]], padding = unit(c(padding, padding, 
 .                 padding, padding), "mm"), heatmap_legend_side = "bot", 
 .                 annotation_legend_side = "bot")
 .         }
 .         else {
 .             if (getArchRVerbose()) 
 .                 message("Plotting Other")
 .             print(plotList[[i]])
 .         }
 .     }
 .     dev.off()
 . }, error = function(x) {
 .     if (getArchRVerbose()) 
 .         message(x)
 . })
2. tryCatchList(expr, classes, parentenv, handlers)
3. tryCatchOne(expr, names, parentenv, handlers[[1L]])
4. value[[3L]](cond)
5. message(x)
6. withRestarts({
 .     signalCondition(cond)
 .     defaultHandler(cond)
 . }, muffleMessage = function() NULL)
7. withOneRestart(expr, restarts[[1L]])
8. doWithOneRestart(return(expr), restart)
9. signalCondition(cond)

How to solve this problem? Thanks!

sessionInfo()

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 20.04.1 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/liblapack.so.3;  LAPACK version 3.9.0

Random number generation:
 RNG:     L'Ecuyer-CMRG 
 Normal:  Inversion 
 Sample:  Rejection 
 
locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

time zone: America/New_York
tzcode source: system (glibc)

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

other attached packages:
 [1] nabor_0.5.0                       Seurat_5.1.0                     
 [3] SeuratObject_5.0.2                sp_2.1-4                         
 [5] Rsamtools_2.20.0                  BSgenome.Hsapiens.UCSC.hg38_1.4.5
 [7] BSgenome_1.72.0                   rtracklayer_1.64.0               
 [9] BiocIO_1.14.0                     Biostrings_2.72.1                
[11] XVector_0.44.0                    rhdf5_2.48.0                     
[13] SummarizedExperiment_1.34.0       Biobase_2.64.0                   
[15] MatrixGenerics_1.16.0             Rcpp_1.0.13                      
[17] Matrix_1.7-0                      GenomicRanges_1.56.1             
[19] GenomeInfoDb_1.40.1               IRanges_2.38.1                   
[21] S4Vectors_0.42.1                  BiocGenerics_0.50.0              
[23] matrixStats_1.4.1                 data.table_1.16.0                
[25] stringr_1.5.1                     plyr_1.8.9                       
[27] magrittr_2.0.3                    ggplot2_3.5.1                    
[29] gtable_0.3.5                      gtools_3.9.5                     
[31] gridExtra_2.3                     ArchR_1.0.2                      

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22         splines_4.4.1            later_1.3.2             
  [4] pbdZMQ_0.3-11            bitops_1.0-8             tibble_3.2.1            
  [7] polyclip_1.10-7          XML_3.99-0.17            fastDummies_1.7.3       
 [10] lifecycle_1.0.4          globals_0.16.3           lattice_0.22-6          
 [13] MASS_7.3-61              plotly_4.10.4            yaml_2.3.10             
 [16] httpuv_1.6.15            sctransform_0.4.1        spam_2.10-0             
 [19] spatstat.sparse_3.1-0    reticulate_1.38.0        cowplot_1.1.3           
 [22] pbapply_1.7-2            RColorBrewer_1.1-3       abind_1.4-8             
 [25] zlibbioc_1.50.0          Rtsne_0.17               purrr_1.0.2             
 [28] RCurl_1.98-1.16          GenomeInfoDbData_1.2.12  ggrepel_0.9.6           
 [31] irlba_2.3.5.1            listenv_0.9.1            spatstat.utils_3.0-5    
 [34] goftest_1.2-3            RSpectra_0.16-2          spatstat.random_3.3-1   
 [37] fitdistrplus_1.2-1       parallelly_1.38.0        leiden_0.4.3.1          
 [40] codetools_0.2-20         DelayedArray_0.30.1      tidyselect_1.2.1        
 [43] UCSC.utils_1.0.0         farver_2.1.2             base64enc_0.1-3         
 [46] spatstat.explore_3.3-1   GenomicAlignments_1.40.0 jsonlite_1.8.9          
 [49] progressr_0.14.0         ggridges_0.5.6           survival_3.7-0          
 [52] tools_4.4.1              ica_1.0-3                glue_1.7.0              
 [55] SparseArray_1.4.8        IRdisplay_1.1            dplyr_1.1.4             
 [58] withr_3.0.1              fastmap_1.2.0            rhdf5filters_1.16.0     
 [61] fansi_1.0.6              digest_0.6.37            R6_2.5.1                
 [64] mime_0.12                colorspace_2.1-1         scattermore_1.2         
 [67] Cairo_1.6-2              tensor_1.5               spatstat.data_3.1-2     
 [70] utf8_1.2.4               tidyr_1.3.1              generics_0.1.3          
 [73] httr_1.4.7               htmlwidgets_1.6.4        S4Arrays_1.4.1          
 [76] uwot_0.2.2               pkgconfig_2.0.3          lmtest_0.9-40           
 [79] htmltools_0.5.8.1        dotCall64_1.1-1          scales_1.3.0            
 [82] png_0.1-8                spatstat.univar_3.0-0    reshape2_1.4.4          
 [85] rjson_0.2.23             uuid_1.2-1               nlme_3.1-166            
 [88] curl_5.2.3               repr_1.1.7               zoo_1.8-12              
 [91] KernSmooth_2.23-24       miniUI_0.1.1.1           restfulr_0.0.15         
 [94] pillar_1.9.0             vctrs_0.6.5              RANN_2.6.1              
 [97] promises_1.3.0           xtable_1.8-4             cluster_2.1.6           
[100] evaluate_1.0.0           cli_3.6.3                compiler_4.4.1          
[103] rlang_1.1.4              crayon_1.5.3             future.apply_1.11.2     
[106] labeling_0.4.3           stringi_1.8.4            deldir_2.0-4            
[109] viridisLite_0.4.2        BiocParallel_1.38.0      munsell_0.5.1           
[112] lazyeval_0.2.2           spatstat.geom_3.3-2      IRkernel_1.3.2          
[115] RcppHNSW_0.6.0           patchwork_1.2.0          future_1.34.0           
[118] Rhdf5lib_1.26.0          shiny_1.9.1              ROCR_1.0-11             
[121] igraph_2.0.3            


ggsave can save the plot, but I don't know why plotPDF doesn't work.

ggsave(
  "./UMAP-scATAC-scRNA-Combined_p2.pdf", p2,
  scale = 1,
  width = 8,
  height = 8,
  dpi = 600)

danli349 avatar Sep 28 '24 23:09 danli349

Hi @danli349! Thanks for using ArchR! Lately, it has been very challenging for me to keep up with maintenance of this package and all of my other responsibilities as a PI. I have not been responding to issue posts and I have not been pushing updates to the software. We are actively searching to hire a computational biologist to continue to develop and maintain ArchR and related tools. If you know someone who might be a good fit, please let us know! In the meantime, your issue will likely go without a reply. Most issues with ArchR right not relate to compatibility. Try reverting to R 4.1 and Bioconductor 3.15. Newer versions of Seurat and Matrix also are causing issues. Sorry for not being able to provide active support for this package at this time.

rcorces avatar Sep 28 '24 23:09 rcorces

It's an issue with newer versions of ggplot2 with archR. I had to downgrade to version 3.4.0. Other people say that 3.4.2 works as well.

slundh avatar Oct 08 '24 16:10 slundh

@slundh Thanks a lot for the information!

When I install ggplot2_3.4.2, there is an Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : invalid non-character version specification 'x' (type: double), how did you solve this problem?

packageurl <- "https://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_3.4.2.tar.gz"
install.packages(packageurl, repos=NULL, type="source")

Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) :
  invalid non-character version specification 'x' (type: double)
Error: unable to load R code in package ‘ggplot2’
Execution halted
ERROR: lazy loading failed for package ‘ggplot2’
* removing ‘/home/dan/R/x86_64-pc-linux-gnu-library/4.03/ggplot2’
Warning message:
In install.packages(packageurl, repos = NULL, type = "source") :
  installation of package ‘/tmp/Rtmpwk4sB5/downloaded_packages/ggplot2_3.4.2.tar.gz’ had non-zero exit status

danli349 avatar Oct 21 '24 21:10 danli349

Hey @danli349, sorry for the super late reply. I added in a fix for this, and this will be included in the 1.0.3 release

immanuelazn avatar Nov 26 '24 07:11 immanuelazn

Hey @danli349, sorry for the super late reply. I added in a fix for this, and this will be included in the 1.0.3 release

That's great! Thanks a lot

danli349 avatar Nov 26 '24 14:11 danli349