bzhanglab / WebGestaltR

R package for WebGestalt
https://bzhanglab.github.io/WebGestaltR/
34 stars 14 forks source link

Error "could not find function "gseaPermutation"" #32

Closed helaersr closed 8 months ago

helaersr commented 8 months ago

When using WebGestaltR with KEGG pathway database, I generally have this error 👍🏻

> library("WebGestaltR")
******************************************

*                                        *

*          Welcome to WebGestaltR !      *

*                                        *

******************************************
> rankFile = paste(output_path,"/efit_ensembl_vs_metric.rnk", sep='')
> dir_pathway_KEGG = "enrich_efit_pathway_KEGG"
> enrichResult <- WebGestaltR(enrichMethod="GSEA", organism="hsapiens", enrichDatabase="pathway_KEGG",interestGeneFile=rankFile, interestGeneType="ensembl_gene_id", sigMethod="top", topThr=10, minNum=5, outputDirectory=output_path, projectName=dir_pathway_KEGG)
Loading the functional categories...
Loading the ID list...
Summarizing the uploaded ID list by GO Slim data...
Performing the enrichment analysis...
Error in { : task 1 failed - "could not find function "gseaPermutation""
In addition: There were 50 or more warnings (use warnings() to see the first 50)

The traceback

> traceback()
9: stop(simpleError(msg, call = expr))
8: e$fun(obj, substitute(ex), parent.frame(), e$data)
7: (function (obj, ex)
   {
       e <- getDoPar()
       e$fun(obj, substitute(ex), parent.frame(), e$data)
   })(structure(list(args = (1:perms)(.doRNG.stream = list(c(10407L,
   -300577125L, 1310462240L, 175658657L, -714830866L, -2004016233L,
   -1486148884L),  ........ , c(10407L, 1743938459L,
       -1249704994L, -1768809565L, -220262883L, 1690780601L, 976081818L
       ), c(10407L, -962489133L, 910798970L, -680752213L, 415124716L,
       -224061072L, 1865361953L))), argnames = c("i", ".doRNG.stream"
   ), evalenv = <environment>, specified = character(0), combineInfo = list(
       fun = function (..., deparse.level = 1)
       .Internal(rbind(deparse.level, ...)), in.order = TRUE, has.init = FALSE,
       init = NULL, final = NULL, multi.combine = TRUE, max.combine = 100),
       errorHandling = "stop", packages = "doRNG", export = NULL,
       noexport = NULL, options = list(), verbose = FALSE), class = "foreach"),
       {
           {
               rngtools::RNGseed(.doRNG.stream)
           }
           {
               gseaPermutation(scaled_scores, outset_scores, adj_expr_val)
           }
       })
6: do.call(`%dopar%`, list(obj, ex), envir = parent.frame())
5: foreach(i = 1:perms, .combine = "rbind") %dorng% {
       gseaPermutation(scaled_scores, outset_scores, adj_expr_val)
   }
4: swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,
       max_set_size = maxNum, p = p, nThreads = nThreads, rng_seed = as.integer(format(Sys.time(),
           "%H%M%S")))
3: gseaEnrichment(hostName, outputDirectory, projectName, interestGeneList,
       geneSet, geneSetDes = geneSetDes, minNum = minNum, maxNum = maxNum,
       sigMethod = sigMethod, fdrThr = fdrThr, topThr = topThr,
       perNum = perNum, p = p, nThreads = nThreads, saveRawGseaResult = saveRawGseaResult,
       plotFormat = plotFormat, isOutput = isOutput)
2: WebGestaltRGsea(organism = organism, enrichDatabase = enrichDatabase,
       enrichDatabaseFile = enrichDatabaseFile, enrichDatabaseType = enrichDatabaseType,
       enrichDatabaseDescriptionFile = enrichDatabaseDescriptionFile,
       interestGeneFile = interestGeneFile, interestGene = interestGene,
       interestGeneType = interestGeneType, collapseMethod = collapseMethod,
       minNum = minNum, maxNum = maxNum, fdrMethod = fdrMethod,
       sigMethod = sigMethod, fdrThr = fdrThr, topThr = topThr,
       reportNum = reportNum, setCoverNum = setCoverNum, perNum = perNum,
       p = gseaP, isOutput = isOutput, outputDirectory = outputDirectory,
       projectName = projectName, dagColor = dagColor, saveRawGseaResult = saveRawGseaResult,
       plotFormat = gseaPlotFormat, nThreads = nThreads, cache = cache,
       hostName = hostName)
