Why Hit Contributions Can Differ
In GSEA, the ranked list retains information about where genes lie in an ordered list, rather than reducing the analysis to a selected set of genes and a cutoff. The running sum moves upward when it encounters a gene in the gene set and downward when it encounters a gene outside the set. The size of each upward step determines whether all hits count equally or whether genes with larger ranking-statistic magnitudes have more influence.
An unweighted running sum gives every gene-set member the same hit increment. A weighted running sum makes a hit increment proportional to the magnitude of that gene’s ranking statistic raised to a chosen exponent. The exponent therefore controls how strongly large-magnitude statistics dominate the hit contributions. It does not change the gene order or the positions of hits and misses.
Here a hit means that the gene at the current rank belongs to \(S\); a miss means it does not. The ranking statistic is signed, so its sign helps determine the gene’s position in the ranked list. The hit increment itself uses the statistic’s absolute magnitude. Thus the contribution is nonnegative: direction in the ranking is represented by position, not by a negative hit step.
Normalization and the Role of the Exponent
The normalization makes the total upward movement across all hits equal to one. The total downward movement across all misses is also one. Consequently, the running sum returns to zero after the final ranked gene, apart from rounding in displayed calculations. This endpoint check is useful: a nonzero endpoint usually signals an incorrect increment, decrement, or gene-set size.
For \(p=0\), the convention is equal hit increments, \(1/N_H\), rather than evaluating a zero-to-the-zero power. For \(p>0\), increasing \(p\) concentrates more of the total hit weight on genes with larger \(|r_j|\). It does not guarantee that the ES will increase: the effect depends on where those high-magnitude hits occur relative to the misses and other hits.
A useful invariance follows directly from the formula. If every ranking statistic is multiplied by the same positive constant \(c\), then each weighted hit contribution is unchanged, since both numerator and denominator are multiplied by \(c^p\). The ranking order is also unchanged. Thus the weighted path depends on relative magnitudes within the gene set, not on the overall units of the ranking statistic.
Worked Example: Unweighted Hits and a Tied Extreme
Suppose six genes are ranked in this order, with hypothetical statistics \(6,4,2,1,0,-1\). The gene set contains the genes at positions 1, 3, and 6, so \(N=6\), \(N_H=3\), and there are three misses. Use the unweighted rule, \(p=0\).
Each hit adds \(1/3\), and each miss subtracts \(1/3\). Applying those increments in order gives:
The largest positive departure is \(1/3\), and the largest negative departure is \(-1/3\). They tie in absolute value. Under the stated positive-extreme tie convention, the signed ES is \(+1/3\). Without a tie convention, the path determines the maximum absolute departure but does not uniquely determine its sign. The final running sum is zero, as required by the equal total hit and miss movements.
Worked Example: Changing the Exponent on the Same Ranked List
Use the same six-gene list and the same gene-set positions: 1, 3, and 6. The hit magnitudes are \(6,2,1\), while each of the three misses still decrements the running sum by \(1/3\). Compare \(p=1\) with \(p=2\).
For \(p=1\), the sum of hit magnitudes is \(6+2+1=9\), so the three hit increments are \(6/9=0.6667\), \(2/9=0.2222\), and \(1/9=0.1111\). The running sums are:
The maximum positive departure is \(0.6667\), larger in absolute value than the negative departure \(-0.1111\), so \(ES=+0.6667\).
For \(p=2\), the sum of squared hit magnitudes is \(6^2+2^2+1^2=41\). The hit increments are \(36/41=0.8780\), \(4/41=0.09756\), and \(1/41=0.02439\). Including the same miss decrements, the running sums are approximately \(0.8780,\ 0.5447,\ 0.6423,\ 0.3090,\ -0.02439,\ 0\). The maximum absolute departure is \(0.8780\), so \(ES=+0.8780\).
For this list, the larger exponent emphasizes the hit at position 1, where the statistic magnitude is greatest, and increases the positive ES. This is an outcome of these particular hit positions and magnitudes, not a general rule that increasing \(p\) must increase ES.
Weighting Can Change the Direction
The exponent can affect not only the score’s size but also which side of zero has the largest departure. This happens when hits with different magnitudes occur at different positions. A large-magnitude hit late in the list may pull the running sum strongly upward after an earlier stretch of misses; depending on the other steps, the largest departure can be negative even though all hit increments are positive.
Worked Example: A Weighted Score With the Opposite Sign
Consider four genes ranked by the hypothetical signed statistics \(1,\ 0.5,\ -0.5,\ -5\), in descending order. Suppose the gene set contains the genes at positions 1 and 4. There are two hits and two misses, so each miss decrements by \(1/2\).
With \(p=0\), both hits add \(1/2\). The path is \(1/2,\ 0,\ -1/2,\ 0\). Its positive and negative extremes tie in absolute value, so the stated convention gives \(ES=+1/2\).
With \(p=1\), the hit magnitudes are 1 and 5, and their total is 6. The increments are \(1/6\) and \(5/6\). The path is \(1/6,\ 1/6-1/2=-1/3,\ -1/3-1/2=-5/6,\ -5/6+5/6=0\). The largest absolute departure is \(-5/6\), so \(ES=-5/6\). Here the larger hit is late in the list; weighting it more heavily changes the score’s direction under the signed-maximum convention.
Assumptions, Checks, and Comparisons
These calculations require a fixed ranked list and a defined gene set drawn from that list. Each gene should have one unambiguous position, and \(0<N_H<N\), so there is at least one hit and one miss. A deterministic order for tied ranking statistics is needed if ties could change the hit positions and running-sum path. For \(p>0\), the total \(\sum_{g\in S}|r_g|^p\) must be positive; if all hit statistics are zero, the weighted formula is undefined. In that case, use an explicitly chosen alternative ranking statistic or the unweighted rule rather than silently dividing by zero.
Several checks help catch implementation or hand-calculation errors:
- Hit increments are nonnegative and sum to one; miss decrements are equal and sum in magnitude to one.
- The running sum ends at zero, up to rounding.
- The ES is the extreme with greatest absolute value, not necessarily the final running-sum value or the largest positive value alone.
- If all hit magnitudes are equal, normalized weighted increments are equal for every \(p>0\), so the weighted path matches the unweighted path.
- A larger \(p\) can amplify, reduce, or reverse the signed ES; inspect the entire path rather than inferring the result from the exponent alone.
Weighted and unweighted GSEA differ in how they allocate the total upward hit movement. The unweighted version treats membership as the only determinant of a hit’s step size. A weighted version also uses the ranking-statistic magnitudes, making the result sensitive to their relative values within the gene set. By comparison, threshold-based over-representation analysis asks about membership in a selected subset and does not retain the full ranked order. The running-sum ES preserves order, but its value alone is not a significance test: it does not provide a p-value or quantify how unusual the observed score is under a null model.
A common mistake is to say that a larger exponent always makes enrichment stronger because it gives more weight to large statistics. That reasoning confuses a larger contribution for one hit with a guaranteed increase in the maximum deviation. In fact, the contribution’s effect depends on its location in the path. A large early hit can increase a positive extreme, while a large late hit can deepen a negative extreme or offset earlier movement. Calculate the contributions and follow the running sum before interpreting the score.
Check Your Understanding
Answer each question, then compare with the solutions below.
- A list has five genes, with hits at positions 2 and 5. Under \(p=0\), what are the running sums and signed ES using the positive-extreme tie convention?
- A set has two hits with magnitudes 3 and 1 in a five-gene list. Under \(p=1\), the hits are at positions 1 and 4. Calculate the hit increments, running-sum path, and ES.
- Under \(p=1\), what happens to the hit increments if every ranking statistic is multiplied by 10?
- Is it always true that increasing \(p\) increases the signed ES? Explain using a running-sum argument.
Solutions. (1) Each hit adds \(1/2\), and each of the three misses subtracts \(1/3\). The path is \(-1/3,\ 1/6,\ -1/6,\ -1/2,\ 0\). The largest absolute departure is \(-1/2\), so \(ES=-1/2\). (2) The hit-weight total is \(3+1=4\), giving increments \(3/4\) and \(1/4\); each miss decrements by \(1/3\). The path is \(3/4,\ 5/12,\ 1/12,\ 1/3,\ 0\), so \(ES=3/4\). (3) Each numerator and the denominator are multiplied by \(10\), so their ratio is unchanged; the hit increments do not change. (4) No. The exponent reallocates hit weight according to magnitude, and the positions of the reweighted hits determine how the path changes. In the four-gene example above, changing from \(p=0\) to \(p=1\) changes the ES from \(+1/2\) to \(-5/6\), because the larger hit is at the end of the list.