This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How p value is calculated in GSEA?

I have two gene sets from GSEA for example; and I am calculating the intersection between them. I am trying to calculate the p value that the intersection of these sets occurs by chance.
I wrote python script that calculates that p value but I wanted to double check if that's indeed the value i'm supposed to get.
In this website you can do the exact same thing and get the p value - for example here's a link to a comparison between the gene set MYMOD_07 and others.
As you can see, one of the columns is the p value and I was wondering how was it actually calculated?
Is it two sided or one sided? if it's one sided then from which side? Is it the logarithmic value?

geneset p value

I came across this page before but I'm quite a beginner in bioinformatics and especially in statistics, hence It's quite hard for me to navigate there for my answer through all the lingo I'm not familiar with.
Could you please explain the answer explicitly?

2 answers

GSEA works by ranking all genes used in an analysis by some statistic. So this might be all genes in the genome (traditionally all genes with a probe on an array).

Start with an enrichment score of 0. Then take the gene ranked No. 1, and ask if it is in your gene-set. If it is you increase the enrichment score, if not decrease the enrichment score. Then move on to the gene ranked No. 2 and do the same thing. And so on down the whole list of genes. When you've done, find the highest the enrichment score you ever got. This is your Enrichment Score for that gene-set.

Next randomly shuffle the gene ranks (or sample labels) to put them in a random order, and repeat the scoring process above. Do this 1000 times.

Two things are now calculated - The P-value is calculated by looking at how often the Enrichment score from actual ranking is bigger than that for the random permulations. The Normalised Enrichment Score is calcualted by dividing the Enrichment Score from the actual ranking by the mean of the random permutations.

The FDR is calculated by comparing the distribution of Normalised Enrichment Scores from many different genesets.

Hi, I find this explanation very helpfull:

If you are only interested in enrichment alone, you chose the one sided test. But if you are additionally interested in underrepresentation, you choose the two-sided one. I cant see the data, but your task sounds like you are only interested in whether there is enrichment of genes of one gene set within another gene set, so you could do the one-sided one.

GSEA (the specific algorithm from the Broad, rather than the general class of analyses that looks at gene sets) does not use fishers exact test for enrichment.

Thank you, I did not know that and just assumed it, because every other tool I came across uses it. I will only slightly edit the anser, to avoid confusion.

Log in to answer this question.