Right on, thanks!
Hi there,
Ran into an issue with fgsea and I wasn't able to find an appropriate solution anywhere.
The code:
fgsea$Entrez = convert2EntrezID(fgsea$ensembl_gene_id, "org.Hs.eg.db", "ensembl_gene_id")
gseaDat <- filter(fgsea, !is.na(entrez))
ranks <- gseaDat$log2FoldChange
names(ranks) <- gseaDat$entrez
head(ranks)
load("mouse_H_v5-1.rdata")
pathwaysH <- Mm.H
fgseaRes <- fgsea(pathwaysH, ranks, minSize=15, maxSize = 500, nperm=1000)
This is resulting in fgseaRes being 0 obs. of 8 variables.
Please let me know if there is an error I am making or something else I should be doing in the code. Thanks!
1 answer
Empty result in fgsea means that no input pathway passed the size limits. A common reason is that you are using different gene ID types for stats and for pathways. For example, you rank gene IDs seems to be of Entrez type, but I suspect pathway gene IDs are gene symbols. The size of intersection length(intersect(names(ranks), unlist(pathwaysH))) should be non-zero.
For MSigDB based pathways I recomment use msigdbr package. There you can easily select the required gene IDs type. For example:
library(msigdbr)
# Hallmark pathways from MSigDB
df <- msigdbr(species = "Homo sapiens", category = "H")
df
pathways <- split(df$entrez_gene, df$gs_name)
Log in to answer this question.
It looks like you are mixing both human and mouse data at the same time?
org.Hs.eg.dbis a homo sapiens (Hs) database, while later you are loading mouse pathways.Great catch, thanks! However, even after replacing org.Hs.eg.db with org.Mm.eg.db fgseaRes comes out as 0 obs. of 8 variables, not sure why.
Empty data.table (0 rows and 8 cols): pathway,pval,padj,ES,NES,nMoreExtreme...
In the first line you write "Entrez", while in the others "entrez", that could be a reason.