Guided project
Module 7 · From genes to function · Self-checked
Take 30 genes that rose in low oxygen, test six pathways for enrichment, correct for multiple testing, connect the hits in a network and write the biological story with its cautions.
Research question
Thirty genes went up when cells were grown in low oxygen. Which biological processes do they point to, how sure can we be, and what story can we honestly tell?
How to approach this
This project joins Pathways and enrichment analysis and Biological networks and systems biology. Pathways and enrichment analysis asked whether a gene list overlaps a pathway more than chance would give; Biological networks and systems biology asked how genes are connected. Here you do both, in order, on one list, and then write what it means. The gene list is made up for teaching, but it is mostly modelled on genes known to rise when oxygen is short. The pathway table holds simplified pathway lists for teaching: each list contains only well-established members, and real databases hold more.
- Work in one notebook, top to bottom, so that anyone can rerun it and get your numbers. Paste the data cell below as the first cell.
- Keep the background fixed. The background is the set of genes that could have appeared in the list: here, the 10,000 genes measured in the experiment. Every p-value depends on it, so state it in your report.
- Write numbers down as you go, in a text cell under each result. Task 5 is much quicker when every figure is already recorded next to the code that produced it.
Why this order? Enrichment comes first because it is the question with a test attached: it says which pathways stand out, and how surprising that is. The network comes second because it works on a smaller, more focused set of genes and asks a different question: do the hits sit together along one route, or are they scattered? A pathway that is enriched and whose hits also form a connected chain is a much stronger lead than one that passes only the first test.
Two terms in the tasks are new. Bonferroni correction multiplies each p-value by the number of tests, here 6. The Benjamini–Hochberg method controls the false discovery rate (FDR), the expected share of false positives among the results you call significant; it is less strict than Bonferroni. The project needs pandas, scipy and networkx, all already in Colab.
import pandas as pd
import networkx as nx
from scipy.stats import hypergeom, false_discovery_control
# Simplified pathway lists for teaching (well-established members only)
pathways = {
"Glycolysis": ["HK1", "HK2", "GPI", "PFKL", "PFKM", "ALDOA", "TPI1",
"GAPDH", "PGK1", "PGAM1", "ENO1", "PKM"],
"TCA cycle": ["CS", "ACO2", "IDH3A", "OGDH", "SUCLA2", "SDHA", "SDHB",
"FH", "MDH2"],
"DNA repair": ["BRCA1", "BRCA2", "RAD51", "PALB2", "ATM", "ATR", "MRE11",
"RAD50", "NBN", "MLH1", "MSH2", "MSH6", "XRCC1", "PARP1",
"ERCC1"],
"Cell cycle": ["CDK1", "CDK2", "CDK4", "CDK6", "CCNA2", "CCNB1", "CCND1",
"CCNE1", "CDKN1A", "CDKN2A", "RB1", "E2F1", "CDC20", "PLK1",
"AURKA", "BUB1"],
"Apoptosis": ["BAX", "BAK1", "BCL2", "BCL2L1", "MCL1", "BID", "CASP3",
"CASP8", "CASP9", "APAF1", "CYCS", "XIAP"],
"Cholesterol synthesis": ["HMGCR", "HMGCS1", "MVK", "PMVK", "MVD", "FDPS",
"FDFT1", "SQLE", "LSS", "CYP51A1", "DHCR7"],
}
# Genes up in a teaching experiment: cells grown in low oxygen (made-up list)
genes_up = ["HK2", "PFKL", "ALDOA", "TPI1", "PGK1", "ENO1", "PKM", "SLC2A1",
"LDHA", "PFKFB3", "PFKFB4", "PDK1", "CA9", "VEGFA", "BNIP3",
"NDRG1", "EGLN3", "ADM", "ANKRD37", "P4HA1", "ERO1A", "KDM3A",
"ANGPTL4", "LOX", "BHLHE40", "DDIT4", "STC2", "CDKN1A", "MCL1",
"SDHA"]
N = 10_000 # background: all genes measured in the experiment
n = len(genes_up)
print(n, "genes up;", len(pathways), "pathways")The cell defines three things: pathways, a dictionary that maps each pathway name to its list of gene symbols; genes_up, the 30 genes; and N, the background size. n = len(genes_up) is the length of the list. The figure shows how the five tasks connect.
Before you start, look at the list itself. Only 10 of the 30 genes appear in any of the six pathway lists; the other 20, including CA9, VEGFA, BNIP3 and ADM, appear in none. Several of them are among the best-known genes that rise in low oxygen, yet an over-representation test cannot see them, because it only counts genes that a pathway list contains. This is the catalogue problem of Pathways and enrichment analysis in miniature: the result depends on what the gene sets include, and a gene missing from every set simply drops out of the analysis.
Count the overlaps
Pathways and enrichment analysis
- For each pathway, find which of the 30 genes are in it, and how many.
- Work out how many hits you would expect by chance: list size × pathway size ÷ background.
Hint. Python's set type does the matching: set(members) & set(genes_up) keeps the genes in both. Loop over pathways.items(), which gives each name with its list, and collect one row per pathway into a pandas table with the size, the number of hits and the expected number. The expected number for glycolysis is 30 × 12 ÷ 10,000.
Checkpoint: glycolysis has 7 hits of 12 (ALDOA, ENO1, HK2, PFKL, PGK1, PKM, TPI1) against 0.036 expected. TCA cycle (SDHA), cell cycle (CDKN1A) and apoptosis (MCL1) have 1 hit each; DNA repair and cholesterol synthesis have none.
Run the hypergeometric test
Pathways and enrichment analysis
- For each pathway, compute the chance of seeing at least that many hits if the 30 genes had been drawn at random from the background.
- Sort the pathways by p-value.
Hint. Use hypergeom.sf(k - 1, N, K, n), where k is the number of hits, K the pathway size, N the background and n the list size. The - 1 matters: sf gives the chance of more than its first argument, so k - 1 turns it into "at least k". A pathway with no hits should get p = 1.
Checkpoint: glycolysis p = 8.1 × 10−16. Three more pathways also fall below 0.05 on a single hit each: TCA cycle 0.027, apoptosis 0.035 and cell cycle 0.047.
Correct for multiple testing
Pathways and enrichment analysis
- Apply Bonferroni and Benjamini–Hochberg to the six p-values.
- List the pathways with FDR below 0.05.
Hint. Bonferroni is p * 6, capped at 1 with .clip(upper=1). For Benjamini–Hochberg, scipy has false_discovery_control(p, method="bh"), which returns the adjusted values in the same order as the input. Ask why a single gene can give p below 0.05: when only 0.03 to 0.05 hits are expected, even one hit is unusual, but one gene is a thin basis for a claim about a whole pathway.
Checkpoint: only glycolysis survives (FDR 4.8 × 10−15). The three single-hit pathways all have FDR 0.070, and Bonferroni values of 0.16 to 0.28.
Build a network of the significant genes
Biological networks and systems biology
- Use this teaching table of links between consecutive steps, or direct regulation, in glucose use: SLC2A1–HK2, HK2–GPI, GPI–PFKL, PFKFB3–PFKL, PFKFB4–PFKL, PFKL–ALDOA, ALDOA–TPI1, ALDOA–GAPDH, TPI1–GAPDH, GAPDH–PGK1, PGK1–PGAM1, PGAM1–ENO1, ENO1–PKM, PKM–LDHA.
- Keep only the genes in your list, count nodes, links and pieces; then put the missing genes back and count again.
Hint. Build the full network with nx.Graph(links), then G.subgraph([g for g in G if g in genes_up]) keeps the hits. nx.number_connected_components counts pieces. The network brings in list genes that are not in the glycolysis table at all: the glucose transporter SLC2A1, lactate dehydrogenase LDHA, and PFKFB3 and PFKFB4, which make and break down a small molecule that controls PFKL's enzyme.
Checkpoint: the hits alone form 11 genes, 7 links and 4 pieces; PGK1 is left on its own. Adding GPI, GAPDH and PGAM1, which were measured but not in the list, joins all 14 genes into 1 piece running from SLC2A1 to LDHA. PFKL has the highest degree, 4.
Tell the biological story, with its cautions
Pathways and enrichment analysis, Biological networks and systems biology and Why multi-omics, and how layers are integrated
- Write a short paragraph answering the research question, with the numbers.
- List at least three cautions.
Hint. Start with the finding and its size: how many genes, against how many expected, with what FDR. Then say what the network adds: the hits sit along one route, from glucose entering the cell to lactate leaving it. Link it to known biology: cells short of oxygen rely more on glycolysis for energy. For the cautions, think about the made-up list, the simplified pathway lists, the choice of background, the single-gene pathways, and what enrichment can and cannot show. Why multi-omics, and how layers are integrated suggests what a second layer could add.
Checkpoint: your story names glycolysis with 7 of 12 genes (FDR about 5 × 10−15), explains why the network has gaps, says the three single-gene pathways did not survive correction, and proposes a test in another layer, such as measuring lactate.
Three pitfalls catch most first reports. The first is to over-claim the direction of biology: the data show that RNA for glycolysis genes rose, not that glycolysis itself ran faster. As Why multi-omics, and how layers are integrated showed, RNA, protein and activity can disagree, so "glycolysis genes were induced" is accurate and "glycolysis was activated" needs another layer, such as lactate in the medium, to support it.
The second is to read a tiny p-value as many independent pieces of evidence. The hypergeometric test treats each gene as a separate draw, but the seven glycolysis genes are not independent: as the Go deeper box below explains, much of the cluster rises together because one regulator switches it on. The enrichment is real, but it is closer to one strong observation than to seven.
The third is to forget the made-up parts. The list, the pathway tables and the link table were all simplified for teaching. In your cautions, say which conclusions depend on those choices, and which you would expect to hold with real databases and a real experiment.
Go deeper: one switch behind the whole cluster
Why do so many glycolysis genes rise together in low oxygen? Much of the answer is one transcription factor, HIF-1. In normal oxygen, its HIF-1α subunit is made all the time but destroyed within minutes. Enzymes called prolyl hydroxylases use oxygen to tag it, the VHL protein recognises the tag, and the cell's proteasome breaks it down.
When oxygen is short, the tagging stops. HIF-1α builds up, pairs with HIF-1β, and binds short DNA sites called hypoxia response elements near its target genes. Those targets include the glucose transporter SLC2A1, most glycolytic enzymes, and LDHA. This work earned the 2019 Nobel Prize in Physiology or Medicine. For your report, this suggests a sharper next question than "which pathway?": "which regulator?". Enrichment of a regulator's known targets, or measuring HIF-1α protein, would test it.
Take it further
Paste the 30 genes into STRING, choose Homo sapiens, and compare its network and enrichment tables with yours. Then try a real pathway database, such as Reactome's analysis tool, with the full background.
Expect differences. Real pathway lists are larger and overlap each other, so more pathways will be tested and the correction will be stronger. STRING's links come from many kinds of evidence, not only consecutive steps, so the hypoxia genes that were isolated here may join the network. Seeing where the answers agree and where they differ teaches you how much each result depends on the lists and settings you chose.
Look back at what this module has done. You found genes on a genome, read their proteins as domains and folds, grouped them into pathways and networks, joined several layers, modelled a system over time and sorted a mixed community of microbes. Every step relied on methods whose rules were written down by people: reading frames, profile models, hypergeometric tests, rate equations. Module 8, AI for biology, asks what changes when the rules are learned from data instead. It starts with the same kinds of input you have handled here, sequences, expression tables and structures, and asks where machine learning helps, where traditional methods are still better, and how to tell the difference honestly.
Further reading · Module 7Reactome: pathway browser and analysis tool. · KEGG PATHWAY: reference maps, including glycolysis. · STRING: networks and enrichment for a gene list. · All reading for this course
Up next
Lesson 1
Where AI fits: traditional methods and AI methods side by side