bzhanglab / WebGestaltR

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

Error in idMappingGene: Organism is missing. While specifying the organism #29

Closed SamDCalis closed 1 year ago

SamDCalis commented 1 year ago

Hi, I have recently been getting this error while performing GSEA eventhough I changed nothing about my code and it worked before. Any idea what could cause this? WebGestaltR 0.4.6 R version 4.2.2 (my collegue gets the same error in 4.3) Rstudio version 2023.6.0.421

Error in idMappingGene(organism = organism, dataType = dataType, inputGeneFile = inputGeneFile, :
Organism is missing.

My code below:

Perform_GSEA <-function(GSEA_input, subfolder){
  # Subfolder: Folder where you want the output of the analysis stored
  # GSEA_input is a matrix with columns: a list of identifiers e.g. swissprot protein IDs, second column is a ranking eg -log10(adjusted P values) * abs(logFC)
  library(WebGestaltR)
  GSEA <- WebGestaltR(
    enrichMethod = "GSEA",
    organism = "hsapiens",          #  <=organism is specified here
    enrichDatabase = c(
      "geneontology_Biological_Process_noRedundant",
      "geneontology_Cellular_Component_noRedundant",
      "geneontology_Molecular_Function_noRedundant",
      "pathway_KEGG"
    ),
    enrichDatabaseType = "uniprotswissprot",
    interestGene = GSEA_input,
    interestGeneType = "uniprotswissprot",
    collapseMethod = "mean",
    minNum = 50,
    maxNum = 200,
    sigMethod = "fdr",
    fdrMethod = "BH",
    fdrThr = 0.05,
    topThr = 15,
    reportNum = 40,
    perNum = 1000,
    isOutput = T,
    outputDirectory = subfolder,
    projectName = "GSEA_DifferentialExpression",
    dagColor = "continuous",
    gseaPlotFormat = "png"
  ) 
  return(GSEA)
}
count <- 0
source("GSEA_function.R")
GSEA_output_list <-
  lapply(seq_along(conditions_adapted), function(i) {
    count <<- count + 1
    print(paste0("(",count,"/",length(conditions_adapted),")"))
    Perform_GSEA(GSEA_list[[i]], subfolder_list[[i]])
  })
Pchaskar commented 1 year ago

I encountered the same issue recently. I appreciate any solution to resolve this issue. Thanks

iblacksand commented 1 year ago

The server had a storage issue which is now resolved, so everything should be running now. If it is not working please let us know.

Pchaskar commented 1 year ago

Still not working from my side

iblacksand commented 1 year ago

I can run the GSEA example without an issue with the latest version. Can you try the following example code and check if you still see this problem?

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)
SamDCalis commented 1 year ago

For me it is working fine now. No more issues, thanks.

Pchaskar commented 1 year ago

Thanks it works now though with a custom gmt file the error persist but it worked in the past. I will verify the gmt. Thanks again