1: WebGestaltR(enrichMethod = "GSEA", organism = "hsapiens", enrichDatabase = "pathway_KEGG",
       interestGeneFile = rankFile, interestGeneType = "ensembl_gene_id",
       sigMethod = "top", topThr = 10, minNum = 5, outputDirectory = output_path,
       projectName = dir_pathway_KEGG)

My rsession info

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS

Matrix products: default
BLAS/LAPACK: /apps/modulesfiles/software/FlexiBLAS/3.2.1-GCC-12.2.0/lib/libflexiblas.so.3.2

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

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

other attached packages:
[1] WebGestaltR_0.4.6

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10       pillar_1.8.1      compiler_4.2.2    tools_4.2.2
 [5] iterators_1.0.14  rngtools_1.5.2    bit_4.0.5         digest_0.6.31
 [9] jsonlite_1.8.4    lifecycle_1.0.3   tibble_3.2.0      lattice_0.20-45
[13] pkgconfig_2.0.3   rlang_1.1.0       doRNG_1.8.6       Matrix_1.5-3
[17] foreach_1.5.2     igraph_1.4.1      cli_3.6.0         curl_5.0.0
[21] parallel_4.2.2    withr_2.5.0       apcluster_1.4.10  dplyr_1.1.0
[25] httr_1.4.5        generics_0.1.3    vctrs_0.6.0       systemfonts_1.0.4
[29] hms_1.1.2         bit64_4.0.5       grid_4.2.2        tidyselect_1.2.0
[33] svglite_2.1.1     glue_1.6.2        R6_2.5.1          fansi_1.0.4
[37] vroom_1.6.1       whisker_0.4.1     readr_2.1.4       tzdb_0.3.0
[41] magrittr_2.0.3    codetools_0.2-19  ellipsis_0.3.2    utf8_1.2.3
[45] doParallel_1.0.17 crayon_1.5.2

Do you have any idea of what could cause this issue ?

iblacksand commented 8 months ago

gseaPermutation is a function written in C++ and used via Rpp. It may be possible that during installation there was some problem with compilation leading to this issue. However if this only happens with KEGG and not others, then this is unlikely to be the problem.

What happens if you run the KEGG GSEA example?

####### GSEA example #########
rankFile <- system.file("extdata", "GeneRankList.rnk", package="WebGestaltR")
outputDirectory <- getwd()
enrichResult <- WebGestaltR(enrichMethod="GSEA", organism="hsapiens",
  enrichDatabase="pathway_KEGG", interestGeneFile=rankFile,
  interestGeneType="genesymbol", sigMethod="top", topThr=10, minNum=5,
  outputDirectory=outputDirectory)

If you still have an issue you could try reinstalling WebGestaltR and see if that fixes it.

remove.packages("WebGestaltR")
install.packages("WebGestaltR")
helaersr commented 8 months ago

Same problem with the example

> library("WebGestaltR")
******************************************

*                                        *

*          Welcome to WebGestaltR !      *

*                                        *

******************************************

> rankFile <- system.file("extdata", "GeneRankList.rnk", package="WebGestaltR")
> outputDirectory <- getwd()
> enrichResult <- WebGestaltR(enrichMethod="GSEA", organism="hsapiens",
  enrichDatabase="pathway_KEGG", interestGeneFile=rankFile,
  interestGeneType="genesymbol", sigMethod="top", topThr=10, minNum=5,
  outputDirectory=outputDirectory)
Loading the functional categories...
Loading the ID list...
Summarizing the uploaded ID list by GO Slim data...
Performing the enrichment analysis...
Error in { : task 1 failed - "could not find function "gseaPermutation""
In addition: Warning messages:
1: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa00232

2: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa00290

3: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa00400

4: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa00440

5: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa00471

6: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa00524

7: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa00780

8: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa00785

9: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score does not contain minimum number of items in set for hsa05033

10: In swGsea(inputDf, thresh_type = "val", perms = perNum, min_set_size = minNum,  :
  score has more than 500 items in set hsa01100

I reinstall the package, there is no error during the installation process, and I still have the same problem. But now, I have the problem with any database (e.g. GO). As it worked before in the same environment, I'm a bit confused on what could be missing/inaccessible (at first KEGG was working too). Do you see any missing package in my sessioninfo ?

helaersr commented 8 months ago

OK I found the problem.

It seems that Rcpp(?) needs a writable library path. My libPaths were limited to read-only paths. After adding an (empty) writable path to my libPaths, everything worked again.

Thanks for help !