4

I'm trying to perform a GSEA analysis following this pipeline:

https://learn.gencore.bio.nyu.edu/rna-seq-analysis/gene-set-enrichment-analysis/

But when I run the code: the following message appears:

**> Error in (function (classes, fdef, mtable) : unable to find an

inherited method for function ‘species’ for signature ‘"character"’**

This is the code I'm running:

library(clusterProfiler)
library(enrichplot)
library(ggplot2)

# SET THE DESIRED ORGANISM HERE
organism = "org.Dm.eg.db"
BiocManager::install(organism, character.only = TRUE)
library(organism, character.only = TRUE)

original_gene_list <- df$log2FoldChange
names(original_gene_list) <- df$X
gene_list<-na.omit(original_gene_list)

# sort the list in decreasing order (required for clusterProfiler)
gene_list = sort(gene_list, decreasing = TRUE)

gse <- gseGO(geneList=gene_list, 
             ont ="ALL", 
             keyType = "ENSEMBL", 
             minGSSize = 3, 
             maxGSSize = 800, 
             pvalueCutoff = 0.05, 
             verbose = TRUE, 
             OrgDb = organism, 
             pAdjustMethod = "none")

What I read is that I may have two packages in which the function"species" is present, but here I'm not running any function called species.

How can I solve this problem?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Vera García
  • 43
  • 1
  • 5

2 Answers2

4

In this case, "OrgDb" parametrer of gseGO needs the object, not the variable annotation name. It means that you cannot use:

OrgDb = "org.Dm.eg.db"

Instead, you must use:

OrgDb = org.Dm.eg.db

Or which I think is the best option, obtain the boject by it's name:

OrgDb = get("org.Dm.eg.db")

The most elegant option is update your organism assignation to organism = get("org.Dm.eg.db")

fmjabato
  • 41
  • 2
3

In the fifth line of your code, you need to change your code from

organism = "org.Dm.eg.db"

to

organism = org.Dm.eg.db

Because when you're using the gseGO function in you last line, you use the parameter "OrgDb" as "OrgDb = organism". In fact, the parameter should be OrgDb = org.Dm.eg.db rather than a character variable for "org.Dm.eg.db".

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574