ctlab / fgsea

Fast Gene Set Enrichment Analysis
Other
379 stars 67 forks source link

GESECA: Error following tutorial: 2 arguments passed to 'cumsum' which requires 1 #136

Closed grapefruitshark closed 1 year ago

grapefruitshark commented 1 year ago

Hi,

Thank you so much for developing this great tool!! I am trying to use geseca on my scRNA-seq data in Seurat. I am following the tutorial here , however, when I get to the geseca() function, I am getting the following error:

Error in FUN(newX[, i], ...): 2 arguments passed to 'cumsum' which requires 1
Traceback:
1. geseca(pathways.hallmark, E, minSize = 15, maxSize = 500)
2. gesecaSimpleImpl(pathwayScores, pathwaySizes, pathwayNames, permPerProc, 
 .     seeds, m, E, BPPARAM)
3. bplapply(seq_along(permPerProc), function(i) {
 .     set.seed(seeds[i])
 .     nperm1 <- permPerProc[i]
 .     scores <- gesecaCumScores(nperm1, pathwaySizes, E)
 .     geScore <- t(apply(scores, 1, function(x) {
 .         return(x >= pathwayScores)
 .     }))
 .     geScore <- colSums(geScore)
 .     data.table(pathway = seq_len(toKeepLength), geScore = geScore)
 . }, BPPARAM = BPPARAM)
4. bplapply(seq_along(permPerProc), function(i) {
 .     set.seed(seeds[i])
 .     nperm1 <- permPerProc[i]
 .     scores <- gesecaCumScores(nperm1, pathwaySizes, E)
 .     geScore <- t(apply(scores, 1, function(x) {
 .         return(x >= pathwayScores)
 .     }))
 .     geScore <- colSums(geScore)
 .     data.table(pathway = seq_len(toKeepLength), geScore = geScore)
 . }, BPPARAM = BPPARAM)
5. bplapply(X, FUN, ..., BPREDO = BPREDO, BPPARAM = param)
6. bplapply(X, FUN, ..., BPREDO = BPREDO, BPPARAM = param)
7. lapply(X, FUN_, ...)
8. FUN(X[[i]], ...)
9. FUN(...)
10. withCallingHandlers({
  .     tryCatch({
  .         FUN(...)
  .     }, error = handle_error)
  . }, warning = handle_warning)
11. tryCatch({
  .     FUN(...)
  . }, error = handle_error)
12. tryCatchList(expr, classes, parentenv, handlers)
13. tryCatchOne(expr, names, parentenv, handlers[[1L]])
14. value[[3L]](cond)

I also tried using another matrix of gene TPMs X samples, but ran into the same error. I am following the tutorial exactly. I would appreciate help figuring out what is going on!

vdsukhov commented 1 year ago

@grapefruitshark

Hi, thanks for your interest in the package. Could you provide your output of sessionInfo() function?

grapefruitshark commented 1 year ago

@vdsukhov , thank you so much for your help troubleshooting this issue!

I have attached the sessionInfo() output, please let me know if there is anything else I can provide that will help with troubleshooting:

R version 4.0.2 (2020-06-22)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /home/myname/miniconda3/envs/r_env/lib/libopenblasp-r0.3.12.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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] BiocParallel_1.24.1 Signac_1.4.0        dplyr_1.1.2        
 [4] readr_1.4.0         ggpubr_0.4.0        ggplot2_3.4.2      
 [7] SeuratObject_4.0.3  Seurat_4.0.5        fgsea_1.27.0       
[10] devtools_2.4.2      usethis_2.1.3      

