{
  "filename": "plot_7.png",
  "iteration": 5,
  "description": "Four-panel evidence summary: differential diagnosis by polyp burden, HPO phenotype frequencies with Wilson CIs, the predicted-versus-reported penetrance gap, and the ClinVar interpretation burden",
  "timestamp": "2026-11-26 20:06:35",
  "code": "\nimport pandas as pd, numpy as np\nimport matplotlib.pyplot as plt\nimport requests, time\n\n# ---------------- Differential diagnosis matrix for adenomatous polyposis ----------------\ndd = pd.DataFrame([\n # gene, inheritance, typical polyp count, onset decade, molecular signature, extracolonic hallmark\n (\"MSH3\",  \"AR\", \"18-54\",      5, \"EMAST, MSS on 5-marker panel\", \"duodenal adenomas, breast ca (n small)\"),\n (\"APC\",   \"AD\", \">100 (classic)\", 2, \"none (CIN)\",               \"desmoid, CHRPE, osteoma, hepatoblastoma\"),\n (\"APC (AFAP)\",\"AD\",\"10-99\",   4, \"none (CIN)\",                   \"duodenal adenomas, gastric fundic gland\"),\n (\"MUTYH\", \"AR\", \"10-100\",     5, \"C:G>A:T transversions, SBS18/36\",\"duodenal adenomas, sebaceous tumours\"),\n (\"NTHL1\", \"AR\", \"8-50\",       5, \"C>T at CpC, SBS30\",            \"breast ca, multi-tumour spectrum\"),\n (\"MSH2/MLH1\",\"AD\",\"0-few\",    4, \"MSI-H, dMMR IHC loss\",         \"endometrial, urothelial, sebaceous\"),\n (\"POLE/POLD1\",\"AD\",\"10-100\",  4, \"ultramutation, POLE exo domain\",\"brain, endometrial (POLD1)\"),\n (\"MBD4\",  \"AR\", \"10-50\",      4, \"CpG>TpG hypermutation, SBS1\",  \"uveal melanoma, AML\"),\n (\"AXIN2\", \"AD\", \"variable\",   4, \"none\",                          \"oligodontia, ectodermal dysplasia\"),\n (\"RNF43\", \"AD\", \"serrated\",   5, \"RNF43 LoF, Wnt hyperactivation\",\"serrated polyposis\"),\n], columns=[\"gene\",\"inh\",\"polyps\",\"onset_decade\",\"signature\",\"extracolonic\"])\n\nprint(dd.to_string(index=False))\n\n# ---------------- Figure: positioning of MSH3 polyposis among the differentials ----------------\nfig = plt.figure(figsize=(16, 9.5))\ngs = fig.add_gridspec(2, 2, height_ratios=[1, 1.05], hspace=0.38, wspace=0.26)\n\n# Panel A: polyp burden vs inheritance\nax = fig.add_subplot(gs[0,0])\nlo = [18,100,10,10,8,0,10,10,5,5]\nhi = [54,1000,99,100,50,5,100,50,50,50]\nypos = np.arange(len(dd))[::-1]\ncols = [\"#C44E52\" if g==\"MSH3\" else (\"#4C72B0\" if i==\"AR\" else \"#8C8C8C\") for g,i in zip(dd.gene, dd.inh)]\nfor y,l,h,c in zip(ypos, lo, hi, cols):\n    ax.plot([l,h],[y,y], lw=7, color=c, solid_capstyle=\"round\", alpha=0.85)\nax.set_yticks(ypos); ax.set_yticklabels([f\"{g} ({i})\" for g,i in zip(dd.gene, dd.inh)], fontsize=9)\nax.set_xscale(\"log\"); ax.set_xlabel(\"cumulative adenoma count (log scale)\")\nax.set_title(\"A. MSH3 polyposis sits in the attenuated range (18-54 adenomas),\\noverlapping MUTYH, NTHL1 and attenuated APC\", fontsize=10.5)\nax.axvspan(10, 99, color=\"#f0e68c\", alpha=0.18)\nax.text(32, len(dd)-0.4, \"attenuated range\", ha=\"center\", fontsize=8.5, color=\"#8a7500\")\n\n# Panel B: phenotype frequencies with Wilson CIs (15-patient census)\nfrom statsmodels.stats.proportion import proportion_confint\npheno = pd.DataFrame([\n (\"HP:0005227 adenomatous colonic polyposis\",15,15),\n (\"HP:0003003 colon cancer\",4,15),\n (\"HP:0004783 duodenal polyposis\",4,15),\n (\"HP:0001399 hepatic cysts\",4,15),\n (\"HP:0003002 breast carcinoma (women)\",3,5),\n (\"HP:0000107 renal cyst\",2,15),\n (\"HP:0033770 gastric adenocarcinoma\",1,15),\n (\"HP:0009592 astrocytoma\",1,15),\n (\"HP:0002671 basal cell carcinoma\",1,15),\n], columns=[\"hpo\",\"k\",\"n\"])\npheno[\"p\"]=pheno.k/pheno.n\nci=[proportion_confint(k,n,method=\"wilson\") for k,n in zip(pheno.k,pheno.n)]\npheno[\"lo\"]=[c[0] for c in ci]; pheno[\"hi\"]=[c[1] for c in ci]\nax = fig.add_subplot(gs[0,1])\ny=np.arange(len(pheno))[::-1]\nax.errorbar(pheno.p*100, y, xerr=[(pheno.p-pheno.lo)*100,(pheno.hi-pheno.p)*100],\n            fmt=\"o\", color=\"#4C72B0\", ecolor=\"#aab7d0\", capsize=3, markersize=7)\nax.set_yticks(y); ax.set_yticklabels(pheno.hpo, fontsize=8.5)\nax.set_xlabel(\"frequency among reported patients (%), Wilson 95% CI\")\nax.set_xlim(-3,105)\nfor yy,k,n in zip(y, pheno.k, pheno.n): ax.text(102, yy, f\"{k}/{n}\", fontsize=8, va=\"center\", ha=\"right\", color=\"#555\")\nax.set_title(\"B. Phenotype frequencies from the full 15-patient census.\\nEvery interval is wide: n is the limiting factor\", fontsize=10.5)\n\n# Panel C: the penetrance gap\nax = fig.add_subplot(gs[1,0])\ncats=[\"predicted biallelic\\nindividuals worldwide\\n(gnomAD v4, HWE)\",\"published patients\\n(6 families, 5 reports)\"]\nvals=[7000, 15]\nb=ax.bar(cats, vals, color=[\"#8C8C8C\",\"#C44E52\"], width=0.55)\nax.set_yscale(\"log\"); ax.set_ylabel(\"individuals (log scale)\")\nfor r,v in zip(b, vals): ax.text(r.get_x()+r.get_width()/2, v*1.35, f\"{v:,}\", ha=\"center\", fontsize=11, fontweight=\"bold\")\nax.set_title(\"C. A ~470-fold gap between predicted and reported cases:\\nincomplete penetrance, under-ascertainment, or both\", fontsize=10.5)\nax.set_ylim(5, 40000)\n\n# Panel D: ClinVar interpretation burden\nax = fig.add_subplot(gs[1,1])\nlabels=[\"uncertain\\nsignificance\",\"likely\\nbenign\",\"pathogenic +\\nlikely path.\",\"conflicting\",\"benign\"]\nvals=[2996,1601,666,247,133]\ncols=[\"#8C8C8C\",\"#55A868\",\"#C44E52\",\"#DD8452\",\"#55A868\"]\nw=ax.bar(labels, vals, color=cols)\nfor r,v in zip(w, vals): ax.text(r.get_x()+r.get_width()/2, v+60, f\"{v:,}\", ha=\"center\", fontsize=9.5)\nax.set_ylabel(\"ClinVar germline records (n=5,665)\")\nax.set_title(\"D. 52.9% of MSH3 variants are VUS. Of the 666 P/LP alleles,\\n618 truncate the protein and 2 are missense\", fontsize=10.5)\nax.tick_params(axis=\"x\", labelsize=8.5); ax.set_ylim(0,3400)\n\nfig.suptitle(\"MSH3-related attenuated familial adenomatous polyposis (MONDO:0044300, OMIM:617100): evidence summary\",\n             fontsize=13.5, fontweight=\"bold\", y=0.985)\nplt.show()\n",
  "plot_number": 7
}