Tutorials › High-Dimensional Genomic Data Analysis › Defining Gene Sets and the Tested-Gene Universe

Gene Set and Pathway Enrichment · Tutorial 456 of 795

Defining Gene Sets and the Tested-Gene Universe

Learn to align gene-set membership and the enrichment background with the genes your assay could measure and your analysis actually tested.

Intermediate 11 min read

What You'll Learn

  • Distinguish an annotated gene set from the part of that set eligible for analysis.
  • Define the tested-gene universe from assay coverage, gene mapping, quality control, and the differential-expression procedure.
  • Handle pathway annotations, identifier conversion, and duplicate mappings consistently.
  • Explain why all genes in the genome or all detected genes may be an inappropriate background.
  • Diagnose how filtering changes pathway counts without mistaking untested genes for non-significant genes.
  • Check the inputs to over-representation analysis before calculating enrichment.

Why the Background Must Match the Analysis

A pathway enrichment analysis compares a selected collection of genes with genes assigned to a biological set. That comparison is only interpretable if the background represents genes that had a legitimate opportunity to be selected. In an RNA-seq experiment, a gene absent from the assay or excluded before differential-expression testing could not appear in the selected list. Counting it as an unselected background gene changes the reference set for reasons unrelated to the biological question.

The two inputs therefore need to be defined before enrichment is calculated: what counts as membership in the gene set? and which genes were eligible to be selected? These are data and analysis decisions, not merely labels attached to a pathway database. The earlier material on independent filtering is relevant here: genes removed from testing by a filter should not be treated as tested genes with non-significant results.

Definition: Let \(U\) be the tested-gene universe: the set of genes that were eligible for, and included in, the differential-expression testing procedure used to create the selected list. Let \(S\) be an annotated gene set, such as the genes assigned to a pathway. For analysis against \(U\), the eligible membership of that set is \(S \cap U\). Let \(D\) be the selected gene set, such as genes meeting a stated differential-expression criterion; it should satisfy \(D \subseteq U\).

The intersection \(S \cap U\) is sometimes called the pathway genes in the background, or the effective pathway set for that analysis. A gene can be annotated to a pathway but not be eligible for the current analysis. Conversely, a gene can be in \(U\) without belonging to that pathway. The count of selected pathway genes is \(|D \cap S|\). Since \(D \subseteq U\), this is also \(|D \cap (S \cap U)|\): only genes both selected and eligible pathway members contribute.

Defining Membership and Eligibility

A gene-set definition needs a clear biological label and a reproducible membership rule. Record the source of the annotation, its release or retrieval date, the pathway or set identifier, and the identifier type used to represent genes. For example, a set might be defined as all unique Ensembl gene identifiers assigned to one specified pathway in a specified annotation release. A broad label such as “immune genes” is not sufficient unless the source and rule that determine membership are also given.

Identifiers require particular care. A pathway may use Entrez identifiers while an expression matrix uses Ensembl identifiers or gene symbols. Convert identifiers using a documented mapping and apply a consistent rule for unmapped or ambiguous entries. Gene symbols can change, and a single symbol may map to multiple records. If several probes or transcripts map to one gene, decide whether the analysis is at probe, transcript, or gene level, then use that same unit in the differential-expression results, pathway membership, and universe. Counting the same gene more than once can distort both membership and overlap.

The universe is analysis-specific. Begin with genes represented by the assay, then account for the mapping and quality-control steps, and finally identify the genes included in the tests that produced \(D\). In a gene-level RNA-seq analysis, the universe is typically the genes with usable counts that were actually tested after the stated filters. In a targeted panel, it is limited by panel coverage. In a microarray study, it is limited by the probes and the rules used to map probes to genes. A genome-wide annotation does not make every annotated gene eligible.

