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

Could not find function "gseaPermutation" #55

Open
ecirri opened this issue Aug 9, 2024 · 1 comment
Open

Could not find function "gseaPermutation" #55

ecirri opened this issue Aug 9, 2024 · 1 comment
Assignees
Labels

Comments

@ecirri
Copy link

ecirri commented Aug 9, 2024

Dear WebGestaltR team,

I am running your package and have been since quite some years with no issues. The package is used to enrich differentially regulated proteins coming from the candidates table output of Spectronaut.
Since a couple of weeks, when running the WebGestaltR function with GSEA method I get this message:

Error in { : task 1 failed - "could not find function "gseaPermutation""                                                                                                                                    
Called from: e$fun(obj, substitute(ex), parent.frame(), e$data)

With following debug:

function (obj, expr, envir, data) 
{
  cl <- data
  preschedule <- FALSE
  attachExportEnv <- FALSE
  if (!inherits(obj, "foreach")) 
    stop("obj must be a foreach object")
  it <- iter(obj)
  accumulator <- makeAccum(it)
  options <- obj$options$snow
  if (!is.null(options)) {
    nms <- names(options)
    recog <- nms %in% c("preschedule", "attachExportEnv")
    if (any(!recog)) 
      warning(sprintf("ignoring unrecognized snow option(s): %s", 
        paste(nms[!recog], collapse = ", ")), call. = FALSE)
    if (!is.null(options$preschedule)) {
      if (!is.logical(options$preschedule) || length(options$preschedule) != 
        1) {
        warning("preschedule must be logical value", 
          call. = FALSE)
      }
      else {
        if (obj$verbose) 
          cat(sprintf("bundling all tasks into %d chunks\n", 
            length(cl)))
        preschedule <- options$preschedule
      }
    }
    if (!is.null(options$attachExportEnv)) {
      if (!is.logical(options$attachExportEnv) || length(options$attachExportEnv) != 
        1) {
        warning("attachExportEnv must be logical value", 
          call. = FALSE)
      }
      else {
        if (obj$verbose) 
          cat("attaching export environment\n")
        attachExportEnv <- options$attachExportEnv
      }
    }
  }
  exportenv <- tryCatch({
    qargs <- quote(list(...))
    args <- eval(qargs, envir)
    environment(do.call(makeDotsEnv, args))
  }, error = function(e) {
    new.env(parent = emptyenv())
  })
  noexport <- union(obj$noexport, obj$argnames)
  packages <- getexports(expr, exportenv, envir, bad = noexport)
  if (obj$verbose) 
    cat(sprintf("discovered package(s): %s\n", paste(packages, 
      collapse = ", ")))
  vars <- ls(exportenv)
  if (obj$verbose) {
    if (length(vars) > 0) {
      cat("automatically exporting the following variables", 
        "from the local environment:\n")
      cat(" ", paste(vars, collapse = ", "), "\n")
    }
    else {
      cat("no variables are automatically exported\n")
    }
  }
  export <- unique(obj$export)
  ignore <- intersect(export, vars)
  if (length(ignore) > 0) {
    warning(sprintf("already exporting variable(s): %s", 
      paste(ignore, collapse = ", ")))
    export <- setdiff(export, ignore)
  }
  if (length(export) > 0) {
    if (obj$verbose) 
      cat(sprintf("explicitly exporting variables(s): %s\n", 
        paste(export, collapse = ", ")))
    for (sym in export) {
      if (!exists(sym, envir, inherits = TRUE)) 
        stop(sprintf("unable to find variable \"%s\"", 
          sym))
      val <- get(sym, envir, inherits = TRUE)
      if (is.function(val) && (identical(environment(val), 
        .GlobalEnv) || identical(environment(val), envir))) {
        environment(val) <- exportenv
      }
      assign(sym, val, pos = exportenv, inherits = FALSE)
    }
  }
  c.expr <- comp(expr, env = envir, options = list(suppressUndefined = TRUE))
  pkgname <- if (exists("packageName", mode = "function")) 
    packageName(envir)
  else NULL
  packages = c(packages, obj$packages)
  if (obj$verbose) {
    cat(sprintf("explicitly exporting package(s): %s\n", 
      paste(packages, collapse = ", ")))
  }
  if (!preschedule) {
    r <- clusterCall(cl, workerInit, c.expr, exportenv, 
      pkgname, packages, attachExportEnv)
    for (emsg in r) {
      if (!is.null(emsg)) 
        stop("worker initialization failed: ", emsg)
    }
    argsList <- as.list(it)
    results <- clusterApplyLB(cl, argsList, evalWrapper)
    if (attachExportEnv) {
      clusterCall(cl, workerCleanup)
    }
  }
  else {
    argsList <- splitList(as.list(it), length(cl))
    results <- do.call(c, clusterApply(cl, argsList, workerPreschedule, 
      c.expr, exportenv, pkgname, packages))
  }
  tryCatch(accumulator(results, seq_along(results)), error = function(e) {
    cat("error calling combine function:\n")
    print(e)
  })
  errorValue <- getErrorValue(it)
  errorIndex <- getErrorIndex(it)
  if (identical(obj$errorHandling, "stop") && !is.null(errorValue)) {
    msg <- sprintf("task %d failed - \"%s\"", errorIndex, 
      conditionMessage(errorValue))
    stop(simpleError(msg, call = expr))
  }
  else {
    getResult(it)
  }
}

I see no issues in installation or in library call, so I don't know why this function is missing. Is there any new, very recent updates that maybe I did not correctly installed?

Many thanks for your help.

Best regards,

Emilio

@iblacksand
Copy link
Collaborator

iblacksand commented Aug 9, 2024

Hello,

WebGestaltR did have an update, however it was not published on CRAN yet, and gseaPermutation is no longer referenced in the code, so you must be running an older version. The new R package uses Rust, instead of C++. It takes 10% of the computation compared to previous versions. You can install the new R Package according the installation instructions here: https://bzhanglab.github.io/WebGestaltR/.

If you would rather keep your version for consistency with previous results, I would try re-installing the R package to see if that will bring back this function or reveal a compilation issue.

remove.packages("WebGestaltR")
install.packages("WebGestaltR")

This might be related to a different user's problem where they couldn't find gseaPermutation. For them, it was because Rcpp needed a writable library path. You can find the full details at issue #32.

If you want to do a quick test for GSEA you can run the following code in an R session:

library("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)

Let me know if this solved your issue, or if you have any questions.

Best,
John

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

No branches or pull requests

2 participants