Hey, can you explain me the three layers of the filtration barrier where we have the basement membrane and we have the, what do you say, epithelial cells or podocytes? And then below that, we'll have some other cells, I don't remember. So all of this make the filtration barrier and depth podocytes are effaced. Then it is membranous nephropathy, and what is focal segmental glomerulosclerosis, what is membranous nephropathy, what is membranoproliferative glomerulonephritis, and explain me that little concept. Three USMLE-based ultra-high yield, ultra-short notes, small diagrams of filtration so I can remember.
CAPILLARY LUMEN
│
┌───────▼──────────────────────────────┐
│ LAYER 1 - FENESTRATED ENDOTHELIUM │
│ • Large pores (70–100 nm) │
│ • Covered by negatively charged │
│ glycocalyx (heparan sulfate) │
│ → Filters by SIZE (large cells out) │
│ → Does NOT stop albumin alone │
└───────────────────────────────────────┘
│
┌───────▼──────────────────────────────┐
│ LAYER 2 - GBM (Glomerular Basement │
│ Membrane) ~250–400 nm thick │
│ • Type IV collagen + laminin 521 │
│ • Heparan sulfate proteoglycans │
│ (strongly NEGATIVE charge) │
│ → Filters by SIZE + CHARGE │
│ → Main barrier to albumin (negative) │
└───────────────────────────────────────┘
│
┌───────▼──────────────────────────────┐
│ LAYER 3 - PODOCYTE FOOT PROCESSES │
│ (Visceral Epithelial Cells) │
│ • Foot processes interdigitate │
│ • Connected by SLIT DIAPHRAGM │
│ (nephrin, podocin, CD2AP) │
│ → Final barrier - most specific │
│ → Effacement = loss of foot procs │
└───────────────────────────────────────┘
│
BOWMAN'S SPACE (filtrate)


