The Immune System
Learn how the innate and adaptive immune systems detect and eliminate pathogens — from pattern recognition and complement to B/T cell development, immune memory, and vaccination.
Introduction
Every multicellular organism lives under constant threat of infection. Bacteria, viruses, fungi, and parasites seek to exploit the rich resources within animal cells, and over hundreds of millions of years of co-evolution, animals have assembled a sophisticated multi-layered defense system — the immune system. In vertebrates, immunity is organized into two cooperating arms. The innate immune system provides immediate, broad-spectrum defense using receptors that recognize conserved features shared by whole classes of pathogens. The adaptive immune system mounts highly specific responses against individual pathogens, using lymphocytes (B cells and T cells) that carry an enormous diversity of antigen receptors generated by somatic gene rearrangement. Critically, the adaptive system remembers prior encounters, enabling faster and more powerful responses upon re-exposure — the principle that makes vaccination possible.
This lesson covers the mechanisms of innate immunity (epithelial barriers, pattern recognition receptors, complement, natural killer cells, and dendritic cells), the organization of the adaptive immune system (B and T cell development, immune memory, and lymphocyte recirculation), and the immune system in disease (autoimmunity, immunodeficiency, allergy, transplantation, and vaccination). We also explore the bioinformatics tools used to analyze immune repertoires, deconvolve immune cell composition from expression data, and design vaccines.
24.1 — Innate Immunity
Epithelial Surfaces and Antimicrobial Peptides
The first line of defense is not cellular but physical. Epithelial barriers — skin, the respiratory tract lining, the gastrointestinal mucosa, and the urogenital epithelium — form continuous sheets that block pathogen entry. These barriers are reinforced by chemical defenses: the stomach produces hydrochloric acid (pH ~2), the airways secrete mucus that traps microbes, and tears and saliva contain the enzyme lysozyme, which degrades bacterial cell walls.
Antimicrobial peptides (AMPs) are a critical component of epithelial defense. These small cationic peptides — including defensins (α-defensins and β-defensins), cathelicidins, and histatins — are produced by epithelial cells and neutrophils. They kill bacteria by inserting into and disrupting microbial membranes, which are enriched in negatively charged phospholipids. AMPs also have immunomodulatory functions, recruiting immune cells and promoting wound healing. In the gut, Paneth cells at the base of intestinal crypts secrete α-defensins that help shape the commensal microbiome and prevent pathogenic colonization.
Pattern Recognition Receptors Detect Conserved Features of Pathogens
The innate immune system detects infection through pattern recognition receptors (PRRs) — germline-encoded receptors that recognize pathogen-associated molecular patterns (PAMPs), conserved molecular structures shared by broad classes of microbes but absent from host cells. PAMPs include bacterial lipopolysaccharide (LPS), peptidoglycan, flagellin, unmethylated CpG DNA, and viral double-stranded RNA. PRRs also detect damage-associated molecular patterns (DAMPs) — molecules released by stressed or dying host cells, such as ATP, HMGB1, and uric acid.
The key classes of PRRs include:
| PRR family | Location | Example ligands |
|---|---|---|
| Toll-like receptors (TLRs) | Cell surface and endosomes | LPS (TLR4), flagellin (TLR5), dsRNA (TLR3), ssRNA (TLR7/8), CpG DNA (TLR9) |
| NOD-like receptors (NLRs) | Cytoplasm | Peptidoglycan (NOD1/2), bacterial toxins, crystals (NLRP3) |
| RIG-I-like receptors (RLRs) | Cytoplasm | Viral dsRNA and 5′-triphosphate RNA |
| C-type lectin receptors (CLRs) | Cell surface | Fungal β-glucans (Dectin-1), mannose (mannose receptor) |
| cGAS-STING | Cytoplasm | Cytoplasmic dsDNA (viral or bacterial) |
Toll-like Receptors (TLRs)
Toll-like receptors are the best-characterized family of PRRs. Humans have 10 TLRs (TLR1–TLR10), each recognizing a distinct set of microbial ligands. TLRs on the cell surface (TLR1, 2, 4, 5, 6) detect extracellular microbial components such as lipoproteins, LPS, and flagellin. Endosomal TLRs (TLR3, 7, 8, 9) detect nucleic acids from internalized pathogens — an arrangement that prevents inappropriate activation by self nucleic acids in the extracellular space.
Upon ligand binding, TLRs recruit adaptor proteins (principally MyD88 and TRIF) that activate downstream signaling cascades, leading to activation of the transcription factors NF-κB, IRF3, and AP-1. These drive expression of pro-inflammatory cytokines (TNF-α, IL-1β, IL-6), chemokines that recruit immune cells, and type I interferons (IFN-α/β) that establish an antiviral state in neighboring cells.
Inflammasomes and Inflammatory Caspases
Inflammasomes are multiprotein complexes assembled in the cytoplasm in response to infection or cellular stress. The best-studied is the NLRP3 inflammasome, which is activated by a remarkably diverse range of stimuli, including bacterial toxins, ATP, uric acid crystals, and silica particles. Activation requires two signals: a priming signal (typically TLR activation, which upregulates NLRP3 and pro-IL-1β expression) and an activation signal (which triggers NLRP3 oligomerization).
Upon assembly, the inflammasome activates inflammatory caspases — primarily caspase-1 — which cleave the precursors of the cytokines IL-1β and IL-18 into their active, secreted forms. Caspase-1 also cleaves gasdermin D, whose N-terminal fragment forms pores in the plasma membrane, leading to an inflammatory form of cell death called pyroptosis. Pyroptosis releases intracellular contents (including DAMPs) that amplify the inflammatory response, alerting neighboring cells and recruiting more immune cells. Additional inflammatory caspases (caspase-4, -5, and -11) directly sense cytoplasmic LPS from gram-negative bacteria, providing a TLR-independent detection mechanism.
The Complement System
The complement system is a cascade of more than 30 blood proteins that enhances the ability of antibodies and phagocytes to clear pathogens. Complement can be activated through three pathways:
| Pathway | Trigger | Key components |
|---|---|---|
| Classical | Antibody-antigen complexes | C1q, C1r, C1s |
| Lectin | Mannose on microbial surfaces | MBL (mannose-binding lectin), MASPs |
| Alternative | Spontaneous C3 hydrolysis on microbial surfaces | Factor B, Factor D, properdin |
All three pathways converge on C3 convertase, which cleaves C3 into C3a (a small anaphylatoxin that promotes inflammation) and C3b (which covalently attaches to the pathogen surface). C3b has three major effects: (1) it acts as an opsonin, marking pathogens for phagocytosis by cells bearing complement receptors; (2) together with additional complement components, it forms the C5 convertase, generating C5a (a potent chemoattractant) and C5b; and (3) C5b initiates assembly of the membrane attack complex (MAC) (C5b–C9), which forms a pore in the pathogen membrane, leading to osmotic lysis. Host cells are protected from complement-mediated damage by regulatory proteins such as CD46, CD55, and CD59, which inactivate complement components deposited on self surfaces.
Natural Killer (NK) Cells
Natural killer (NK) cells are innate lymphocytes that kill virus-infected cells and tumor cells without prior sensitization. NK cell activity is governed by the balance between activating receptors (which recognize stress-induced ligands on abnormal cells) and inhibitory receptors (which recognize MHC class I molecules on healthy cells). Because many viruses and tumors downregulate MHC class I to escape T cell recognition, the loss of MHC I removes the inhibitory signal and activates the NK cell — a principle called “missing self” recognition.
Activated NK cells kill targets by releasing cytotoxic granules containing perforin (which forms pores in the target membrane) and granzymes (serine proteases that enter through the pores and trigger apoptosis). NK cells also produce large quantities of IFN-γ, which activates macrophages and shapes the subsequent adaptive immune response.
Dendritic Cells: The Link Between Innate and Adaptive Immunity
Dendritic cells (DCs) are the principal antigen-presenting cells and serve as the critical bridge between innate and adaptive immunity. Immature DCs reside in peripheral tissues (skin, mucosal surfaces), where they continuously sample the environment by phagocytosis and macropinocytosis. Upon encountering a pathogen and receiving PRR signals, DCs undergo maturation: they upregulate MHC class II molecules loaded with pathogen-derived peptides, upregulate costimulatory molecules (CD80, CD86) required for T cell activation, and migrate via lymphatic vessels to draining lymph nodes, where they present antigen to naïve T cells. Without DC-mediated antigen presentation, adaptive immune responses cannot be initiated. The type of PRR signals received by a DC during maturation influences which cytokines it produces, thereby directing the differentiation of CD4⁺ helper T cells into appropriate effector subsets (Th1, Th2, Th17).
Innate Lymphoid Cells (ILCs)
Innate lymphoid cells (ILCs) are a family of innate immune cells that mirror the functional diversity of T helper cell subsets but lack antigen-specific receptors. They reside in tissues (especially mucosal surfaces) and respond rapidly to cytokine signals from epithelial cells and DCs:
| ILC group | Functional analog | Key cytokines produced | Main function |
|---|---|---|---|
| ILC1 | Th1 | IFN-γ | Defense against intracellular pathogens |
| ILC2 | Th2 | IL-4, IL-5, IL-13 | Anti-helminth defense; tissue repair; allergy |
| ILC3 | Th17 | IL-17, IL-22 | Mucosal barrier defense against extracellular bacteria and fungi |
| NK cells | CD8⁺ T cells | IFN-γ, perforin | Killing of infected and tumor cells |
ILCs are critical for maintaining tissue homeostasis and providing early defense before the adaptive immune system is engaged.
Bioinformatics: Innate Immunity Analysis
Computational approaches have become essential for studying innate immunity. PRR ligand databases catalog known ligand-receptor interactions, while tools such as the Antimicrobial Peptide Database (APD) and DBAASP (Database of Antimicrobial Activity and Structure of Peptides) enable prediction of antimicrobial activity from peptide sequences using machine learning models trained on experimentally validated AMPs.
Complement pathway simulation uses systems biology models (ordinary differential equations) to predict how genetic variants or therapeutic complement inhibitors alter the cascade. Innate immune cell deconvolution methods estimate the proportions of macrophages, DCs, NK cells, and other innate populations in bulk RNA-seq data using reference gene expression signatures. Inflammation gene signature analysis identifies coordinated upregulation of NF-κB targets, inflammasome components, and cytokine genes, providing a molecular readout of innate immune activation in disease.
Let’s examine the N-terminal sequences of two key antimicrobial peptides to compare their structural features:
let healthy_repertoire = '[15, 12, 10, 8, 7, 6, 5, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1]'
let leukemia_repertoire = '[80, 5, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]'
print("Healthy T cell repertoire diversity:")
print("Shannon index: " + Stats.shannon(healthy_repertoire))
print("Leukemia patient repertoire:")
print("Shannon index: " + Stats.shannon(leukemia_repertoire))
A healthy immune repertoire has high Shannon diversity, reflecting many clonotypes at similar frequencies. In leukemia, a single malignant clone dominates, drastically reducing diversity.
24.2 — Overview of the Adaptive Immune System
B Cells and T Cells Are the Main Effectors of Adaptive Immunity
The adaptive immune system relies on two classes of lymphocytes: B cells and T cells. Both carry antigen receptors of extraordinary diversity, generated by somatic gene rearrangement during development. Each individual lymphocyte expresses a unique receptor with a single specificity, and the total population of lymphocytes (∼1012 in a human) collectively covers an enormous range of potential antigens.
B cells produce antibodies (immunoglobulins) — secreted or membrane-bound proteins that bind specific antigens with high affinity. Upon activation, B cells differentiate into antibody-secreting plasma cells. Antibodies neutralize pathogens, opsonize them for phagocytosis, and activate complement.
T cells recognize peptide fragments displayed on cell surfaces by MHC molecules (major histocompatibility complex). CD8⁺ cytotoxic T cells kill infected or cancerous cells displaying foreign peptides on MHC class I. CD4⁺ helper T cells recognize peptides on MHC class II and orchestrate immune responses by secreting cytokines that activate B cells, macrophages, and other effector cells.
B Cells Develop in the Bone Marrow and T Cells Develop in the Thymus
B and T cells develop from common lymphoid progenitors in the bone marrow, but their maturation occurs in different primary lymphoid organs.
B cells complete their development in the bone marrow itself. During development, immunoglobulin genes undergo V(D)J recombination — the random assembly of variable (V), diversity (D), and joining (J) gene segments by the recombinase enzymes RAG1 and RAG2 — to generate a unique B cell receptor (BCR). B cells whose receptors bind strongly to self-antigens in the bone marrow are eliminated by apoptosis or functionally silenced (central tolerance), ensuring that the B cell repertoire is largely purged of self-reactive specificities before cells enter the periphery.
T cells migrate from the bone marrow to the thymus, where they undergo maturation and selection. T cell receptor (TCR) genes are rearranged by V(D)J recombination, similar to immunoglobulin genes. Thymocytes then undergo two rounds of selection:
- Positive selection (in the thymic cortex): T cells that can recognize self-MHC molecules with moderate affinity survive; those that cannot are eliminated. This ensures MHC restriction — T cells only recognize antigens presented by the body’s own MHC molecules.
- Negative selection (in the thymic medulla): T cells that react too strongly to self-peptides presented on self-MHC are eliminated by apoptosis, establishing central tolerance and preventing autoimmunity. The transcription factor AIRE (autoimmune regulator) drives expression of tissue-specific antigens in the thymic medulla, enabling elimination of T cells reactive to antigens from organs throughout the body.
Only about 2–5% of thymocytes survive both rounds of selection and exit the thymus as mature, self-tolerant T cells.
Let’s compare two T cell receptor variable region sequences to see the diversity generated by V(D)J recombination:
let vgene1 = "ATGGACTGGACCTGGAGGGTCTTCTGC"
let vgene2 = "ATGGACTGGACCTGGAGGTTCTTCTGC"
let vgene3 = "ATGGACTGGATCTGGAGGGTCTTCTGC"
let msa = Seq.msa(vgene1, vgene2, vgene3)
print("Antibody V-gene family alignment:")
print(msa)
Multiple sequence alignment of V-gene family members reveals highly conserved framework regions interspersed with variable positions that contribute to antigen-binding diversity.
let blood = '[{"label": "Neutrophils", "value": 60}, {"label": "Lymphocytes", "value": 30}, {"label": "Monocytes", "value": 6}, {"label": "Eosinophils", "value": 3}, {"label": "Basophils", "value": 1}]'
let chart = Viz.bar(blood, '{"title": "White Blood Cell Proportions (%)", "color": "#3B82F6"}')
print(chart)
Neutrophils are the most abundant white blood cells in circulation, forming the first wave of cellular defense during acute bacterial infection.
Immunological Memory Enables a Rapid Secondary Response
A defining feature of adaptive immunity is immunological memory. After the primary immune response clears an infection, most effector lymphocytes die, but a population of long-lived memory cells (memory B cells and memory T cells) persists for years or even a lifetime. Upon re-exposure to the same pathogen, memory cells mount a secondary response that is faster (days instead of weeks), stronger (higher antibody titers, more effector cells), and of higher quality (antibodies have greater affinity due to somatic hypermutation during the primary response).
The difference between primary and secondary responses is dramatic:
| Feature | Primary response | Secondary response |
|---|---|---|
| Lag period | 7–14 days | 1–3 days |
| Peak antibody titer | Lower | 10–100× higher |
| Predominant antibody class | IgM → IgG | IgG (already class-switched) |
| Antibody affinity | Lower | Higher (affinity-matured) |
| Duration | Shorter | Longer-lasting |
This is the immunological basis of vaccination: exposure to a harmless form of the pathogen (inactivated virus, attenuated virus, protein subunit, or mRNA encoding a viral antigen) generates memory without disease, so that upon actual infection, the immune system responds swiftly and effectively.
Lymphocytes Continuously Recirculate Through Peripheral Lymphoid Organs
Naïve lymphocytes do not simply wait passively for pathogens to find them. Instead, they continuously recirculate through the blood, lymph, and peripheral lymphoid organs — the lymph nodes, spleen, and mucosal-associated lymphoid tissues (MALT, including Peyer’s patches in the gut and tonsils). Lymph nodes are strategically positioned along lymphatic vessels, filtering lymph fluid for antigens. Naïve T cells enter lymph nodes through specialized blood vessels called high endothelial venules (HEVs), survey dendritic cells displaying antigens, and exit through efferent lymphatic vessels if no cognate antigen is found. A naïve T cell can visit hundreds of lymph nodes per day.
This constant recirculation dramatically increases the probability that a rare antigen-specific lymphocyte (estimated at only 1 in 105–106 naïve T cells for any given peptide-MHC complex) will encounter its cognate antigen presented by a dendritic cell in a lymph node. The spleen serves a similar surveillance function for blood-borne antigens.
Bioinformatics: Immune Repertoire Analysis
The advent of adaptive immune receptor repertoire sequencing (AIRR-seq) has transformed our ability to characterize the diversity of B cell receptors (BCRs) and T cell receptors (TCRs). High-throughput sequencing of the rearranged variable regions reveals the clonotype composition of an individual’s immune repertoire.
V(D)J recombination analysis and clonotype identification: Tools such as MiXCR, IgBLAST, and the IMGT (ImMunoGeneTics) database align sequencing reads to germline V, D, and J gene segment reference sequences, identifying which segments were used and characterizing the junctional diversity at the V-D and D-J boundaries. Each unique V(D)J rearrangement with its specific junctional sequence (particularly the CDR3 region) defines a clonotype.
Repertoire diversity metrics quantify the composition of the immune repertoire:
| Metric | Definition | Interpretation |
|---|---|---|
| Richness | Number of unique clonotypes | Higher in healthy, diverse repertoires |
| Shannon entropy | H = −Σpi log(pi) | Higher values indicate more even distribution |
| Clonality | 1 − (H / log(N)) | Higher during immune responses (dominant clones expand) |
| Gini coefficient | Measure of inequality in clone sizes | 0 = perfectly even, 1 = maximally uneven |
Convergent recombination and public clonotype detection: Some TCR or BCR sequences are found recurrently across unrelated individuals — these are called public clonotypes. Convergent recombination occurs when the same amino acid sequence can be encoded by multiple distinct nucleotide sequences, increasing the probability that independent rearrangement events produce the same receptor. Public clonotypes are often specific for common pathogens (CMV, EBV, influenza) and can serve as biomarkers of immune exposure.
Repertoire overlap and similarity measures compare immune repertoires between individuals, time points, or tissues. Metrics such as the Morisita-Horn index and Jaccard similarity quantify the degree of overlap, revealing shared immune responses and tracking repertoire changes during infection, vaccination, or immunotherapy.
24.5 — The Immune System in Health and Disease
Immune Tolerance and Autoimmunity
The immune system must distinguish self from non-self with high fidelity. Immune tolerance is maintained by multiple mechanisms: central tolerance (deletion of self-reactive lymphocytes in the thymus and bone marrow) and peripheral tolerance (suppression of self-reactive cells that escape central deletion, mediated by regulatory T cells (Tregs), anergy, and peripheral deletion).
When tolerance fails, the immune system attacks the body’s own tissues — autoimmunity. Autoimmune diseases affect approximately 5–8% of the population and include type 1 diabetes (T cells destroy insulin-producing β cells), rheumatoid arthritis (inflammation of joint synovium), multiple sclerosis (demyelination of nerve fibers), and systemic lupus erythematosus (antibodies against nuclear antigens). Autoimmunity often involves a combination of genetic susceptibility (particularly specific HLA alleles) and environmental triggers (infections, molecular mimicry).
Immunodeficiency Diseases
Immunodeficiency results from defects in one or more components of the immune system, leading to increased susceptibility to infection. Primary immunodeficiencies are genetic: severe combined immunodeficiency (SCID) involves defects in lymphocyte development (e.g., mutations in IL-2 receptor γ-chain or RAG genes), resulting in absence of both B and T cells. Chronic granulomatous disease (CGD) results from defects in the NADPH oxidase complex, impairing the ability of phagocytes to generate the reactive oxygen species needed to kill ingested microbes.
Secondary (acquired) immunodeficiencies are more common and include HIV/AIDS (the virus destroys CD4⁺ T cells, progressively crippling the adaptive immune system), immunosuppressive therapy (for transplant recipients or autoimmune patients), and malnutrition.
Allergy and Hypersensitivity
Allergy (type I hypersensitivity) is an inappropriate IgE-mediated immune response to normally harmless environmental antigens (allergens) such as pollen, dust mites, and food proteins. Upon initial sensitization, B cells produce allergen-specific IgE, which binds to FcεRI receptors on mast cells and basophils. Re-exposure causes allergen crosslinking of bound IgE, triggering rapid degranulation and release of histamine, prostaglandins, and leukotrienes — producing the symptoms of allergy (vasodilation, edema, bronchoconstriction, mucus secretion). In severe cases, systemic IgE-mediated activation leads to anaphylaxis, a life-threatening condition.
Transplantation Immunology
Transplant rejection occurs because the recipient’s T cells recognize foreign MHC molecules on the donor tissue. Because MHC genes (HLA in humans) are the most polymorphic genes in the genome, unrelated individuals almost always differ at multiple HLA loci. Successful transplantation requires HLA matching between donor and recipient, combined with lifelong immunosuppressive therapy (calcineurin inhibitors such as cyclosporine and tacrolimus, which block T cell activation). Bone marrow transplantation presents the additional risk of graft-versus-host disease (GVHD), in which donor T cells attack recipient tissues.
Immunological Basis of Vaccination
Vaccination exploits immunological memory to provide protective immunity without disease. Vaccine types include:
| Vaccine type | Examples | Mechanism |
|---|---|---|
| Live attenuated | Measles, mumps, rubella (MMR); oral polio | Weakened pathogen replicates, generating strong immune response |
| Inactivated | Influenza (some), hepatitis A | Killed pathogen; cannot replicate; may need boosters |
| Subunit/recombinant | Hepatitis B (HBsAg), HPV | Purified protein antigen; requires adjuvant |
| Toxoid | Tetanus, diphtheria | Inactivated toxin |
| mRNA | COVID-19 (Pfizer, Moderna) | mRNA encoding viral antigen; translated in host cells |
| Viral vector | COVID-19 (AstraZeneca, J&J) | Harmless virus delivers antigen gene |
Adjuvants — substances co-administered with the antigen — enhance vaccine immunogenicity by activating innate immune pathways (particularly PRRs on DCs), ensuring robust costimulation and effective T cell help. Common adjuvants include aluminum salts and the TLR4 agonist monophosphoryl lipid A (MPL).
Bioinformatics: Immune System Data Integration
Computational methods now enable comprehensive profiling of the immune system from high-throughput data.
Immune cell type deconvolution: Algorithms such as CIBERSORTx, xCell, and MCP-counter estimate the proportions of distinct immune cell populations (CD8⁺ T cells, CD4⁺ T cells, B cells, NK cells, macrophages, dendritic cells, and others) from bulk RNA-seq data, using reference gene expression signatures. CIBERSORTx uses support vector regression against its LM22 signature matrix (22 immune cell types), while xCell integrates hundreds of gene signatures via single-sample GSEA. These tools have been transformative for characterizing the tumor immune microenvironment, where high immune infiltration often predicts better response to immunotherapy.
Immune gene expression signatures: Curated gene sets such as immunoStates (a standardized immune signature matrix) and the LM22 reference enable consistent immune profiling across studies and platforms. These signatures allow researchers to score the immune activation state of patient samples and compare immune compositions across disease cohorts.
Autoimmune disease GWAS interpretation: Genome-wide association studies (GWAS) have identified hundreds of loci associated with autoimmune diseases, with the HLA region (chromosome 6p21) consistently showing the strongest associations. Computational tools map disease-associated variants to specific HLA alleles and predict how amino acid polymorphisms in the peptide-binding groove alter the peptide repertoire presented to T cells, providing mechanistic insight into autoimmune susceptibility.
Vaccine design bioinformatics: Computational pipelines predict candidate vaccine antigens by identifying conserved B cell epitopes (surface-accessible regions recognized by antibodies) and T cell epitopes (peptides that bind specific HLA alleles, predicted by tools like NetMHCpan and MHCflurry). Adjuvant selection is informed by computational models of innate immune activation. Reverse vaccinology — mining pathogen genomes to identify surface-exposed proteins — has accelerated vaccine development for organisms that are difficult to culture.
Systems immunology integrates transcriptomics, proteomics, metabolomics, epigenomics, and immune repertoire data to build comprehensive models of immune responses. Multi-omics integration reveals how different immune cell types coordinate during infection and vaccination, identifying correlates of protection and signatures of immune dysfunction.
COVID-19 and pandemic response bioinformatics: The SARS-CoV-2 pandemic demonstrated the power of genomic surveillance for tracking viral variants in real time (platforms such as GISAID and Nextstrain), predicting the impact of spike protein mutations on immune evasion, and identifying immune correlates of protection (neutralizing antibody titers, T cell responses). These bioinformatics frameworks — variant tracking, immune correlates analysis, and rapid epitope mapping — are now part of the infrastructure for future pandemic preparedness.
Let’s compare two HLA allele variants to see how polymorphism in the peptide-binding groove creates the diversity that underlies transplantation matching and autoimmune susceptibility:
let labels = '["Germline", "Clone-A", "Clone-B", "Clone-C", "Clone-D"]'
let distances = '[0, 5, 8, 12, 15, 5, 0, 4, 10, 12, 8, 4, 0, 7, 9, 12, 10, 7, 0, 3, 15, 12, 9, 3, 0]'
let tree = Phylo.nj(labels, distances)
print("B cell clonal lineage tree (somatic hypermutation):")
print(tree)
During an immune response, activated B cells undergo somatic hypermutation in germinal centers, accumulating point mutations in their antibody genes. Clones with higher-affinity mutations are selected, creating a branching lineage tree rooted at the germline sequence.
Exercises
Exercise: Measure Immune Repertoire Diversity
A healthy immune system maintains a diverse repertoire of T and B cells. Shannon diversity index quantifies this diversity — higher values indicate a more diverse repertoire capable of responding to more pathogens:
let healthy = '[10, 8, 7, 6, 5, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]'
let infection = '[45, 15, 8, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1]'
let immunodeficiency = '[3, 2, 2, 1, 1, 1]'
print("Healthy repertoire - Shannon: " + Stats.shannon(healthy))
print("Active infection - Shannon: " + Stats.shannon(infection))
print("Immunodeficiency - Shannon: " + Stats.shannon(immunodeficiency))
// Which condition has the most diverse repertoire?
let answer = "healthy"
print(answer)
Exercise: Align Antibody V-Gene Family Members
Antibody diversity partly comes from multiple V-gene segments. Aligning V-gene family members reveals conserved framework regions and variable complementarity-determining regions (CDRs):
let vh1 = "ATGGACTGGACCTGGAGGGTCTTCTGCTTG"
let vh2 = "ATGGACTGGACCTGGAGGTTCTTCTGCTTG"
let vh3 = "ATGGACTGGATCTGGAGGGTCTTCTGCTTG"
let alignment = Seq.msa(vh1, vh2, vh3)
print("V-gene family alignment:")
print(alignment)
// Are the conserved positions part of CDRs or framework regions?
let answer = "framework"
print(answer)
Exercise: Compare Immune Cell Proportions in Health and Disease
The proportions of immune cell types change dramatically during infection. Compare healthy blood with a patient experiencing a bacterial infection:
let healthy = '[{"label": "Neutrophils", "value": 60}, {"label": "Lymphocytes", "value": 30}, {"label": "Monocytes", "value": 6}]'
let bacterial = '[{"label": "Neutrophils", "value": 85}, {"label": "Lymphocytes", "value": 10}, {"label": "Monocytes", "value": 4}]'
print("Healthy blood:")
print(Viz.bar(healthy, '{"title": "Healthy (%)", "color": "#10B981"}'))
print("Bacterial infection:")
print(Viz.bar(bacterial, '{"title": "Bacterial Infection (%)", "color": "#EF4444"}'))
// Which cell type increases most during bacterial infection?
let answer = "neutrophils"
print(answer)
Knowledge Check
Summary
In this lesson you covered the immune system’s organization, function, and computational analysis:
- Epithelial barriers and antimicrobial peptides (defensins, cathelicidins) form the first line of defense against infection
- Pattern recognition receptors (PRRs) — including TLRs, NLRs, RLRs, CLRs, and cGAS-STING — detect conserved pathogen-associated molecular patterns (PAMPs) to activate innate immune responses
- TLR signaling through MyD88 and TRIF activates NF-κB and IRFs, driving cytokine production and inflammation
- Inflammasomes (especially NLRP3) activate caspase-1, which processes IL-1β and IL-18 and triggers pyroptosis
- The complement system enhances pathogen clearance through opsonization, inflammation, and the membrane attack complex (MAC)
- NK cells use “missing self” recognition to kill virus-infected and tumor cells that downregulate MHC class I
- Dendritic cells bridge innate and adaptive immunity by presenting pathogen-derived peptides on MHC to naïve T cells in lymph nodes
- Innate lymphoid cells (ILCs) mirror T helper cell subsets but act without antigen-specific receptors
- B cells develop in the bone marrow and produce antibodies; T cells develop in the thymus and undergo positive and negative selection
- V(D)J recombination by RAG1/RAG2 generates the enormous diversity of BCRs and TCRs
- Immunological memory enables faster, stronger secondary responses — the foundation of vaccination
- Lymphocytes recirculate continuously through peripheral lymphoid organs (lymph nodes, spleen) to maximize the chance of encountering cognate antigen
- Immune tolerance failures cause autoimmunity; immune component defects cause immunodeficiency; inappropriate IgE responses cause allergy; MHC mismatch drives transplant rejection
- Vaccination exploits memory to generate protective immunity; vaccine types range from live attenuated to mRNA-based
- AIRR-seq tools (MiXCR, IgBLAST, IMGT) identify clonotypes; diversity metrics (Shannon entropy, clonality, richness) quantify repertoire composition
- Immune deconvolution (CIBERSORTx, xCell, MCP-counter) estimates cell type proportions from bulk expression data
- Systems immunology and pandemic response bioinformatics integrate multi-omics data for immune profiling, vaccine design, and variant tracking
References
- Alberts B, Johnson A, Lewis J, Morgan D, Raff M, Roberts K, Walter P. Molecular Biology of the Cell, 7th ed. New York: W.W. Norton; 2022. Chapter 24: The Innate and Adaptive Immune Systems.
- Janeway CA Jr, Medzhitov R. Innate immune recognition. Annu Rev Immunol. 2002;20:197–216.
- Tonegawa S. Somatic generation of antibody diversity. Nature. 1983;302(5909):575–581.
- Ye J, Ma N, Madden TL, Bhatt DK, Ostell JM. IgBLAST: an immunoglobulin variable domain sequence analysis tool. Nucleic Acids Res. 2013;41(Web Server issue):W34–W40.
- Lefranc MP, Giudicelli V, Duroux P, et al. IMGT, the International ImMunoGeneTics Information System. Nucleic Acids Res. 2009;37(Database issue):D1006–D1012. https://www.imgt.org/
- Vita R, Mahajan S, Overton JA, et al. The Immune Epitope Database (IEDB): 2018 update. Nucleic Acids Res. 2019;47(D1):D339–D343. https://www.iedb.org/
- Villani AC, Satija R, Reynolds G, et al. Single-cell RNA-seq reveals new types of human blood dendritic cells, monocytes, and progenitors. Science. 2017;356(6335):eaah4573.
- Davis MM, Brodin P. Rebooting human immunology. Annu Rev Immunol. 2018;36:843–864.