{
  "filename": "plot_6.png",
  "iteration": 4,
  "description": "Model age-dependent penetrance of ATM genotypes against SEER incidence and test surveillance thresholds",
  "timestamp": "2026-11-26 21:21:13",
  "code": "\nimport numpy as np, pandas as pd\nimport matplotlib.pyplot as plt\n\n# SEER 22 female breast cancer age-specific incidence, cases per 100,000 per year\n# (SEER*Explorer, invasive female breast cancer, all races, 2017-2021; values rounded)\nages  = np.array([20,25,30,35,40,45,50,55,60,65,70,75,80])\nrates = np.array([1.4,8.1,24.6,54.0,109.1,174.0,221.6,265.5,345.0,428.0,463.0,447.0,413.0])/1e5\n\n# Relative risks for germline ATM genotypes (female breast cancer)\n# CARRIERS population-based case-control, ATM protein-truncating: OR 2.10 (95% CI 1.71-2.57)  PMID 33471974\n# BRIDGES, ATM PTV: OR 2.10 (95% CI 1.71-2.59)                                                PMID 33471991-class estimate\n# ATM c.7271T>G missense (dominant negative): RR ~ 4-6 in family-based series                 PMID 12195425 / 10814674\nGENO = {\"Non-carrier (SEER baseline)\": (1.00, 1.00, 1.00),\n        \"ATM PTV carrier (OR 2.10)\":   (2.10, 1.71, 2.57),\n        \"ATM c.7271T>G (RR 5.0)\":      (5.00, 4.00, 6.00)}\n\ndef cum_risk(rr):\n    # competing-risk-free cumulative incidence from age 20: 1 - exp(-integral of hazard)\n    h = rates*rr\n    cum = np.concatenate([[0], np.cumsum(h[:-1]*np.diff(ages))])\n    return 1-np.exp(-cum)\n\ncurves={}\nfor k,(rr,lo,hi) in GENO.items():\n    curves[k]=(cum_risk(rr), cum_risk(lo), cum_risk(hi))\n\ntab=pd.DataFrame({k:np.round(100*v[0],1) for k,v in curves.items()}, index=ages)\ntab.index.name=\"age\"\nprint(\"=== Cumulative female breast cancer risk (%) by age and ATM genotype ===\")\nprint(tab.to_string())\nfor k,(m,lo,hi) in curves.items():\n    print(f\"{k:32s} risk by 80: {100*m[-1]:.1f}% (95% CI {100*lo[-1]:.1f}-{100*hi[-1]:.1f})\"\n          f\" | by 50: {100*m[list(ages).index(50)]:.1f}%\")\n\n# --- Surveillance threshold: at what age does an ATM PTV carrier reach the\n#     cumulative risk a non-carrier only reaches at age 50 (the usual mammography start)?\nbase50 = curves[\"Non-carrier (SEER baseline)\"][0][list(ages).index(50)]\nfor k in [\"ATM PTV carrier (OR 2.10)\",\"ATM c.7271T>G (RR 5.0)\"]:\n    m=curves[k][0]\n    a=np.interp(base50, m, ages)\n    print(f\"{k:32s} reaches the age-50 population risk ({100*base50:.2f}%) at age {a:.1f}\")\n\n# --- NCCN uses a 20% lifetime threshold for annual breast MRI ---\nfor k,(m,lo,hi) in curves.items():\n    if m[-1]>=0.20:\n        print(f\"{k}: crosses the 20% lifetime threshold for MRI surveillance \"\n              f\"(risk by 80 = {100*m[-1]:.1f}%)\")\n    else:\n        print(f\"{k}: stays below the 20% lifetime MRI threshold ({100*m[-1]:.1f}%)\")\n\n# --- figure ---\nfig,axes=plt.subplots(1,2,figsize=(14,5.5))\nax=axes[0]\ncols={\"Non-carrier (SEER baseline)\":\"#888888\",\"ATM PTV carrier (OR 2.10)\":\"#4878a8\",\"ATM c.7271T>G (RR 5.0)\":\"#c44e52\"}\nfor k,(m,lo,hi) in curves.items():\n    ax.plot(ages,100*m,lw=2.2,color=cols[k],label=k)\n    ax.fill_between(ages,100*lo,100*hi,color=cols[k],alpha=0.15)\nax.axhline(20,ls=\"--\",c=\"k\",lw=1)\nax.text(21,21,\"20% lifetime risk: NCCN threshold for annual breast MRI\",fontsize=8)\nax.axvline(40,ls=\":\",c=\"k\",lw=1); ax.text(40.5,2,\"age 40\",fontsize=8,rotation=90)\nax.set_xlabel(\"Age (years)\"); ax.set_ylabel(\"Cumulative breast cancer risk (%)\")\nax.set_title(\"Age-dependent penetrance of germline ATM genotypes\\nSEER age-specific incidence scaled by genotype relative risk\",fontsize=11)\nax.legend(fontsize=9,loc=\"upper left\"); ax.grid(alpha=0.3)\n\nax2=axes[1]\n# organ-specific relative risks from published case-control series\norg=pd.DataFrame({\n \"site\":[\"Breast (female)\",\"Pancreas\",\"Prostate (aggressive)\",\"Ovary\",\"Colorectal\",\"Gastric\",\"Melanoma\"],\n \"or\":[2.10,4.21,2.58,1.57,1.23,2.0,1.1],\n \"lo\":[1.71,3.24,1.78,1.21,0.9,1.1,0.7],\n \"hi\":[2.57,5.47,3.75,2.03,1.7,3.6,1.7]})\norg=org.sort_values(\"or\")\ny=np.arange(len(org))\nax2.errorbar(org[\"or\"],y,xerr=[org[\"or\"]-org[\"lo\"],org[\"hi\"]-org[\"or\"]],\n             fmt=\"o\",color=\"#4878a8\",capsize=4,ms=7)\nax2.axvline(1,c=\"k\",lw=1)\nax2.set_yticks(y); ax2.set_yticklabels(org[\"site\"],fontsize=10)\nax2.set_xscale(\"log\"); ax2.set_xticks([0.7,1,2,3,5]); ax2.set_xticklabels([\"0.7\",\"1\",\"2\",\"3\",\"5\"])\nax2.set_xlabel(\"Odds ratio / relative risk (log scale)\")\nax2.set_title(\"Organ specificity of ATM heterozygote cancer risk\\npoint estimate with 95% CI\",fontsize=11)\nax2.grid(axis=\"x\",alpha=0.3)\nplt.tight_layout(); plt.show()\n",
  "plot_number": 6
}