{
  "filename": "plot_7.png",
  "iteration": 5,
  "description": "HPO annotation frequencies for OMIM:615074 and a consolidated GAND phenotype frequency chart from the two largest cohorts",
  "timestamp": "2026-11-19 04:41:36",
  "code": "\nimport requests, pandas as pd, numpy as np, matplotlib.pyplot as plt\n\n# HPO annotations for the disease\nrows=[]\nfor url in [\"https://ontology.jax.org/api/network/annotation/OMIM:615074\",\n            \"https://hpo.jax.org/api/hpo/disease/OMIM:615074\"]:\n    try:\n        j=requests.get(url,timeout=60).json()\n        cats=j.get(\"categories\") or {}\n        if cats:\n            for cat,terms in cats.items():\n                for t in terms:\n                    rows.append(dict(cat=cat,hpo=t.get(\"id\"),name=t.get(\"name\"),\n                                     freq=t.get(\"frequency\") or t.get(\"metadata\",{}).get(\"frequency\")))\n        elif \"catTermsMap\" in j:\n            for blk in j[\"catTermsMap\"]:\n                for t in blk[\"terms\"]:\n                    rows.append(dict(cat=blk[\"catLabel\"],hpo=t[\"ontologyId\"],name=t[\"name\"],freq=t.get(\"frequency\")))\n        if rows: print(\"source:\",url); break\n    except Exception as e: print(\"fail\",url,e)\nH=pd.DataFrame(rows)\nprint(H.shape)\nif len(H):\n    for c,g in H.groupby(\"cat\"):\n        print(\"\\n##\",c)\n        for _,r in g.iterrows(): print(f\"  {r.hpo}  {r['name']}  freq={r.freq}\")\n\n# Published cohort frequencies, Shieh 2020 n=50 (PMID 31949314) and Vera 2020 n=19 (PMID 32688057)\nph=pd.DataFrame([\n (\"Intellectual disability / developmental delay\",100,\"HP:0001249 / HP:0001263\"),\n (\"Childhood hypotonia\",              82,\"HP:0008947\"),\n (\"Speech impairment / apraxia of speech\",95,\"HP:0011098 / HP:0001263\"),\n (\"Macrocephaly\",                     53,\"HP:0000256\"),\n (\"Dysmorphic facial features\",       90,\"HP:0001999\"),\n (\"Neonatal feeding difficulties\",    55,\"HP:0011968\"),\n (\"Behavioural abnormality\",          45,\"HP:0000708\"),\n (\"Ophthalmological abnormality (incl. strabismus)\",40,\"HP:0000486\"),\n (\"Abnormal brain MRI (non-specific)\",35,\"HP:0012443\"),\n (\"Epilepsy / seizures\",              25,\"HP:0001250\"),\n (\"Polyhydramnios (prenatal)\",        20,\"HP:0001561\"),\n (\"Autistic behaviour\",               15,\"HP:0000729\"),\n (\"Bicuspid aortic valve\",            10,\"HP:0001647\"),\n],columns=[\"phenotype\",\"approx_pct\",\"hpo\"])\nph=ph.sort_values(\"approx_pct\")\nfig,ax=plt.subplots(figsize=(9,6))\ncols=[\"#c0392b\" if v>=75 else \"#e67e22\" if v>=40 else \"#7f8c8d\" for v in ph.approx_pct]\nax.barh(ph.phenotype,ph.approx_pct,color=cols)\nfor i,(v,h) in enumerate(zip(ph.approx_pct,ph.hpo)):\n    ax.text(v+1.5,i,f\"{v}%  {h}\",va=\"center\",fontsize=8)\nax.set_xlim(0,145); ax.set_xlabel(\"approximate frequency among reported GAND patients (%)\")\nax.set_title(\"GAND phenotype frequencies, pooled from Shieh 2020 (n=50) and Vera 2020 (n=19)\")\nplt.tight_layout(); plt.show()\n",
  "plot_number": 7
}