Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Over-representation and GSEA

The tests of Gene-set tests read the linear model of every gene. Often there is less to go on: a list of the genes that an analysis called significant, or one statistic for every gene, from any method. This chapter tests gene sets from those. gsea is the default along a ranking: it asks whether each set’s genes sit near the top or the bottom when all genes are ordered by a statistic, as fgsea computes it Subramanian et al., 2005Korotkevich et al., 2021. over_representation asks whether a set has more of its genes among those called significant than chance would give, as limma’s kegga computes it Young et al., 2010. Gene sets and pathways runs both on published data.

Over-representation analysis

Say that nn genes of a universe of NN are selected, such as the genes called significant, and that a set has KK genes in the universe, kk of them selected. Were the nn genes drawn at random from the universe, kk would be hypergeometric with mean Kn/NK n / N, the overlap expected by chance, and the p-value is the chance of an overlap at least as large Tavazoie et al., 1999:

P(X≥k)=∑j=kmin⁡(K,n)(Kj)(N−Kn−j)(Nn),P(X \ge k) = \sum_{j=k}^{\min(K, n)} \frac{\binom{K}{j} \binom{N - K}{n - j}}{\binom{N}{n}},

which is also the p-value of Fisher’s exact test, one-sided, for the table of the genes in and out of the set, selected or not Fisher, 1922Rivals et al., 2007.

over_representation selects the genes of a cell type and contrast of a differential-expression result, or of any table of results, whose adjusted p-value is below alpha. Like kegga and goana on a fit of limma, it tests the genes up and the genes down as two lists, and adds both together as a third. A list of genes from elsewhere is tested as it is, against a universe that you give. The p-values of each list are adjusted over its sets by Benjamini and Hochberg’s method Benjamini & Hochberg, 1995, and plot_over_representation draws the sets with the smallest p-values in any list, with a dot for each list, as clusterProfiler compares lists of genes Yu et al., 2012.

The universe

The universe holds every gene that the analysis could have selected, which by default means every gene with a p-value. The genes of the genome, or of all the sets, include genes that were never expressed, or were filtered out before the tests, and so could not have been selected; they make the p-values too small Timmons et al., 2015Wijesooriya et al., 2022. Genes outside a universe that you give are left out, even when selected or in a set, and genes of the universe that belong to no set still count, as in kegga.

Gene set enrichment analysis

Gene set enrichment analysis (GSEA) orders all genes by a statistic, such as a contrast’s moderated t-statistic, and asks whether a set’s genes crowd towards either end of the ranking Subramanian et al., 2005. It needs no cutoff, and the statistic can come from any method. A walk down the ranking of NN genes steps up at each of the set’s mm genes and down at every other gene; after the ii-th gene of the set, at rank pip_i, it stands at

RSi=∑j≤i∣rj∣q∑j=1m∣rj∣q−pi−iN−m,\mathrm{RS}_i = \frac{\sum_{j \le i} |r_j|^q}{\sum_{j = 1}^{m} |r_j|^q} - \frac{p_i - i}{N - m},

with rjr_j the statistics of the set’s genes and qq the exponent: 1 for the weighted score of GSEA, 0 for the unweighted one of Mootha et al. (2003). The enrichment score is the walk’s furthest point from zero: positive when the set’s genes gather at the top and negative when they gather at the bottom. The leading edge is the genes that drive the score: the set’s genes up to the walk’s extreme, counted from the top for a positive score and from the bottom for a negative one.

gsea ranks the statistics of a cell type and contrast of a differential-expression result, of a table of results, or of gene ids mapped to statistics, and tests each set with at least one gene in the ranking; a set of every ranked gene is not tested. plot_enrichment draws the walk of one set, as fgsea’s plotEnrichment does, and plot_gsea_table the top sets with their genes on the ranking, as its plotGseaTable does.

p-values from random sets

The scores of random sets of the same size give the null distribution, so that the test is competitive, like camera’s, and it permutes genes, not samples. Dividing a score by the mean random score of its sign gives the normalized enrichment score, which lets sets of different sizes compare, and the p-value is the share of the random scores of its sign that reach it: with nn random scores of that sign, at least 1/(n+1)1/(n + 1). fgsea’s multilevel method, the default, reaches far smaller p-values Korotkevich et al., 2021. It draws random sets of the size of the set, keeps at each level the half with the higher scores and moves them by a Markov chain that keeps their scores above the level’s median, so that each level about halves the probability, until the median reaches the observed score; log2_error estimates the standard deviation of log⁡2p\log_2 p. With the multilevel method, a set with under 10 random scores of its sign gets no p-value, as in fgsea.

