Tutorials › High-Dimensional Genomic Data Analysis › The Running-Sum Statistic in Gene Set Enrichment Analysis

Gene Set and Pathway Enrichment · Tutorial 462 of 795

The Running-Sum Statistic in Gene Set Enrichment Analysis

You will calculate each hit and miss increment in the unweighted GSEA running sum and interpret how the positions of pathway genes shape the walk.

Intermediate 9 min read

What You'll Learn

  • Define the unweighted running sum for a ranked list and a pathway.
  • Calculate hit and miss increments from the list and pathway sizes.
  • Trace the cumulative statistic rank by rank and verify its endpoint.
  • Compare trajectories when the same pathway hits occur in different positions.
  • Recognize data and setup problems that make a running sum misleading or undefined.
  • Distinguish a ranked-list running sum from threshold-based over-representation analysis.

From a Ranked List to a Running Sum

A ranked gene list retains information that is lost when genes are reduced to a selected/not-selected list. In gene set enrichment analysis (GSEA), the running sum makes that positional information visible: move down the ordered list one gene at a time, adding a fixed amount when the gene belongs to the pathway and subtracting a fixed amount when it does not. The resulting sequence records how pathway hits are distributed across the ranking.

This tutorial focuses on the unweighted running sum. It uses only pathway membership and position in the ranked list; it does not give larger hit increments to genes with more extreme ranking statistics. The ranked list is assumed to be ordered from the top-ranked gene to the bottom-ranked gene, using the ranking statistic chosen for the analysis.

Definition: Let \(N\) be the number of genes in the ranked list, and let \(S\) be the pathway being evaluated. Assume that each gene in the tested universe appears exactly once in the list, and that \(S\) contains \(N_H\) genes from this universe, with \(0<N_H<N\). At position \(i\), define the running sum \(R_i\) by starting at \(R_0=0\) and adding \(1/N_H\) if the gene at position \(i\) belongs to \(S\), or subtracting \(1/(N-N_H)\) if it does not. Thus, a hit is a pathway member and a miss is a nonmember.

The hit step is \(1/N_H\), so the total contribution of all \(N_H\) hits is 1. The miss step is \(-1/(N-N_H)\), so the total contribution of all \(N-N_H\) misses is -1. These equal-and-opposite totals make the running sum return to zero when the entire list has been traversed. A gene's position determines when its increment is added; its membership determines which increment is used.

The assumptions matter. The list must represent the tested-gene universe for the analysis, and pathway membership must be checked against that same universe. A pathway gene absent from the list is not a hit in this calculation. If \(N_H=0\), there are no hits and the hit increment is undefined; if \(N_H=N\), there are no misses and the miss increment is undefined. In either edge case, the usual two-sided running-sum construction does not apply.

Calculating the Walk

The calculation is cumulative: each new value equals the preceding value plus the increment for the current gene. A compact table can show the rank, membership, increment, and resulting running sum. Fractions are useful while calculating because they help identify arithmetic errors; decimal values can be reported afterward.

$$ R_i = \begin{cases} R_{i-1}+\dfrac{1}{N_H}, & \text{if the gene at position }i\text{ is a pathway member},\\[6pt] R_{i-1}-\dfrac{1}{N-N_H}, & \text{if it is not.} \end{cases} $$

Worked Example: Tracing Four Hits Through Ten Genes

Consider a hypothetical ranked list of \(N=10\) genes. A pathway contains \(N_H=4\) of them, at ranks 2, 3, 7, and 9. The hit increment is \(1/4=0.25\), and the miss decrement is \(1/(10-4)=1/6\approx0.1667\). Starting at zero, add the appropriate increment at each rank.

RankMembershipIncrementRunning sum
0Start—0
1Miss\(-1/6\)\(-1/6\approx-0.1667\)
2Hit\(+1/4\)\(1/12\approx0.0833\)
3Hit\(+1/4\)\(1/3\approx0.3333\)
4Miss\(-1/6\)\(1/6\approx0.1667\)
5Miss\(-1/6\)0
6Miss\(-1/6\)\(-1/6\approx-0.1667\)
7Hit\(+1/4\)\(1/12\approx0.0833\)
8Miss\(-1/6\)\(-1/12\approx-0.0833\)
9Hit\(+1/4\)\(1/6\approx0.1667\)
10Miss\(-1/6\)0

For example, after rank 3 the cumulative sum is \(-1/6+1/4+1/4=1/3\). The first two hits are adjacent, so they raise the walk in succession. The later hit at rank 7 raises it again, while the intervening and subsequent misses pull it downward. The displayed values describe the path; they are not a significance test or a probability.

Why the Walk Returns to Zero

The endpoint is a useful check on both the formula and the arithmetic. Across the complete list there are exactly \(N_H\) hit increments and \(N-N_H\) miss increments. Their total is therefore:

$$ N_H\left(\frac{1}{N_H}\right) +(N-N_H)\left(-\frac{1}{N-N_H}\right) =1-1=0. $$

Since \(R_0=0\), the sum of all increments gives \(R_N=0\). This result does not depend on where the hits occur. If a hand calculation over the complete list ends noticeably above or below zero, check the pathway size, the number of hits and misses, and whether each rank was counted once. The return to zero is not evidence that the pathway is unimportant; it is built into the normalization.

The step sizes also explain why a running sum can rise or fall at different rates. With few pathway members, each hit has a larger positive increment. With many nonmembers, each miss has a smaller negative decrement. The total upward and downward contributions remain balanced over the full list, but their order determines the intermediate trajectory.

Worked Example: Hits Concentrated Near the Bottom

