{
  "filename": "plot_7.png",
  "iteration": 4,
  "description": "Audit ClinVar coverage of PNLIP: classification spectrum, class of P/LP alleles, and whether published CPLD variants are deposited",
  "timestamp": "2026-11-29 00:12:42",
  "code": "\nimport requests, time, re, pandas as pd, numpy as np, matplotlib.pyplot as plt\nE=\"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/\"\nids=requests.get(E+\"esearch.fcgi\",params=dict(db=\"clinvar\",term=\"PNLIP[gene]\",retmax=500,retmode=\"json\"),timeout=60).json()[\"esearchresult\"][\"idlist\"]\nrecs=[]\nfor i in range(0,len(ids),100):\n    s=requests.get(E+\"esummary.fcgi\",params=dict(db=\"clinvar\",id=\",\".join(ids[i:i+100]),retmode=\"json\"),timeout=90).json()[\"result\"]\n    for k in s.get(\"uids\",[]):\n        r=s[k]; gs=r.get(\"germline_classification\",{}) or {}\n        recs.append(dict(title=r.get(\"title\"), clin=gs.get(\"description\"), review=gs.get(\"review_status\"),\n                         cond=\";\".join(sorted({t.get(\"trait_name\",\"\") for t in (gs.get(\"trait_set\") or [])}))))\n    time.sleep(0.35)\ncv=pd.DataFrame(recs)\nsmall=cv[cv.title.astype(str).str.startswith(\"NM_000936\")].copy()\ncnv=cv[~cv.title.astype(str).str.startswith(\"NM_000936\")]\nprint(f\"ClinVar PNLIP: {len(cv)} records = {len(small)} PNLIP small variants + {len(cnv)} large 10q CNVs spanning the gene\")\nprint(\"\\nSmall-variant germline classifications:\"); print(small.clin.value_counts().to_string())\nplp=small[small.clin.isin([\"Pathogenic\",\"Likely pathogenic\"])].copy()\ndef cls(t):\n    if \"Ter\" in t: return \"nonsense\"\n    if \"fs\" in t: return \"frameshift\"\n    if re.search(r\"c\\.\\d+[-+]\\d*[ACGT]?>?[ACGT]?$|c\\.\\d+[-+]\", t): return \"splice\"\n    return \"missense/other\"\nplp[\"kind\"]=plp.title.map(cls)\nprint(f\"\\n{len(plp)} P/LP small variants, by class:\"); print(plp.kind.value_counts().to_string())\nprint(\"\\nP/LP records carrying a disease label:\")\nlab=plp[plp.cond.astype(str).str.contains(\"ancreat|PNLIP\",na=False)]\nprint(lab[[\"title\",\"clin\",\"review\",\"cond\"]].to_string(index=False) if len(lab) else \"  none\")\nlit={\"p.Ser290Asn c.869G>A (Curry 2025, Amish CPLD)\":\"869G>A\",\n     \"p.Thr221Met c.662C>T (CPLD + mouse CP model)\":\"662C>T\",\n     \"p.Phe300Leu (protease-sensitive, CP)\":\"900C>\",\n     \"p.Ile265Arg (protease-sensitive, CP)\":\"794T>\",\n     \"p.Ala433Thr (protease-sensitive, CP)\":\"1297G>\",\n     \"p.Ala174Pro (misfolding)\":\"520G>\",\n     \"p.Gly233Glu (misfolding)\":\"698G>\",\n     \"p.Cys254Arg (misfolding)\":\"760T>\",\n     \"p.Val454Phe (misfolding)\":\"1360G>\"}\nprint(\"\\nAre the literature PNLIP alleles in ClinVar?\")\nfor l,p in lit.items():\n    h=small[small.title.astype(str).str.contains(p,na=False,regex=False)]\n    print(f\"  {l:48s} -> \" + (\" | \".join(f\"{x.title} [{x.clin}]\" for x in h.itertuples()) if len(h) else \"ABSENT\"))\n\nfig,axes=plt.subplots(1,2,figsize=(12.5,4.8))\no=[\"Pathogenic\",\"Likely pathogenic\",\"Conflicting classifications of pathogenicity\",\"Uncertain significance\",\"Likely benign\",\"Benign/Likely benign\",\"Benign\"]\nvals=[int((small.clin==k).sum()) for k in o]\naxes[0].bar(range(len(o)),vals,color=[\"#C44E52\",\"#E08A8A\",\"#DDAA55\",\"#9AA0A6\",\"#8FB8DE\",\"#6E9BC5\",\"#4C72B0\"])\naxes[0].set_xticks(range(len(o))); axes[0].set_xticklabels([k.replace(\" classifications of pathogenicity\",\"\") for k in o],rotation=35,ha=\"right\",fontsize=8)\naxes[0].set_ylabel(\"ClinVar records\"); axes[0].set_title(f\"PNLIP small variants in ClinVar (n={len(small)})\")\nfor i,v in enumerate(vals): axes[0].text(i,v+2,str(v),ha=\"center\",fontsize=9)\nkc=plp.kind.value_counts()\naxes[1].bar(range(len(kc)),kc.values,color=\"#C44E52\")\naxes[1].set_xticks(range(len(kc))); axes[1].set_xticklabels(kc.index,rotation=20,ha=\"right\",fontsize=9)\naxes[1].set_ylabel(\"records\"); axes[1].set_title(f\"Class of the {len(plp)} pathogenic / likely pathogenic\\nPNLIP small variants\")\nfor i,v in enumerate(kc.values): axes[1].text(i,v+0.1,str(v),ha=\"center\",fontsize=9)\nplt.tight_layout(); plt.show()\n",
  "plot_number": 7
}