| Finding | Disease |
|---|---|
| Diffuse foot process effacement, NO deposits | Minimal Change Disease (MCD) |
| Diffuse foot process effacement + segmental sclerosis | FSGS |
| Subepithelial ("spike and dome") deposits | Membranous Nephropathy |
| Subendothelial deposits + "tram-track" GBM | MPGN |
| Mesangial IgA deposits | IgA Nephropathy |
FSGS
│
├─ "Focal" = only SOME glomeruli affected (<50%)
├─ "Segmental" = only PART of a glomerulus is sclerosed
│
├─ PATHOGENESIS
│ ├─ Primary: circulating permeability factor (suPAR)
│ │ injures podocytes → foot process effacement
│ │ → podocyte dropout → bare GBM → hyalinosis
│ ├─ Secondary: HIV (HIVAN - collapsing variant)
│ │ heroin, sickle cell, obesity, APOL1 mutations
│ │ (Black patients - high-risk G1/G2 alleles)
│ └─ Inherited: nephrin, podocin, alpha-actinin-4 mutations
│
├─ PRESENTATION → NEPHROTIC SYNDROME
│ ├─ Massive proteinuria (non-selective)
│ ├─ Edema, hypoalbuminemia, hyperlipidemia
│ └─ Hematuria + HTN more common than MCD
│
├─ MICRO (EM)
│ ├─ Diffuse foot process effacement
│ ├─ NO immune deposits (vs membranous)
│ └─ Segmental collapse/sclerosis of capillary tuft
│
├─ IMMUNOFLUORESCENCE: Negative (no immune complexes)
│
└─ PROGNOSIS
├─ Poor response to steroids (vs MCD which responds well)
├─ 50% → ESKD within 10 years
└─ Recurs in 25-50% of transplants (circulating factor!)
MEMBRANOUS NEPHROPATHY
│
├─ PRIMARY (75%): Anti-PLA2R antibodies (IgG4)
│ → Antibody binds PLA2R on podocyte surface
│ → Complement activation (MAC = C5b-9)
│ → Immune complexes shed → lodge SUBEPITHELIALLY
│ → GBM grows "spikes" around deposits
│
├─ SECONDARY (25%):
│ ├─ Drugs: NSAIDs, penicillamine, gold, captopril
│ ├─ Malignancy: lung/colon cancer, melanoma
│ ├─ Infections: HBV, HCV, syphilis, malaria
│ └─ SLE (Class V lupus nephritis)
│
├─ PRESENTATION → NEPHROTIC SYNDROME
│ ├─ Most common cause of nephrotic syndrome in ADULTS
│ ├─ Massive proteinuria (selective early, then non-selective)
│ └─ NO hematuria early (non-inflammatory)
│
├─ MICRO
│ ├─ LM: Diffuse thickening of capillary wall
│ │ Silver stain → "spike and dome" (GBM spikes
│ │ projecting up between subepithelial deposits)
│ ├─ EM: Subepithelial electron-dense deposits
│ │ (Stages I→IV: deposits grow, GBM encircles them)
│ └─ IF: Granular IgG + C3 along GBM
│
└─ PROGNOSIS: "Rule of thirds"
├─ 1/3 spontaneous remission
├─ 1/3 persistent proteinuria, stable function
└─ 1/3 progressive → renal failure
MPGN
│
├─ It's a PATTERN not a single disease
│
├─ TYPE I (Immune Complex-mediated, IC-MPGN)
│ ├─ Cause: HCV (most common), HBV, SLE,
│ │ endocarditis, cryoglobulinemia
│ ├─ Deposits: SUBENDOTHELIAL + mesangial
│ ├─ Complement: C3 low, C4 low (classical pathway)
│ └─ IF: IgG + C3 + C1q + C4 (full house early)
│
├─ C3 GLOMERULOPATHY (old "Type II" / Dense Deposit Disease)
│ ├─ Cause: C3 nephritic factor (C3NeF) autoantibody
│ │ → stabilizes C3 convertase → uncontrolled
│ │ alternative complement activation
│ ├─ Deposits: Intramembranous dense ribbonlike material
│ ├─ Complement: C3 very low, C4 NORMAL
│ └─ IF: C3 only (no IgG, no C1q, no C4)
│
├─ PRESENTATION
│ ├─ MIXED nephrotic + nephritic picture
│ ├─ Hematuria + proteinuria + hypertension + edema
│ ├─ Low serum C3 in both types
│ └─ Young adults, adolescents
│
├─ MICRO
│ ├─ LM: Large, hypercellular lobular glomeruli
│ │ "Tram-track" / double-contour GBM
│ │ (silver or PAS stain)
│ │ Mesangial interposition between split GBMs
│ └─ EM: Subendothelial deposits (Type I)
│ or dense intramembranous ribbons (Type II/DDD)
│
└─ PROGNOSIS: Poor - 50% → chronic renal failure in 10 years
| MCD | FSGS | MN | MPGN | |
|---|---|---|---|---|
| Syndrome | Nephrotic | Nephrotic | Nephrotic | Both |
| Age | Kids | Adults/Kids | Adults | Adolescents |
| LM | Normal | Focal-segmental sclerosis | Thick walls, spikes | Lobular, tram-track |
| EM | Diffuse foot process effacement, NO deposits | Same + segmental sclerosis, NO deposits | Subepithelial deposits | Subendothelial deposits |
| IF | Negative | Negative | Granular IgG+C3 along GBM | IgG+C3 (Type I); C3 only (Type II) |
| Complement | Normal | Normal | Normal | Low C3 (+/- C4) |
| Key antigen/cause | Unknown (permeability factor) | APOL1, HIV, obesity, podocin/nephrin mutations | Anti-PLA2R (75%) | HCV, C3NeF |
| Steroid response | Excellent | Poor | Partial | None |
GLOMERULAR CAPILLARY CROSS-SECTION:
BOWMAN'S SPACE
│
[PODOCYTE FOOT PROCESS]
│
← Subepithelial ← (MN = "spike and dome")
│
[ G B M ]
│
← Intramembranous ← (DDD/C3GN = dense ribbons)
│
← Subendothelial ← (MPGN Type I, SLE)
│
[ENDOTHELIUM - fenestrated]
│
CAPILLARY LUMEN
│
← Mesangial ← (IgA nephropathy, mesangial lupus)
Create a quick-reference PDF summarizing filtration barrier layers and three glomerulonephropathies
ls /home/daytona/workspace/ 2>/dev/null && mkdir -p /home/daytona/workspace/glomerulo-pdf
~/glomerulo-pdf/make_pdf.py
#!/usr/bin/env python3
"""
USMLE Quick-Reference PDF: Glomerular Filtration Barrier + Glomerulopathies
Uses ReportLab for full layout control.
"""
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether, PageBreak
)
from reportlab.platypus.flowables import Flowable
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Polygon, Circle, Group
from reportlab.graphics import renderPDF
import io
# ── Colour palette ────────────────────────────────────────────────────────────
C_DARK_BLUE = colors.HexColor("#1A3A5C")
C_MED_BLUE = colors.HexColor("#2E6DA4")
C_LIGHT_BLUE = colors.HexColor("#D6E8F7")
C_TEAL = colors.HexColor("#1B7F79")
C_LIGHT_TEAL = colors.HexColor("#D0EFED")
C_ORANGE = colors.HexColor("#E07B39")
C_LIGHT_ORA = colors.HexColor("#FDEBD8")
C_PURPLE = colors.HexColor("#5B3A8A")
C_LIGHT_PUR = colors.HexColor("#EDE5F5")
C_RED = colors.HexColor("#C0392B")
C_LIGHT_RED = colors.HexColor("#FADBD8")
C_GREEN = colors.HexColor("#1E7D45")
C_LIGHT_GRN = colors.HexColor("#D5F0E0")
C_GREY = colors.HexColor("#5A5A5A")
C_LGREY = colors.HexColor("#F2F2F2")
C_WHITE = colors.white
C_BLACK = colors.black
C_GOLD = colors.HexColor("#D4A017")
W, H = A4 # 595.27 x 841.89 pt
# ── Styles ────────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
def S(name, **kw):
return ParagraphStyle(name, **kw)
TITLE = S("Title2",
fontSize=22, leading=28, textColor=C_WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER, spaceAfter=4)
SUBTITLE = S("Subtitle2",
fontSize=10, leading=14, textColor=C_LIGHT_BLUE,
fontName="Helvetica", alignment=TA_CENTER)
SEC_HEAD = S("SecHead",
fontSize=13, leading=17, textColor=C_WHITE,
fontName="Helvetica-Bold", alignment=TA_LEFT,
leftIndent=6, spaceAfter=2, spaceBefore=6)
SUB_HEAD = S("SubHead",
fontSize=10, leading=13, textColor=C_DARK_BLUE,
fontName="Helvetica-Bold", spaceAfter=2, spaceBefore=4)
BODY = S("Body2",
fontSize=8.5, leading=12, textColor=C_GREY,
fontName="Helvetica", spaceAfter=2)
BODY_B = S("BodyBold",
fontSize=8.5, leading=12, textColor=C_BLACK,
fontName="Helvetica-Bold", spaceAfter=2)
SMALL = S("Small",
fontSize=7.5, leading=10, textColor=C_GREY,
fontName="Helvetica", spaceAfter=1)
CODE = S("Code2",
fontSize=7.8, leading=11, textColor=C_DARK_BLUE,
fontName="Courier", spaceAfter=1, leftIndent=6)
USMLE = S("USMLE",
fontSize=8.5, leading=12, textColor=C_DARK_BLUE,
fontName="Helvetica-BoldOblique", spaceAfter=2,
leftIndent=4, borderPad=4)
TABLE_HEAD = S("TH",
fontSize=8, leading=10, textColor=C_WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER)
TABLE_CELL = S("TC",
fontSize=7.5, leading=10, textColor=C_GREY,
fontName="Helvetica", alignment=TA_CENTER)
TABLE_CELL_L = S("TCL",
fontSize=7.5, leading=10, textColor=C_GREY,
fontName="Helvetica", alignment=TA_LEFT)
TABLE_CELL_B = S("TCB",
fontSize=7.5, leading=10, textColor=C_BLACK,
fontName="Helvetica-Bold", alignment=TA_CENTER)
# ── Custom Flowables ───────────────────────────────────────────────────────────
class ColorBox(Flowable):
"""A coloured header band."""
def __init__(self, text, bg, fg=C_WHITE, height=22, width=None, radius=4, style=None):
Flowable.__init__(self)
self.text = text
self.bg = bg
self.fg = fg
self.bheight = height
self._width = width
self.radius = radius
self.style = style or ParagraphStyle("cb",
fontSize=11, fontName="Helvetica-Bold",
textColor=fg, alignment=TA_LEFT, leading=14)
def wrap(self, availW, availH):
self.availW = self._width or availW
return self.availW, self.bheight + 4
def draw(self):
c = self.canv
c.setFillColor(self.bg)
c.roundRect(0, 0, self.availW, self.bheight, self.radius, fill=1, stroke=0)
c.setFillColor(self.fg)
c.setFont(self.style.fontName, self.style.fontSize)
c.drawString(8, (self.bheight - self.style.fontSize) / 2 + 2, self.text)
class FiltrationBarrierDiagram(Flowable):
"""ASCII-art style cross-section of the filtration barrier."""
def __init__(self, w=510, h=230):
Flowable.__init__(self)
self._w = w
self._h = h
def wrap(self, aW, aH):
return self._w, self._h
def draw(self):
c = self.canv
w, h = self._w, self._h
# Background
c.setFillColor(C_LGREY)
c.roundRect(0, 0, w, h, 6, fill=1, stroke=0)
# ---- Layers (from top = Bowman's space, bottom = capillary lumen)
# Zones: y positions (bottom of each layer)
lumen_top = 18
endo_top = lumen_top + 48
gbm_top = endo_top + 38
podo_top = gbm_top + 52
bowman_top = h - 12
# Capillary Lumen (bottom)
c.setFillColor(colors.HexColor("#AED6F1"))
c.rect(30, lumen_top - 14, w - 60, 14, fill=1, stroke=0)
c.setFont("Helvetica-Bold", 7.5)
c.setFillColor(C_DARK_BLUE)
c.drawCentredString(w/2, lumen_top - 11, "CAPILLARY LUMEN (blood)")
# ── Layer 1: Fenestrated Endothelium ──────────────────────────────
c.setFillColor(colors.HexColor("#5DADE2"))
c.rect(30, lumen_top, w - 60, endo_top - lumen_top, fill=1, stroke=0)
# Draw fenestrations (small white ovals)
import math
for xi in range(55, w - 55, 38):
c.setFillColor(C_WHITE)
c.ellipse(xi - 7, lumen_top + 10, xi + 7, lumen_top + 28, fill=1, stroke=0)
# Negative charge symbols
c.setFillColor(colors.HexColor("#F5B7B1"))
c.setFont("Helvetica-Bold", 9)
for xi in range(46, w - 55, 38):
c.setFillColor(colors.HexColor("#C0392B"))
c.drawString(xi - 2, lumen_top + 32, "−")
# Label on left
c.setFillColor(C_WHITE)
c.setFont("Helvetica-Bold", 8)
c.drawString(35, lumen_top + 19, "LAYER 1")
c.setFont("Helvetica", 7.5)
c.drawString(35, lumen_top + 9, "Fenestrated")
# Right-side annotation
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica-Bold", 7.5)
c.drawString(w - 155, lumen_top + 32, "• 70–100 nm pores")
c.drawString(w - 155, lumen_top + 21, "• Glycocalyx (−ve charge)")
c.drawString(w - 155, lumen_top + 10, "• Coarse size filter")
# ── Layer 2: GBM ──────────────────────────────────────────────────
c.setFillColor(colors.HexColor("#D4AC0D"))
c.rect(30, endo_top, w - 60, gbm_top - endo_top, fill=1, stroke=0)
# Texture lines
c.setStrokeColor(colors.HexColor("#B7950B"))
c.setLineWidth(0.4)
for yi in range(endo_top + 4, gbm_top, 6):
c.line(30, yi, w - 30, yi)
c.setFillColor(C_WHITE)
c.setFont("Helvetica-Bold", 8)
c.drawString(35, endo_top + 18, "LAYER 2 – GBM")
c.setFont("Helvetica", 7)
c.drawString(35, endo_top + 7, "250–400 nm thick")
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica-Bold", 7.5)
c.drawString(w - 210, endo_top + 28, "• Type IV collagen + Laminin 521")
c.drawString(w - 210, endo_top + 17, "• Heparan sulfate (−ve charge)")
c.drawString(w - 210, endo_top + 6, "• SIZE + CHARGE barrier → stops albumin")
# ── Layer 3: Podocyte foot processes ──────────────────────────────
c.setFillColor(colors.HexColor("#A9DFBF"))
c.rect(30, gbm_top, w - 60, podo_top - gbm_top, fill=1, stroke=0)
# Draw interdigitating foot process stumps
fp_count = 10
fp_w = (w - 100) / fp_count
for i in range(fp_count):
xi = 50 + i * fp_w
# Alternating foot processes from 2 podocytes (different shade)
shade = colors.HexColor("#27AE60") if i % 2 == 0 else colors.HexColor("#1E8449")
c.setFillColor(shade)
c.roundRect(xi, gbm_top + 6, fp_w * 0.55, podo_top - gbm_top - 10, 3, fill=1, stroke=0)
# Slit diaphragm lines
c.setStrokeColor(colors.HexColor("#922B21"))
c.setLineWidth(1.2)
for i in range(fp_count - 1):
xi = 50 + i * fp_w + fp_w * 0.55
mid_y = gbm_top + (podo_top - gbm_top) / 2 + 4
c.line(xi, gbm_top + 8, xi + fp_w * 0.45, gbm_top + 8)
c.setFillColor(colors.HexColor("#922B21"))
c.setFont("Helvetica-Bold", 7)
c.drawCentredString(w / 2 + 20, gbm_top + 1, "← slit diaphragms (nephrin / podocin) →")
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica-Bold", 8)
c.drawString(35, podo_top - 12, "LAYER 3 – PODOCYTE")
c.setFont("Helvetica", 7)
c.drawString(35, podo_top - 22, "foot processes")
c.setFont("Helvetica-Bold", 7.5)
c.setFillColor(C_DARK_BLUE)
c.drawString(w - 215, podo_top - 12, "• Interdigitating foot processes")
c.drawString(w - 215, podo_top - 23, "• Slit diaphragm = nephrin, podocin, CD2AP")
c.drawString(w - 215, podo_top - 34, "• FINAL and most specific barrier")
c.drawString(w - 215, podo_top - 45, "• Effacement → proteinuria")
# Bowman's space
c.setFillColor(colors.HexColor("#EBF5FB"))
c.rect(30, podo_top, w - 60, bowman_top - podo_top, fill=1, stroke=0)
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica-Bold", 7.5)
c.drawCentredString(w / 2, podo_top + 5, "BOWMAN'S SPACE (filtrate)")
# Left border labels
layer_labels = [
(lumen_top + (endo_top - lumen_top)/2 + 2, "1"),
(endo_top + (gbm_top - endo_top)/2, "2"),
(gbm_top + (podo_top - gbm_top)/2, "3"),
]
layer_cols = [C_MED_BLUE, colors.HexColor("#B7950B"), C_GREEN]
for (ly, num), col in zip(layer_labels, layer_cols):
c.setFillColor(col)
c.circle(18, ly, 8, fill=1, stroke=0)
c.setFillColor(C_WHITE)
c.setFont("Helvetica-Bold", 9)
c.drawCentredString(18, ly - 3, num)
# Title
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica-Bold", 9.5)
c.drawCentredString(w / 2, h - 9, "GLOMERULAR FILTRATION BARRIER — Cross-Section")
class DepositLocationDiagram(Flowable):
"""Shows WHERE deposits sit relative to GBM for each disease."""
def __init__(self, w=510, h=130):
Flowable.__init__(self)
self._w = w
self._h = h
def wrap(self, aW, aH):
return self._w, self._h
def draw(self):
c = self.canv
w, h = self._w, self._h
# Background
c.setFillColor(C_LGREY)
c.roundRect(0, 0, w, h, 5, fill=1, stroke=0)
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica-Bold", 9)
c.drawCentredString(w/2, h - 12, "DEPOSIT LOCATION CHEAT SHEET")
# Draw a capillary wall cross-section
cx = 90 # centre x of the diagram
top_y = h - 25
bot_y = 22
# Podocyte layer
c.setFillColor(colors.HexColor("#A9DFBF"))
c.rect(cx - 8, top_y - 15, 16, 15, fill=1, stroke=0)
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica", 7)
c.drawCentredString(cx, top_y - 7, "POD")
# GBM
c.setFillColor(colors.HexColor("#F9E79F"))
c.rect(cx - 8, bot_y + 25, 16, top_y - 15 - (bot_y + 25), fill=1, stroke=0)
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica-Bold", 7)
c.drawCentredString(cx, (bot_y + 25 + top_y - 15) / 2 - 3, "GBM")
# Endothelium
c.setFillColor(colors.HexColor("#AED6F1"))
c.rect(cx - 8, bot_y, 16, 25, fill=1, stroke=0)
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica", 7)
c.drawCentredString(cx, bot_y + 13, "END")
c.setFillColor(C_DARK_BLUE)
c.setFont("Helvetica", 6.5)
c.drawCentredString(cx, bot_y - 10, "Lumen ↑")
# Arrows + labels for each disease
diseases = [
# (x_offset, y_centre, colour, label, sublabel)
(cx + 35, top_y - 8, C_ORANGE, "Membranous NP", "subEPITHELIAL\n(spike & dome)"),
(cx + 100, (bot_y + 25 + top_y - 15) / 2, C_PURPLE, "DDD / C3GN", "intraMEMBRANOUS\n(dense ribbons)"),
(cx + 170, bot_y + 13, C_RED, "MPGN Type I", "subENDOTHELIAL\n(tram-track)"),
(cx + 240, (bot_y + 25 + top_y - 15) / 2 - 10, C_TEAL, "IgA / Mesangial", "MESANGIAL\n(IgA deposits)"),
]
for dx, dy, col, label, sub in diseases:
# Arrow from disease position to wall
c.setStrokeColor(col)
c.setLineWidth(1.5)
c.line(cx + 10, dy, dx - 5, dy)
# Arrow head
c.setFillColor(col)
c.polygon([dx - 5, dy + 4, dx - 5, dy - 4, dx + 2, dy], fill=1, stroke=0)
# Dot on wall
c.setFillColor(col)
c.circle(cx + 10, dy, 4, fill=1, stroke=0)
# Disease box
c.setFillColor(col)
bw = 100
bh = 28
c.roundRect(dx + 5, dy - bh/2, bw, bh, 3, fill=1, stroke=0)
c.setFillColor(C_WHITE)
c.setFont("Helvetica-Bold", 7)
c.drawString(dx + 9, dy + 6, label)
lines = sub.split("\n")
c.setFont("Helvetica", 6.5)
c.drawString(dx + 9, dy - 2, lines[0])
if len(lines) > 1:
c.drawString(dx + 9, dy - 10, lines[1])
# ── Helper: disease card ───────────────────────────────────────────────────────
def disease_card(title, color_bg, color_light, rows, usmle_line):
"""Returns a list of flowables for one disease section."""
items = []
items.append(ColorBox(title, color_bg, C_WHITE, height=20))
items.append(Spacer(1, 3))
for label, content in rows:
row_data = [[
Paragraph(f"<b>{label}</b>", TABLE_CELL_B),
Paragraph(content, TABLE_CELL_L)
]]
t = Table(row_data, colWidths=[85, W - 85 - 72])
t.setStyle(TableStyle([
("BACKGROUND", (0, 0), (0, 0), color_light),
("BACKGROUND", (1, 0), (1, 0), C_WHITE),
("ALIGN", (0, 0), (0, 0), "CENTER"),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("GRID", (0, 0), (-1, -1), 0.4, colors.HexColor("#CCCCCC")),
("TOPPADDING", (0, 0), (-1, -1), 3),
("BOTTOMPADDING", (0, 0), (-1, -1), 3),
("LEFTPADDING", (0, 0), (-1, -1), 5),
("RIGHTPADDING", (0, 0), (-1, -1), 5),
]))
items.append(t)
items.append(Spacer(1, 3))
# USMLE one-liner box
usmle_data = [[
Paragraph("USMLE ONE-LINER", TABLE_HEAD),
Paragraph(usmle_line, USMLE)
]]
ut = Table(usmle_data, colWidths=[90, W - 90 - 72])
ut.setStyle(TableStyle([
("BACKGROUND", (0, 0), (0, 0), color_bg),
("BACKGROUND", (1, 0), (1, 0), color_light),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("GRID", (0, 0), (-1, -1), 0.5, color_bg),
("TOPPADDING", (0, 0), (-1, -1), 4),
("BOTTOMPADDING", (0, 0), (-1, -1), 4),
("LEFTPADDING", (0, 0), (-1, -1), 5),
]))
items.append(ut)
items.append(Spacer(1, 8))
return items
# ── Build document ─────────────────────────────────────────────────────────────
OUT = "/home/daytona/workspace/glomerulo-pdf/Glomerular_Quick_Reference.pdf"
doc = SimpleDocTemplate(
OUT,
pagesize=A4,
leftMargin=28, rightMargin=28,
topMargin=22, bottomMargin=22,
title="Glomerular Filtration Barrier & Glomerulopathies",
author="Orris Medical AI",
)
story = []
# ══ HEADER BANNER ══════════════════════════════════════════════════════════════
header_data = [[
Paragraph("GLOMERULAR FILTRATION BARRIER<br/><font size='11'>+ Glomerulopathies USMLE Quick Reference</font>", TITLE),
Paragraph("Robbins Pathology · Brenner & Rector · NKF Primer<br/>USMLE Step 1 / Step 2 CK", SUBTITLE),
]]
header_tbl = Table(header_data, colWidths=[W - 56])
header_tbl.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, -1), C_DARK_BLUE),
("ROUNDEDCORNERS", (0, 0), (-1, -1), [8, 8, 8, 8]),
("TOPPADDING", (0, 0), (-1, -1), 10),
("BOTTOMPADDING", (0, 0), (-1, -1), 10),
]))
story.append(header_tbl)
story.append(Spacer(1, 10))
# ══ SECTION 1: FILTRATION BARRIER ═════════════════════════════════════════════
story.append(ColorBox(" SECTION 1 — THE THREE-LAYER GLOMERULAR FILTRATION BARRIER", C_MED_BLUE, height=22))
story.append(Spacer(1, 6))
story.append(FiltrationBarrierDiagram(w=W - 56, h=215))
story.append(Spacer(1, 8))
# Layer table
layer_rows = [
[Paragraph("Layer", TABLE_HEAD),
Paragraph("Structure", TABLE_HEAD),
Paragraph("Key Components", TABLE_HEAD),
Paragraph("Barrier Function", TABLE_HEAD),
Paragraph("Charge", TABLE_HEAD)],
[Paragraph("1", TABLE_CELL_B),
Paragraph("Fenestrated Endothelium", TABLE_CELL_L),
Paragraph("70–100 nm fenestrae; glycocalyx coat", TABLE_CELL_L),
Paragraph("Coarse size filter; excludes cells + large proteins", TABLE_CELL_L),
Paragraph("Negative (heparan sulfate)", TABLE_CELL_L)],
[Paragraph("2", TABLE_CELL_B),
Paragraph("GBM (Glomerular Basement Membrane)", TABLE_CELL_L),
Paragraph("Type IV collagen, laminin 521, heparan sulfate proteoglycans; 250–400 nm", TABLE_CELL_L),
Paragraph("SIZE + CHARGE — main barrier to albumin (IgG-size molecules)", TABLE_CELL_L),
Paragraph("Strongly negative", TABLE_CELL_L)],
[Paragraph("3", TABLE_CELL_B),
Paragraph("Podocyte Foot Processes + Slit Diaphragm", TABLE_CELL_L),
Paragraph("Nephrin, podocin, CD2AP, α-actinin-4; slit 25–60 nm", TABLE_CELL_L),
Paragraph("Final and most selective barrier; effacement → massive proteinuria", TABLE_CELL_L),
Paragraph("Negative (podocalyxin)", TABLE_CELL_L)],
]
lt = Table(layer_rows, colWidths=[28, 100, 140, 155, 92])
lt.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), C_DARK_BLUE),
("BACKGROUND", (0, 1), (0, 1), colors.HexColor("#AED6F1")),
("BACKGROUND", (0, 2), (0, 2), colors.HexColor("#F9E79F")),
("BACKGROUND", (0, 3), (0, 3), colors.HexColor("#A9DFBF")),
("ROWBACKGROUNDS", (1, 1), (-1, -1), [C_WHITE, C_LGREY, C_WHITE]),
("GRID", (0, 0), (-1, -1), 0.5, colors.HexColor("#AAAAAA")),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("ALIGN", (0, 0), (0, -1), "CENTER"),
("TOPPADDING", (0, 0), (-1, -1), 3),
("BOTTOMPADDING", (0, 0), (-1, -1), 3),
("LEFTPADDING", (0, 0), (-1, -1), 4),
("RIGHTPADDING", (0, 0), (-1, -1), 4),
]))
story.append(lt)
story.append(Spacer(1, 6))
# Mesangial cells note
meso = Table([[
Paragraph("MESANGIAL CELLS", TABLE_HEAD),
Paragraph(
"NOT part of the filtration barrier. Sit between capillary loops. "
"Provide structural support, phagocytose immune complexes, regulate GFR via contraction. "
"<b>Proliferate in IgA nephropathy and MPGN.</b>",
TABLE_CELL_L)
]], colWidths=[100, W - 56 - 100])
meso.setStyle(TableStyle([
("BACKGROUND", (0, 0), (0, 0), C_TEAL),
("BACKGROUND", (1, 0), (1, 0), C_LIGHT_TEAL),
("GRID", (0, 0), (-1, -1), 0.5, C_TEAL),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("TOPPADDING", (0, 0), (-1, -1), 4),
("BOTTOMPADDING", (0, 0), (-1, -1), 4),
("LEFTPADDING", (0, 0), (-1, -1), 5),
]))
story.append(meso)
story.append(Spacer(1, 10))
# ══ EFFACEMENT TABLE ══════════════════════════════════════════════════════════
story.append(ColorBox(" FOOT PROCESS EFFACEMENT — KEY DISCRIMINATOR", C_TEAL, height=20))
story.append(Spacer(1, 4))
eff_rows = [
[Paragraph("Finding on EM", TABLE_HEAD),
Paragraph("Immune Deposits?", TABLE_HEAD),
Paragraph("LM Finding", TABLE_HEAD),
Paragraph("Disease", TABLE_HEAD)],
[Paragraph("Diffuse effacement, NO deposits", TABLE_CELL_L),
Paragraph("None", TABLE_CELL),
Paragraph("Normal glomeruli", TABLE_CELL_L),
Paragraph("Minimal Change Disease (MCD)", TABLE_CELL_B)],
[Paragraph("Diffuse effacement + segmental sclerosis", TABLE_CELL_L),
Paragraph("None", TABLE_CELL),
Paragraph("Focal-segmental sclerosis/hyalinosis", TABLE_CELL_L),
Paragraph("FSGS", TABLE_CELL_B)],
[Paragraph("Subepithelial deposits (spike & dome)", TABLE_CELL_L),
Paragraph("IgG4 + C3 (granular, along GBM)", TABLE_CELL),
Paragraph("Diffuse capillary wall thickening", TABLE_CELL_L),
Paragraph("Membranous Nephropathy", TABLE_CELL_B)],
[Paragraph("Subendothelial deposits + tram-track", TABLE_CELL_L),
Paragraph("IgG + C3 (Type I)\nC3 only (Type II/DDD)", TABLE_CELL),
Paragraph("Lobular, hypercellular, split GBM", TABLE_CELL_L),
Paragraph("MPGN", TABLE_CELL_B)],
[Paragraph("Mesangial deposits", TABLE_CELL_L),
Paragraph("IgA dominant", TABLE_CELL),
Paragraph("Mesangial expansion", TABLE_CELL_L),
Paragraph("IgA Nephropathy", TABLE_CELL_B)],
]
et = Table(eff_rows, colWidths=[155, 115, 140, 105])
et.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), C_TEAL),
("ROWBACKGROUNDS", (0, 1), (-1, -1), [C_WHITE, C_LGREY]),
("GRID", (0, 0), (-1, -1), 0.5, colors.HexColor("#AAAAAA")),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("TOPPADDING", (0, 0), (-1, -1), 3),
("BOTTOMPADDING", (0, 0), (-1, -1), 3),
("LEFTPADDING", (0, 0), (-1, -1), 4),
]))
story.append(et)
story.append(Spacer(1, 10))
# ══ DEPOSIT LOCATION DIAGRAM ══════════════════════════════════════════════════
story.append(ColorBox(" DEPOSIT LOCATION — WHERE IMMUNE COMPLEXES SIT", C_PURPLE, height=20))
story.append(Spacer(1, 5))
story.append(DepositLocationDiagram(w=W - 56, h=115))
story.append(Spacer(1, 10))
# ══ PAGE BREAK ════════════════════════════════════════════════════════════════
story.append(PageBreak())
# ══ SECTION 2 HEADER ══════════════════════════════════════════════════════════
story.append(ColorBox(" SECTION 2 — THREE GLOMERULOPATHIES (NEPHROTIC-PREDOMINANT)", C_MED_BLUE, height=22))
story.append(Spacer(1, 8))
# ── FSGS ──────────────────────────────────────────────────────────────────────
story += disease_card(
" 1. FOCAL SEGMENTAL GLOMERULOSCLEROSIS (FSGS)",
C_ORANGE, C_LIGHT_ORA,
[
("Syndrome", "NEPHROTIC — massive proteinuria (non-selective), edema, hypoalbuminemia, hyperlipidemia; + hematuria, HTN (more than MCD)"),
("Pathogenesis", "<b>Podocyte loss exceeds compensation capacity.</b> Primary: circulating permeability factor (suPAR). Secondary: HIV (collapsing HIVAN), heroin, sickle cell, obesity. Genetic: APOL1 G1/G2 alleles (Black patients), nephrin/podocin/α-actinin-4 mutations."),
("Light Micro", "Focal (<50% glomeruli) + Segmental (part of tuft) sclerosis and hyalinosis. Rest of glomerulus and other glomeruli appear normal."),
("Electron Micro", "<b>Diffuse foot process effacement</b> — NO electron-dense immune deposits (unlike MN). Segmental collapse of capillary tuft."),
("Immuno-fluor.", "<b>NEGATIVE</b> — no immune complex deposits. May see non-specific IgM/C3 in sclerotic segments."),
("Complement", "Normal C3, C4."),
("Treatment", "Steroids (poor response vs MCD). Cyclosporine, tacrolimus for steroid-resistant. ACE inhibitor for proteinuria."),
("Prognosis", "Poor: 50% → ESKD in 10 years. Recurs in 25–50% of kidney transplants (circulating factor persists)."),
],
"Black patient or HIV patient + steroid-resistant nephrotic syndrome + NO deposits on EM = FSGS. Ask about APOL1 alleles."
)
# ── MEMBRANOUS NEPHROPATHY ────────────────────────────────────────────────────
story += disease_card(
" 2. MEMBRANOUS NEPHROPATHY (MN)",
C_PURPLE, C_LIGHT_PUR,
[
("Syndrome", "<b>NEPHROTIC — #1 cause of nephrotic syndrome in adults.</b> Proteinuria ± selective early. Insidious onset, no hematuria initially."),
("Pathogenesis", "<b>Primary (75%):</b> IgG4 anti-PLA2R antibodies → bind PLA2R on podocyte basal surface → complement (MAC/C5b-9) activation → immune aggregates shed → lodge <b>subepithelially</b> → GBM grows spikes around deposits. Other antigens: NELL1, THSD7A, EXT1/2. <b>Secondary (25%):</b> Drugs (NSAIDs, penicillamine, gold), malignancy (lung, colon, melanoma), SLE (Class V), infections (HBV, HCV, syphilis)."),
("Light Micro", "Diffuse thickening of capillary walls. Silver stain → <b>'spike and dome'</b> pattern (GBM spikes project up between subepithelial deposits)."),
("Electron Micro", "<b>Subepithelial electron-dense deposits</b> (between podocyte foot processes and GBM). Stage I→IV: deposits grow, GBM progressively encircles them."),
("Immuno-fluor.", "Granular IgG (IgG4) + C3 along GBM. C1q + C4 may be present in secondary forms."),
("Complement", "Normal serum C3/C4 in primary MN. May be low in SLE-associated."),
("Diagnosis", "Anti-PLA2R antibody titre (serum) — positive in ~75% primary MN. Confirms diagnosis, monitors remission."),
("Prognosis", "Rule of thirds: 1/3 spontaneous remission, 1/3 persistent stable, 1/3 → renal failure. Rituximab (anti-CD20) first-line for primary MN."),
],
"Adult + nephrotic syndrome + spike-and-dome on silver stain + granular IgG on IF + subepithelial deposits on EM = Membranous NP. Rule out malignancy/SLE."
)
# ── MPGN ──────────────────────────────────────────────────────────────────────
story += disease_card(
" 3. MEMBRANOPROLIFERATIVE GLOMERULONEPHRITIS (MPGN)",
C_RED, C_LIGHT_RED,
[
("Syndrome", "<b>MIXED NEPHROTIC + NEPHRITIC</b> — hematuria + proteinuria + HTN + edema. Low C3. Young adults/adolescents."),
("Classification", "<b>Type I (IC-MPGN):</b> Immune complex-mediated. Causes: HCV + cryoglobulinemia, HBV, SLE, endocarditis. Deposits: subendothelial + mesangial. Classical complement → C3 low AND C4 low. IF: IgG + C3 + C1q + C4.<br/><b>C3 Glomerulopathy (old Type II / DDD):</b> Alternative complement dysregulation. C3NeF autoantibody stabilises C3 convertase → uncontrolled C3 activation. Deposits: intramembranous dense ribbons (DDD). C3 very low, C4 NORMAL. IF: C3 only (no IgG, no C1q, no C4)."),
("Light Micro", "Large, <b>lobular, hypercellular</b> glomeruli. <b>Tram-track / double-contour GBM</b> on PAS or silver stain (mesangial interposition between split GBMs). Endocapillary proliferation."),
("Electron Micro", "Type I: <b>Subendothelial</b> electron-dense deposits + mesangial deposits.<br/>Type II/DDD: <b>Intramembranous</b> ribbonlike, extremely electron-dense material permeating lamina densa."),
("Immuno-fluor.", "Type I: IgG + C3 + C1q + C4 (granular). Type II/DDD: C3 only — no immunoglobulin, no C1q, no C4."),
("Complement KEY", "<b>Both types: Low C3.</b> C4 low in Type I (classical pathway used). C4 NORMAL in Type II/DDD (only alternative pathway)."),
("Secondary MPGN", "Chronic immune complex disorders: SLE, HCV, HBV, endocarditis, cryoglobulinemia. Malignancy with paraprotein. Always work up for underlying cause in adults."),
("Prognosis", "Poor — 50% → chronic renal failure within 10 years. Treat underlying cause. No proven benefit of steroids/immunosuppressants in primary MPGN."),
],
"HCV patient + mixed nephrotic-nephritic + LOW C3 + lobular glomeruli + tram-track = MPGN Type I. If C4 NORMAL with very low C3 → C3 glomerulopathy (DDD). Check for C3NeF."
)
# ══ MASTER COMPARISON TABLE ═══════════════════════════════════════════════════
story.append(ColorBox(" MASTER COMPARISON TABLE", C_DARK_BLUE, height=22))
story.append(Spacer(1, 5))
comp_rows = [
[Paragraph(h, TABLE_HEAD) for h in
["", "MCD", "FSGS", "Membranous NP", "MPGN Type I", "MPGN / DDD (C3G)"]],
[Paragraph("Syndrome", TABLE_CELL_B),
Paragraph("Nephrotic", TABLE_CELL),
Paragraph("Nephrotic", TABLE_CELL),
Paragraph("Nephrotic", TABLE_CELL),
Paragraph("Both", TABLE_CELL),
Paragraph("Both", TABLE_CELL)],
[Paragraph("Peak Age", TABLE_CELL_B),
Paragraph("Children", TABLE_CELL),
Paragraph("Adults (any)", TABLE_CELL),
Paragraph("Adults 30–50", TABLE_CELL),
Paragraph("Teens/YA", TABLE_CELL),
Paragraph("Teens/YA", TABLE_CELL)],
[Paragraph("LM", TABLE_CELL_B),
Paragraph("Normal", TABLE_CELL),
Paragraph("Focal-seg sclerosis", TABLE_CELL),
Paragraph("Thick walls\n(spike & dome)", TABLE_CELL),
Paragraph("Lobular, tram-track", TABLE_CELL),
Paragraph("Lobular, tram-track; dense intramembranous", TABLE_CELL)],
[Paragraph("EM Deposits", TABLE_CELL_B),
Paragraph("None\n(diffuse effacement)", TABLE_CELL),
Paragraph("None\n(effacement + sclerosis)", TABLE_CELL),
Paragraph("Subepithelial", TABLE_CELL),
Paragraph("Subendothelial\n+ mesangial", TABLE_CELL),
Paragraph("Intramembranous\n(dense ribbons)", TABLE_CELL)],
[Paragraph("IF Pattern", TABLE_CELL_B),
Paragraph("Negative", TABLE_CELL),
Paragraph("Negative", TABLE_CELL),
Paragraph("Granular IgG4\n+ C3 (GBM)", TABLE_CELL),
Paragraph("IgG + C3\n+ C1q + C4", TABLE_CELL),
Paragraph("C3 ONLY\n(no IgG/C1q/C4)", TABLE_CELL)],
[Paragraph("C3 / C4", TABLE_CELL_B),
Paragraph("Normal", TABLE_CELL),
Paragraph("Normal", TABLE_CELL),
Paragraph("Normal", TABLE_CELL),
Paragraph("C3↓ C4↓", TABLE_CELL),
Paragraph("C3↓↓ C4 Normal", TABLE_CELL)],
[Paragraph("Key Antigen / Cause", TABLE_CELL_B),
Paragraph("Unknown\n(permeability factor)", TABLE_CELL),
Paragraph("suPAR, APOL1\nHIV, podocin", TABLE_CELL),
Paragraph("Anti-PLA2R\n(IgG4) – 75%", TABLE_CELL),
Paragraph("HCV, SLE\nHBV, endocarditis", TABLE_CELL),
Paragraph("C3NeF autoAb\nFactor H mutation", TABLE_CELL)],
[Paragraph("Steroid Resp.", TABLE_CELL_B),
Paragraph("Excellent ✓", TABLE_CELL),
Paragraph("Poor ✗", TABLE_CELL),
Paragraph("Partial (Rituximab)", TABLE_CELL),
Paragraph("None", TABLE_CELL),
Paragraph("None", TABLE_CELL)],
[Paragraph("Prognosis", TABLE_CELL_B),
Paragraph("Good (90% remit)", TABLE_CELL),
Paragraph("50% ESKD/10yr\nRecurs in Tx", TABLE_CELL),
Paragraph("Rule of 1/3s", TABLE_CELL),
Paragraph("50% CRF/10yr", TABLE_CELL),
Paragraph("50% CRF/10yr", TABLE_CELL)],
]
ct = Table(comp_rows, colWidths=[75, 82, 88, 92, 87, 95])
comp_style = TableStyle([
("BACKGROUND", (0, 0), (-1, 0), C_DARK_BLUE),
("BACKGROUND", (0, 1), (0, -1), C_LIGHT_BLUE),
("ROWBACKGROUNDS", (1, 1), (-1, -1), [C_WHITE, C_LGREY]),
("GRID", (0, 0), (-1, -1), 0.4, colors.HexColor("#BBBBBB")),
("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
("ALIGN", (1, 0), (-1, -1), "CENTER"),
("TOPPADDING", (0, 0), (-1, -1), 3),
("BOTTOMPADDING", (0, 0), (-1, -1), 3),
("LEFTPADDING", (0, 0), (-1, -1), 3),
("RIGHTPADDING", (0, 0), (-1, -1), 3),
# Highlight FSGS row
("BACKGROUND", (2, 1), (2, -1), colors.HexColor("#FEF9E7")),
# Highlight MN
("BACKGROUND", (3, 1), (3, -1), colors.HexColor("#F5EEF8")),
# Highlight MPGN
("BACKGROUND", (4, 1), (4, -1), colors.HexColor("#FDEDEC")),
("BACKGROUND", (5, 1), (5, -1), colors.HexColor("#FDEDEC")),
])
ct.setStyle(comp_style)
story.append(ct)
story.append(Spacer(1, 8))
# ══ FOOTER NOTE ═══════════════════════════════════════════════════════════════
footer_txt = (
"<b>Sources:</b> Robbins, Cotran & Kumar Pathologic Basis of Disease (10e) · "
"Brenner & Rector's The Kidney (11e) · "
"National Kidney Foundation Primer on Kidney Diseases (8e) · "
"Smith & Tanagho's General Urology (19e) | "
"<b>Generated by Orris Medical AI</b>"
)
story.append(Paragraph(footer_txt, SMALL))
# ── Build ──────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved to: {OUT}")
cd /home/daytona/workspace/glomerulo-pdf && python make_pdf.py 2>&1
~/glomerulo-pdf/make_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/glomerulo-pdf/make_pdf.py'
cd /home/daytona/workspace/glomerulo-pdf && python make_pdf.py 2>&1
~/glomerulo-pdf/make_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/glomerulo-pdf/make_pdf.py'
cd /home/daytona/workspace/glomerulo-pdf && python make_pdf.py 2>&1
ls -lh /home/daytona/workspace/glomerulo-pdf/Glomerular_Quick_Reference.pdf