{
  "filename": "plot_3.png",
  "iteration": 3,
  "description": "Reconcile gnomAD-predicted ABAT disease burden with reported case counts; quantify CSF biomarker fold changes and residual enzyme activity",
  "timestamp": "2026-11-28 20:33:52",
  "code": "\nimport requests, json\nimport pandas as pd, numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import stats\n\nS=requests.Session(); S.headers.update({\"User-Agent\":\"research/1.0\",\"Content-Type\":\"application/json\"})\nq=\"\"\"query { gene(gene_symbol:\"ABAT\", reference_genome:GRCh38){\n variants(dataset: gnomad_r4){ hgvsp lof exome{ac an} genome{ac an} } } }\"\"\"\nvs=S.post(\"https://gnomad.broadinstitute.org/api\",data=json.dumps({\"query\":q}),timeout=300).json()[\"data\"][\"gene\"][\"variants\"]\nrows=[]\nfor v in vs:\n    e=v.get(\"exome\") or {}; g=v.get(\"genome\") or {}\n    ac=(e.get(\"ac\") or 0)+(g.get(\"ac\") or 0); an=(e.get(\"an\") or 0)+(g.get(\"an\") or 0)\n    rows.append(dict(hgvsp=v.get(\"hgvsp\") or \"\", lof=v.get(\"lof\"), af=(ac/an if an else 0.0)))\nG=pd.DataFrame(rows)\nq_lof=G.loc[G.lof==\"HC\",\"af\"].sum()\nplp_mis=[\"p.Pro152Ser\",\"p.Leu211Phe\",\"p.Leu478Pro\",\"p.Arg220Lys\",\"p.Gln296His\",\"p.Arg377Trp\",\n         \"p.Arg92Gln\",\"p.Phe213Cys\",\"p.Gly465Asp\",\"p.Gly465Arg\"]\nq_mis=G.loc[G.hgvsp.isin(plp_mis),\"af\"].sum()\nq_tot=q_lof+q_mis\nBIRTHS=132e6\n\n# ---- Panel A: predicted vs observed ---------------------------------------\nFvals=np.linspace(0,0.04,200)\npred=(q_tot**2*(1-Fvals)+q_tot*Fvals)*BIRTHS\n# observed: 20 distinct patients in the primary case literature over 1984-2026 (42 y)\nobs_rate=20/42.0\n\nfig,ax=plt.subplots(1,3,figsize=(16,4.6))\na=ax[0]\na.plot(Fvals,pred,color=\"#2b6cb0\",lw=2.5,label=\"predicted affected births / year\")\na.axhline(obs_rate,color=\"#c53030\",ls=\"--\",lw=2,label=f\"reported cases / year = {obs_rate:.2f}\")\na.set_yscale(\"log\"); a.set_xlabel(\"population inbreeding coefficient F\")\na.set_ylabel(\"affected births per year (world)\")\na.set_title(\"Predicted genetic burden vs reported cases\")\na.legend(fontsize=8); a.grid(alpha=.3)\nfor F,lab in [(0.0,\"outbred\"),(0.01,\"global mean\"),(0.03,\"high consanguinity\")]:\n    y=(q_tot**2*(1-F)+q_tot*F)*BIRTHS\n    a.plot([F],[y],\"o\",color=\"#2b6cb0\"); a.annotate(lab,(F,y),textcoords=\"offset points\",xytext=(4,6),fontsize=7)\n\n# ---- Panel B: biomarker fold changes in the index case (PMID 6148708) ------\nb=ax[1]\nbm=pd.DataFrame([\n dict(metab=\"CSF free GABA\\n(CHEBI:16865)\", pat=4.8, ctrl_med=0.08),\n dict(metab=\"CSF homocarnosine\\n(CHEBI:27859)\", pat=23.4, ctrl_med=7.6),\n dict(metab=\"CSF beta-alanine\\n(CHEBI:16958)\", pat=0.48, ctrl_med=0.05),\n])\nbm[\"fc\"]=bm.pat/bm.ctrl_med\nbars=b.barh(bm.metab,bm.fc,color=[\"#c53030\",\"#dd6b20\",\"#d69e2e\"])\nfor r,v in zip(bars,bm.fc): b.text(v*1.05,r.get_y()+r.get_height()/2,f\"{v:.0f}x\",va=\"center\",fontsize=9)\nb.set_xscale(\"log\"); b.set_xlim(1,200); b.axvline(1,color=\"k\",lw=1)\nb.set_xlabel(\"fold change vs control median (log scale)\")\nb.set_title(\"CSF biomarkers, index case (PMID 6148708)\")\nb.grid(alpha=.3,axis=\"x\")\n\n# ---- Panel C: residual GABA-T activity -------------------------------------\nc=ax[2]\nact=pd.DataFrame([dict(g=\"patient liver\",v=0.07),dict(g=\"control min\",v=0.31),\n                  dict(g=\"control median\",v=0.38),dict(g=\"control max\",v=0.69)])\nc.bar(act.g,act.v,color=[\"#c53030\",\"#a0aec0\",\"#718096\",\"#a0aec0\"])\nc.axhline(0.31,ls=\":\",color=\"k\",lw=1)\nc.set_ylabel(\"GABA-T activity (umol/mg protein/h)\")\nc.set_title(\"Residual hepatic GABA-T, index case\")\nc.tick_params(axis=\"x\",rotation=20); c.grid(alpha=.3,axis=\"y\")\npct=0.07/0.38*100\nc.text(0,0.09,f\"{pct:.0f}% of\\ncontrol median\",ha=\"center\",fontsize=8)\nplt.tight_layout(); plt.show()\n\nprint(f\"q_total={q_tot:.3e}; carrier 1 in {1/(2*q_tot):,.0f}\")\nprint(\"Predicted affected births/yr: F=0 -> %.1f ; F=0.01 -> %.0f ; F=0.03 -> %.0f\"%(\n      q_tot**2*BIRTHS,(q_tot**2*0.99+q_tot*0.01)*BIRTHS,(q_tot**2*0.97+q_tot*0.03)*BIRTHS))\nprint(\"Observed reported cases/yr (1984-2026):\",round(obs_rate,2))\nprint(\"Ratio predicted/observed at F=0 : %.1f\"%(q_tot**2*BIRTHS/obs_rate))\nprint(\"Residual activity index case: %.1f%% of control median, %.1f%% of control minimum\"%(pct,0.07/0.31*100))\nprint(\"Biomarker fold changes:\"); print(bm[[\"metab\",\"fc\"]].to_string(index=False))\n",
  "plot_number": 3
}