This is a test version of Biostars. For the public version, visit https://www.biostars.org.
collapsePathways function throwing error

I am trying to perform GSEA on DESeq2 results by ranking the t stat and successfully ran fgsea to extract a list of enriched pathways. However, when I run the collapsePathway function, I receive this error message:

Error in preparePathwaysAndStats(pathways, stats, minSize, maxSize, gseaParam,  : 
  Not all stats values are finite numbers

My code:

res.fgsea <- fgsea(pathways = gmt.file, stats=ranked_genes, 
                       minSize=15, maxSize=500)

cp.res <- collapsePathways(fgseaRes=res.fgsea[order(pval)][padj < 0.05], 
                                           pathways = gmt.file, 
                            stats=ranked_genes)

Please could you help me with this issue.

gsea fgsea r

I encountered the same issue while I am sure the data type of stats are finite numbers. Is there a solution to this issue now? (PS: I was analyzing GSE48301 using hugene10sttranscriptcluster.db and GO file (c2.all.v2023.2.Hs.symbols.gmt.txt))

3 answers

Hello, I've had the same error. In my case, the names of ranked_genes contain NA values.  I recommend that you check this. table(is.na(names(ranked_genes)))

I think your issue is that you're sending ALL pathways to collapsePathways and not those present in your reduced fgseaRes object.

Ok, should I filter the pathways gmt file to include only those in fgseaRes?

I don't think so, collapsePathways filters the pathway list in the begining to contain only the pathways present in the filtered fgseaRes table.

Hi, as the error says, it means that some of your values in ranked_genes seem to be non-finite numbers (such as NAs or Infs). Can you check that all(is.finite(ranked_genes)) is true? If not, you should do something with these genes, e.g. remove them from your vector.

Running all(is.finite(ranked_genes)) returns TRUE so I am not sure why it is saying that not all the stats values are finite.

Log in to answer this question.