“Measured” and “tested” are related but not identical. A gene may have a recorded value yet be excluded from testing because it fails a pre-specified expression or quality filter. If the differential-expression procedure reports that gene as untested, it does not belong to \(U\). A gene that was tested and did not meet the selection threshold does belong to \(U\); it is an unselected gene, not an unmeasured one. Keep these categories distinct in the analysis records.

Worked Example: A Targeted RNA-seq Panel

Suppose a hypothetical targeted panel is designed to measure 1,200 genes. After mapping panel targets to unique gene identifiers and applying the pre-specified quality and expression filters, 1,050 genes are included in the differential-expression tests. The selected list \(D\) contains 70 of those genes. An annotation release assigns 80 genes to pathway \(S\), of which 52 are in the tested universe.

The tested-gene universe is \(U\), containing 1,050 genes—not all genes in the genome and not all 1,200 panel targets. The effective pathway set is \(S \cap U\), containing 52 genes. The remaining \(80 - 52 = 28\) annotated pathway genes are outside this analysis because they were not tested.

If 14 of the 70 selected genes are in the effective pathway set, then \(|D \cap S| = 14\). Because \(D \subseteq U\), those 14 are also in \(D \cap (S \cap U)\). The 28 pathway genes outside \(U\) cannot be counted as unselected genes in the analysis: they were not eligible to appear in \(D\).

A Justification for Intersecting the Sets

Restricting pathway membership to \(U\) is not an arbitrary adjustment. It follows from the definition of the selected list. If \(D \subseteq U\), then every gene in \(D \cap S\) is necessarily in \(U\) as well. Thus \(D \cap S\) and \(D \cap (S \cap U)\) contain exactly the same genes:

$$ D \subseteq U \quad\Longrightarrow\quad D \cap S = D \cap (S \cap U). $$

The restriction changes the pathway’s eligible membership count from \(|S|\) to \(|S \cap U|\), and it changes the background from all annotated genes to the genes actually tested. The later calculation of enrichment uses these aligned inputs. This set identity does not, by itself, establish that an enrichment result is statistically significant; it establishes which genes are eligible to contribute to that calculation.

Worked Example: A Microarray with Incomplete Coverage

Consider a hypothetical microarray analysis. After probe quality control, 9,000 probes remain. Mapping and collapsing probes according to a documented gene-level rule gives 7,600 unique genes. A further analysis filter leaves 7,000 genes in the differential-expression tests, so \(U\) contains 7,000 genes. The chosen pathway annotation contains 100 unique genes; 44 of them are in \(U\). The selected differential-expression list contains 350 genes, with 18 in that eligible pathway set.

The pathway membership relevant to this analysis is \(S \cap U\), of size 44, not the 100 genes in the annotation alone. The overlap is \(|D \cap S| = 18\), equivalently \(|D \cap (S \cap U)| = 18\). The 56 annotated genes outside \(U\) were not among the genes tested. The 9,000 probes are also not the right universe for a gene-level analysis: the analysis unit is a unique gene after probe mapping, and only 7,000 genes were tested.

The numbers illustrate two distinct restrictions: converting assay features into the chosen analysis unit, and restricting that unit to genes actually tested. Skipping either restriction can count duplicate probes or ineligible genes as if they were separate opportunities for selection.

Filtering and the Meaning of “Untested”

The universe should correspond to the exact differential-expression results from which \(D\) was formed. If a filter removes genes before testing, the removed genes are outside \(U\). If a gene remains in the tests but has a p-value above the chosen cutoff, it remains inside \(U\), even though it is not in \(D\). This distinction matters whether selection is based on an adjusted p-value threshold, an effect-size threshold, or a combination: the selection rule defines \(D\), while the set of genes tested defines \(U\).

Keep filtering rules and selection rules separate in the analysis description. For example, a minimum-count rule might determine which genes are tested, while an adjusted p-value cutoff determines which tested genes are selected. The first changes \(U\); the second changes \(D\). When using a differential-expression result table, check whether it records filtered or untested genes, and do not infer that every omitted gene received a non-significant test result.

