Inferensys

Glossary

Running Sum Statistic

A sequential calculation used in Gene Set Enrichment Analysis (GSEA) that walks down a ranked gene list, increasing when a gene is in the target set and decreasing otherwise, to detect non-random clustering of the set.
Finance team analyzing AI ROI on laptop, investment return charts visible, business case review session.
GSEA CORE METRIC

What is Running Sum Statistic?

The running sum statistic is the sequential calculation at the heart of Gene Set Enrichment Analysis that quantifies the non-random distribution of a predefined gene set within a ranked list of all genes.

A running sum statistic is a sequential, cumulative calculation used in Gene Set Enrichment Analysis (GSEA) to detect whether members of a predefined gene set are clustered at the extremes of a ranked gene list. The algorithm walks down the entire list of genes, which is ordered by differential expression correlation. At each position, the running sum increases by a weighted amount when the gene belongs to the target set and decreases proportionally when it does not, creating a dynamic deviation profile.

The enrichment score (ES) is defined as the maximum absolute deviation of this running sum from zero. A high positive deviation indicates enrichment at the top of the ranked list, while a negative deviation indicates enrichment at the bottom. The magnitude of the increment is typically weighted by the gene's ranking metric, ensuring that genes with stronger differential expression contribute more heavily to the cumulative sum and the final enrichment signal.

CORE MECHANISM

Key Characteristics of the Running Sum Statistic

The running sum statistic is the sequential engine of Gene Set Enrichment Analysis (GSEA). It walks down a ranked list of genes, incrementing when a gene belongs to the target set and decrementing otherwise, to detect non-random clustering of the set at the extremes of the ranking.

01

Sequential Calculation

The statistic is computed by walking down a gene list L of N genes, ranked by differential expression (e.g., signal-to-noise ratio). At each position j, the running sum is updated:

  • Hit: If gene j is in the target set S, the sum increases by a weighted amount proportional to the gene's correlation with the phenotype.
  • Miss: If gene j is not in S, the sum decreases by a constant penalty. This creates a random walk-like trajectory that reflects the distribution of S within L.
02

Weighted vs. Unweighted Variants

The standard GSEA implementation uses a weighted running sum where the increment for a hit is proportional to the gene's ranking metric (e.g., absolute correlation). This gives more influence to genes at the extremes of the ranked list.

  • Weighted (p=1): Increment = |r_j|^p, where r_j is the correlation. Genes with stronger differential expression contribute more to the enrichment signal.
  • Unweighted (p=0): Increment = 1 for all hits. All members of S are treated equally, regardless of their individual effect size. The choice of weighting scheme affects sensitivity to leading-edge subsets.
03

Enrichment Score Derivation

The Enrichment Score (ES) is the maximum deviation from zero of the running sum statistic. It is calculated as:

  • Track the running sum across all N positions.
  • Identify the point where the sum reaches its peak positive or peak negative value.
  • This peak is the ES, reflecting the degree of overrepresentation at the top (positive ES) or bottom (negative ES) of the ranked list. The ES is conceptually similar to a weighted Kolmogorov-Smirnov statistic, testing whether the distribution of S differs from a uniform distribution across L.
04

Null Distribution via Permutation

To assess statistical significance, the observed ES is compared against a null distribution generated by permutation testing:

  • Phenotype permutation: Randomly shuffle sample labels, re-rank genes, and recompute the ES thousands of times. This preserves gene-gene correlations.
  • Gene set permutation: Randomly select gene sets of the same size as S from the background. This is computationally faster but assumes gene independence. The nominal p-value is the fraction of permuted ES values exceeding the observed ES. Phenotype permutation is preferred for preserving the correlation structure of expression data.
05

Leading-Edge Subset Identification

The running sum trajectory directly identifies the leading-edge subset—the core group of genes driving the enrichment signal:

  • These are the genes in S that appear before or at the point where the running sum reaches its maximum deviation.
  • The leading-edge subset represents the most biologically relevant members of the gene set, often forming a signaling cascade or protein complex.
  • This subset can be extracted for downstream analysis, such as identifying therapeutic targets or constructing diagnostic signatures.
06

Normalization Across Gene Sets

The raw ES is sensitive to gene set size and dataset correlation structure, making direct comparison across gene sets invalid. The Normalized Enrichment Score (NES) corrects for this:

  • For each gene set, the observed ES is divided by the mean of all positive (or negative) permuted ES values for sets of that size.
  • This normalization accounts for the fact that larger gene sets tend to have smaller maximum deviations.
  • NES values enable comparative ranking of enrichment results across multiple gene sets, with |NES| > 1 typically indicating significant enrichment.
RUNNING SUM STATISTIC

Frequently Asked Questions

A technical deep dive into the sequential calculation at the heart of Gene Set Enrichment Analysis, explaining how it detects non-random clustering of gene sets within ranked expression data.

The running sum statistic is a sequential, cumulative calculation used in Gene Set Enrichment Analysis (GSEA) that walks down a ranked list of genes, increasing its value when a gene belongs to the target set and decreasing it when a gene does not. This dynamic, position-dependent score is designed to detect whether members of a pre-defined gene set are non-randomly clustered at the extremes—either the top or bottom—of a ranked list ordered by differential expression. The maximum deviation of this running sum from zero is recorded as the Enrichment Score (ES), which quantifies the degree of overrepresentation at the phenotypic extremes. Unlike static overlap tests, the running sum statistic is a functional class scoring method that leverages the full continuous ranking of all genes, preserving the magnitude of differential expression rather than relying on an arbitrary significance cutoff.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.