The random sets come from seeds that rng draws, through the Mersenne Twister Matsumoto & Nishimura, 1998 seeded as C++ seeds it, as fgsea draws them: a seed gives the same results every time, and given fgsea’s seeds, gsea gives fgsea’s results exactly. CytePool’s routines are adapted from fgsea’s, under its MIT licence (Related software).

Defaults and choices

Limits and differences

Checks and further reading

Further reading:

Pathway scores per sample, the next chapter, gives every sample a score of each gene set.

References
  1. Subramanian, A., Tamayo, P., Mootha, V. K., Mukherjee, S., Ebert, B. L., Gillette, M. A., Paulovich, A., Pomeroy, S. L., Golub, T. R., Lander, E. S., & Mesirov, J. P. (2005). Gene set enrichment analysis: A knowledge-based approach for interpreting genome-wide expression profiles. Proceedings of the National Academy of Sciences, 102(43), 15545–15550. 10.1073/pnas.0506580102
  2. Korotkevich, G., Sukhov, V., Budin, N., Shpak, B., Artyomov, M. N., & Sergushichev, A. (2021). Fast gene set enrichment analysis. bioRxiv 060012, version 3. 10.1101/060012
  3. Young, M. D., Wakefield, M. J., Smyth, G. K., & Oshlack, A. (2010). Gene ontology analysis for RNA-seq: accounting for selection bias. Genome Biology, 11(2), R14. 10.1186/gb-2010-11-2-r14
  4. Tavazoie, S., Hughes, J. D., Campbell, M. J., Cho, R. J., & Church, G. M. (1999). Systematic determination of genetic network architecture. Nature Genetics, 22(3), 281–285. 10.1038/10343
  5. Fisher, R. A. (1922). On the interpretation of χ2 from contingency tables, and the calculation of P. Journal of the Royal Statistical Society, 85(1), 87–94. 10.2307/2340521
  6. Rivals, I., Personnaz, L., Taing, L., & Potier, M.-C. (2007). Enrichment or depletion of a GO category within a class of genes: which test? Bioinformatics, 23(4), 401–407. 10.1093/bioinformatics/btl633
  7. Benjamini, Y., & Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society: Series B (Methodological), 57(1), 289–300. 10.1111/j.2517-6161.1995.tb02031.x
  8. Yu, G., Wang, L.-G., Han, Y., & He, Q.-Y. (2012). clusterProfiler: an R package for comparing biological themes among gene clusters. OMICS: A Journal of Integrative Biology, 16(5), 284–287. 10.1089/omi.2011.0118
  9. Timmons, J. A., Szkop, K. J., & Gallagher, I. J. (2015). Multiple sources of bias confound functional enrichment analysis of global -omics data. Genome Biology, 16, 186. 10.1186/s13059-015-0761-7
  10. Wijesooriya, K., Jadaan, S. A., Perera, K. L., Kaur, T., & Ziemann, M. (2022). Urgent need for consistent standards in functional enrichment analysis. PLoS Computational Biology, 18(3), e1009935. 10.1371/journal.pcbi.1009935
  11. Mootha, V. K., Lindgren, C. M., Eriksson, K.-F., Subramanian, A., Sihag, S., Lehar, J., Puigserver, P., Carlsson, E., Ridderstråle, M., Laurila, E., Houstis, N., Daly, M. J., Patterson, N., Mesirov, J. P., Golub, T. R., Tamayo, P., Spiegelman, B., Lander, E. S., Hirschhorn, J. N., … Groop, L. C. (2003). PGC-1α-responsive genes involved in oxidative phosphorylation are coordinately downregulated in human diabetes. Nature Genetics, 34(3), 267–273. 10.1038/ng1180
  12. Matsumoto, M., & Nishimura, T. (1998). Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random number generator. ACM Transactions on Modeling and Computer Simulation, 8(1), 3–30. 10.1145/272991.272995
  13. Durstenfeld, R. (1964). Algorithm 235: Random permutation. Communications of the ACM, 7(7), 420. 10.1145/364520.364540