Suppose a hypothetical list has \(N=8\) genes and a pathway with \(N_H=3\) members, at ranks 1, 5, and 8. Each hit adds \(1/3\approx0.3333\); each of the five misses subtracts \(1/5=0.2\). The first hit moves the sum to \(0.3333\), and the misses at ranks 2, 3, and 4 give \(0.1333\), \(-0.0667\), and \(-0.2667\), respectively. The hit at rank 5 adds \(0.3333\), giving \(0.0667\). Misses at ranks 6 and 7 reduce the sum to \(-0.1333\) and \(-0.3333\). The final hit adds \(0.3333\), returning the sum to zero.

The three pathway members occur at separated positions, including two near the bottom. Accordingly, the walk does not keep rising as it moves down the list: each stretch of misses produces downward steps until another hit appears. This example illustrates why the running sum records the arrangement of hits, rather than merely their count.

Worked Example: Same Pathway Size, Different Hit Positions

Compare two hypothetical lists, each with \(N=6\) and \(N_H=2\). In both, a hit adds \(1/2=0.5\) and a miss subtracts \(1/4=0.25\). In the first list, the hits are at ranks 1 and 2. The successive sums are \(0.5,\ 1.0,\ 0.75,\ 0.50,\ 0.25,\ 0\). The consecutive hits create two upward steps before the misses bring the walk back down.

In the second list, the hits are at ranks 2 and 5. The successive sums are \(-0.25,\ 0.25,\ 0,\ -0.25,\ 0.25,\ 0\). Here the first rank is a miss, and the hits are separated by other genes, so the walk alternates between upward and downward movement. The lists have the same size and the pathway has the same number of members, but their running-sum trajectories differ because the hit positions differ.

Assumptions, Diagnostics, and Alternatives

Before interpreting a trajectory, verify that the ranking and membership inputs match the intended analysis. The ordering must be meaningful for the question being studied, and the pathway must be intersected with the exact tested-gene universe used to build the list. Tied ranking statistics can make the order of tied genes ambiguous; record the tie-handling rule, especially if changing the order could change the visible path. Duplicate gene identifiers can also create false extra hits or alter the denominators, so map identifiers consistently and ensure each gene appears once.

Useful checks include counting \(N\), \(N_H\), and \(N-N_H\); confirming that the number of hit rows is \(N_H\); checking the hit and miss increment sizes; and verifying \(R_N=0\). A trajectory with large, repeated steps may be correct for a small pathway, but first rule out duplicated members or an incorrect pathway intersection. If the final value is not zero, the calculation or inputs are inconsistent with the stated definition.

The running sum differs from threshold-based over-representation analysis. Over-representation analysis first selects a set of genes using a cutoff, then asks whether pathway membership is unusually common among those selected genes relative to the tested universe. The running sum instead uses the full ordering and lets the positions of pathway members affect the sequence. It can therefore preserve information about genes close to a selection threshold, but it also depends on the quality and direction of the ranking. Neither calculation by itself establishes a biological mechanism or a causal effect.

A further distinction is between this unweighted walk and weighted GSEA variants. Here every hit contributes the same amount, regardless of the gene's ranking statistic. A weighted variant changes the hit contribution, so its step sizes cannot be calculated with the unweighted rule above. The running-sum trajectory is the object studied here; converting that trajectory into a single enrichment score and assessing its statistical significance require additional definitions and procedures.

Common Mistakes

  • Using the same decrement as the hit increment. The steps are generally not equal in magnitude: a hit adds \(1/N_H\), while a miss subtracts \(1/(N-N_H)\).
  • Counting pathway genes outside the ranked list. The hit count \(N_H\) is the number of pathway members in the tested list, not the size of the pathway annotation before intersection.
  • Reading the endpoint as evidence against enrichment. The walk ends at zero by construction, whatever the hit positions. Interpret its intermediate path, not the endpoint alone.
  • Assuming the hit count determines the trajectory. A fixed pathway size determines the step sizes, but the order of hits and misses determines the sequence of running-sum values.
  • Calling the unweighted calculation weighted. In this definition, all hits have identical increments; a gene's ranking statistic does not change its hit step.
Key takeaway: The unweighted GSEA running sum is a cumulative walk through the ranked list: add \(1/N_H\) at each pathway member and subtract \(1/(N-N_H)\) at every nonmember. Its intermediate shape reflects where pathway hits occur, and its full-list endpoint is zero.

Check Your Understanding

Answer each question, then compare your work with the solutions below.

  1. A ranked list contains 12 genes, 3 of which belong to a pathway. What are the hit increment and miss decrement?
  2. For \(N=5\) and \(N_H=2\), pathway hits occur at ranks 2 and 4. Calculate the running sum after every rank.
  3. Why must a correctly calculated complete running sum end at zero?
  4. Two pathways have the same number of members in the same ranked list. What can make their running-sum trajectories differ?
  5. Why is it a mistake to count pathway members absent from the ranked list as hits?

Solutions. (1) The hit increment is \(1/3\approx0.3333\); the miss decrement is \(1/(12-3)=1/9\approx0.1111\). (2) The increments are \(-1/3,+1/2,-1/3,+1/2,-1/3\), so the successive sums are \(-1/3,\ 1/6,\ -1/6,\ 1/3,\ 0\). (3) The three hits contribute \(3(1/3)=1\), and the three misses contribute \(3(-1/3)=-1\); their total is zero. (4) Their members can occur at different ranks, changing the order of upward and downward steps. (5) Only genes in the ranked list can contribute increments, so pathway membership must be intersected with the tested universe before \(N_H\) and the hit steps are calculated.

Clinical Biostats