Worked Example: Filtering Changes the Eligible Set

In a hypothetical study, 5,000 genes have usable assay measurements. A pre-specified low-expression filter excludes 800 before differential-expression testing, leaving \(|U| = 4,200\). Of those tested genes, 210 meet the stated selection rule, so \(|D| = 210\). A pathway annotation contains 120 genes; 30 are among the 800 excluded genes, leaving \(|S \cap U| = 120 - 30 = 90\). Twelve of those 90 are selected.

The correct analysis inputs are a universe of 4,200 tested genes, an eligible pathway set of 90 genes, and a selected list of 210 genes with an overlap of 12. The 800 filtered genes cannot be placed in the unselected part of the tested universe, because the procedure did not test them. If, in a different analysis, all 5,000 genes were tested, the universe would instead contain all 5,000, and the pathway’s eligible membership would have to be reconsidered accordingly.

This example also shows why the same pathway annotation can yield different eligible membership counts in different analyses. The annotation has not necessarily changed; the assay processing and testing universe have.

Checks, Alternatives, and Limitations

Before interpreting an enrichment result, verify that the selected list is a subset of the stated universe, that each gene is counted once at the chosen analysis level, and that the pathway membership is intersected with that universe. Also check that the annotation and identifier mapping are recorded well enough for another analyst to reconstruct the sets.

A useful alternative is to analyze a ranked list rather than first defining a selected list and a tested-gene universe for over-representation. Ranked-list methods use information across genes in a ranking, but they still require genes that can be matched to the assay and annotation. They do not justify including genes that could not be measured. For the over-representation approach, defining \(D\) and \(U\) explicitly is essential because the comparison is based on selected versus eligible genes.

No single background is correct for every study. Using all genes in an organism is usually inappropriate when the assay covered only a subset. Using all genes detected at any level can also be inappropriate if some detected genes were excluded from the actual tests. Even a carefully matched universe cannot fix poor annotation, ambiguous mappings, or biological and technical biases in which genes are more likely to be selected. Report the choices and interpret enrichment as a result conditional on the assay, filters, tests, and annotation used—not as evidence that the pathway caused the observed expression changes.

Common pitfall: “The pathway database lists 100 genes, so all 100 belong in the background comparison; the 70 genes that were not selected are negative results.” This is incorrect if some annotated genes were not covered or tested. First define \(U\) from the genes included in the tests, then use \(S \cap U\) as eligible pathway membership. Only tested genes outside \(D\) are unselected genes for that analysis.
Key takeaway: Define the analysis unit, map pathway membership to that unit, and let the tested genes—not the whole genome or every database entry—determine the universe. The selected list must be formed from that same universe.

Check Your Understanding

Answer each question by identifying the relevant sets and explaining which genes are eligible.

  1. An assay covers 2,000 genes, but 1,700 are included in differential-expression tests. A pathway lists 60 genes, 45 of which are tested. What is the tested universe size and the eligible pathway membership size?
  2. A gene was tested but did not meet the selection threshold. Does it belong in the universe? Why?
  3. Expression features are probes, but the pathway annotation and differential-expression list are at gene level. What must be resolved before defining pathway overlap?
  4. Why is it incorrect to treat filtered-out genes as tested, unselected genes?

Solutions. (1) The universe has 1,700 genes, and the eligible pathway set has 45 genes, the intersection of the annotated set with that universe. (2) Yes. The universe is defined by inclusion in testing, not by whether a gene was selected; a tested gene that misses the threshold remains an unselected member of \(U\). (3) The probe-to-gene mapping and duplicate-handling rule must be specified so that the assay results, selected list, universe, and pathway membership all use the same gene-level unit, with each gene counted consistently. (4) A filtered-out gene was not included in the tests that produced the selected list, so it had no opportunity to be selected under that procedure; it is outside \(U\), not an unselected tested gene.

Clinical Biostats