GSEA asks: is a predefined pathway gene set concentrated near the top or bottom of a list of all genes ranked by a differential-expression metric, rather than scattered randomly? Walking down the ranked list of N genes, a running sum is updated at every position i:
hit (gene i in set): running += |r_i|^p / Σ|r_h|^p (sum over all hits h)
miss (gene i not in set): running -= 1 / (N - N_h)
ES = running sum value of maximum absolute magnitude over the whole walk
This is the Kolmogorov–Smirnov-like running-sum statistic from Subramanian et al. (2005, PNAS). p = 0 reduces it to the classic unweighted KS statistic; p = 1 weights each hit by its expression score so strongly regulated genes pull the curve harder; p = 2 emphasises the strongest hits even more.
- Top/bottom layer — the ranked-list bars: each gene's differential-expression metric, red = up-regulated, blue = down-regulated, sorted highest to lowest.
- Middle layer — the hit "barcode": a gold tick wherever a pathway gene falls in the ranking.
- Upper curve — the running enrichment score, exactly as in a published GSEA enrichment plot. Its peak (dashed marker) is the reported ES.
- Leading edge — the hits between the start of the list and the peak (or the peak and the end, if ES is negative) — the genes actually driving the enrichment signal.
- Permutation test — resamples 500 random gene sets of the same size against the fixed ranking to build a null distribution of ES values; the p-value is the fraction of null scores at least as extreme as the observed one. Published GSEA more commonly permutes the phenotype labels instead — gene-set permutation here is a simplified, equally valid way to see the same significance logic.