loaded via a namespace (and not attached):
  [1] utf8_1.2.3             reticulate_1.22        tidyselect_1.2.0      
  [4] htmlwidgets_1.5.4      grid_4.0.2             docopt_0.7.1          
  [7] Rtsne_0.15             munsell_0.5.0          codetools_0.2-18      
 [10] ica_1.0-2              pbdZMQ_0.3-5           future_1.23.0         
 [13] miniUI_0.1.1.1         withr_2.5.0            colorspace_2.1-0      
 [16] uuid_0.1-4             stats4_4.0.2           ROCR_1.0-11           
 [19] ggsignif_0.6.3         tensor_1.5             listenv_0.8.0         
 [22] slam_0.1-48            repr_1.1.3             GenomeInfoDbData_1.2.4
 [25] polyclip_1.10-0        farver_2.1.1           rprojroot_2.0.2       
 [28] parallelly_1.28.1      vctrs_0.6.3            generics_0.1.3        
 [31] lsa_0.73.2             ggseqlogo_0.1          R6_2.5.1              
 [34] GenomeInfoDb_1.26.7    msigdbr_7.5.1          bitops_1.0-7          
 [37] spatstat.utils_2.2-0   cachem_1.0.6           promises_1.2.0.1      
 [40] scales_1.2.1           gtable_0.3.3           globals_0.14.0        
 [43] processx_3.5.1         goftest_1.2-3          rlang_1.1.1           
 [46] RcppRoll_0.3.0         splines_4.0.2          rstatix_0.7.0         
 [49] lazyeval_0.2.2         spatstat.geom_2.3-0    broom_0.7.6           
 [52] reshape2_1.4.4         abind_1.4-5            backports_1.2.1       
 [55] httpuv_1.6.3           tools_4.0.2            ellipsis_0.3.2        
 [58] spatstat.core_2.3-1    RColorBrewer_1.1-3     BiocGenerics_0.36.0   
 [61] sessioninfo_1.2.1      ggridges_0.5.3         Rcpp_1.0.10           
 [64] plyr_1.8.8             base64enc_0.1-3        zlibbioc_1.36.0       
 [67] purrr_1.0.1            RCurl_1.98-1.3         ps_1.6.0              
 [70] prettyunits_1.1.1      rpart_4.1-15           deldir_1.0-6          
 [73] pbapply_1.5-0          cowplot_1.1.1          S4Vectors_0.28.1      
 [76] zoo_1.8-9              ggrepel_0.9.1          cluster_2.1.1         
 [79] fs_1.5.0               magrittr_2.0.3         data.table_1.14.8     
 [82] scattermore_0.7        lmtest_0.9-39          RANN_2.6.1            
 [85] SnowballC_0.7.0        fitdistrplus_1.1-6     matrixStats_0.61.0    
 [88] pkgload_1.2.1          hms_1.0.0              patchwork_1.1.1       
 [91] mime_0.12              evaluate_0.14          xtable_1.8-4          
 [94] sparsesvd_0.2          IRanges_2.24.1         gridExtra_2.3         
 [97] testthat_3.0.2         compiler_4.0.2         tibble_3.2.1          
[100] KernSmooth_2.23-18     crayon_1.4.2           htmltools_0.5.2       
[103] mgcv_1.8-34            later_1.3.0            tidyr_1.3.0           
[106] DBI_1.1.1              tweenr_1.0.2           MASS_7.3-53.1         
[109] babelgene_22.9         Matrix_1.3-4           car_3.1-0             
[112] cli_3.6.1              parallel_4.0.2         igraph_1.2.8          
[115] GenomicRanges_1.42.0   pkgconfig_2.0.3        IRdisplay_1.0         
[118] plotly_4.10.0          spatstat.sparse_2.0-0  XVector_0.30.0        
[121] stringr_1.5.0          callr_3.6.0            digest_0.6.28         
[124] sctransform_0.3.2      RcppAnnoy_0.0.19       spatstat.data_2.1-0   
[127] Biostrings_2.58.0      leiden_0.3.9           fastmatch_1.1-3       
[130] uwot_0.1.10            curl_4.3.2             shiny_1.7.1           
[133] Rsamtools_2.6.0        lifecycle_1.0.3        nlme_3.1-152          
[136] jsonlite_1.7.2         carData_3.0-5          desc_1.4.0            
[139] viridisLite_0.4.2      fansi_1.0.4            pillar_1.9.0          
[142] lattice_0.20-41        fastmap_1.1.0          httr_1.4.2            
[145] pkgbuild_1.2.0         survival_3.2-10        glue_1.6.2            
[148] remotes_2.3.0          qlcMatrix_0.9.7        png_0.1-7             
[151] ggforce_0.3.3          stringi_1.7.12         memoise_2.0.0         
[154] IRkernel_1.1.1         irlba_2.3.5.1          future.apply_1.8.1
vdsukhov commented 1 year ago

@grapefruitshark

I believe that updating to a newer version of R should resolve the issue you're facing. Starting from R 4.1.0, they have introduced the simplify argument to the apply function (info). Thank you for bringing this to my attention. In the future, I should consider rewriting this specific part, which you can find at the following link: https://github.com/ctlab/fgsea/blob/c9d9b4a09dcb3cf9457a36202602f9aab0ca9267/R/geseca-simple.R#L141C9-L141C76

However, for now, the quickest solution would be to try updating your R version to at least 4.1.0.

vdsukhov commented 1 year ago

@grapefruitshark Hello again! Did it help? Just want to make sure that this is really because of the new behavior of the apply function?

grapefruitshark commented 1 year ago

@vdsukhov -- thank you so much for your response, and I am so sorry for the late response.

Updating to a newer version of R indeed solved my problems.

Thank you so much!