{
  "filename": "plot_4.png",
  "iteration": 2,
  "description": "GTEx v8 tissue distribution of PNLIP and the pancreatic lipase repertoire expression levels",
  "timestamp": "2026-11-29 00:02:05",
  "code": "\nimport requests, pandas as pd, numpy as np, json\nimport matplotlib.pyplot as plt\n# GTEx needs versioned gencodeId; look it up first\ns=requests.get(\"https://gtexportal.org/api/v2/reference/gene\",params={\"geneId\":\"PNLIP\"},timeout=60).json()\ngid=[x for x in s[\"data\"] if x[\"geneSymbol\"]==\"PNLIP\"][0][\"gencodeId\"]\nprint(\"gencodeId:\",gid)\nj=requests.get(\"https://gtexportal.org/api/v2/expression/medianGeneExpression\",\n    params={\"gencodeId\":gid,\"datasetId\":\"gtex_v8\",\"itemsPerPage\":200},timeout=90).json()\nd=pd.DataFrame(j[\"data\"]).sort_values(\"median\",ascending=False)\nprint(\"\\nGTEx v8 PNLIP median TPM, top 8 tissues:\")\nprint(d[[\"tissueSiteDetailId\",\"median\"]].head(8).to_string(index=False))\npan=d[\"median\"].max(); nxt=d[\"median\"].iloc[1]\nprint(f\"\\nPancreas {pan:,.0f} TPM; next tissue {d['tissueSiteDetailId'].iloc[1]} {nxt:,.2f} TPM -> {pan/max(nxt,1e-9):,.0f}-fold enrichment\")\nprint(\"Tissues with median TPM < 1:\", int((d['median']<1).sum()), \"of\", len(d))\n\n# Figure: lipase repertoire in pancreas + PNLIP tissue restriction\nhp={\"PNLIP\":419355.6,\"CLPS\":246873.6,\"CEL\":104264.8,\"PLA2G1B\":110913.6,\"PNLIPRP1\":10208.0,\"PNLIPRP2\":8150.3}\nfig,axes=plt.subplots(1,2,figsize=(14,5.2))\nax=axes[0]\nk=list(hp); v=[hp[x] for x in k]\ncols=[\"#C44E52\" if x==\"PNLIP\" else (\"#DD8452\" if x==\"CLPS\" else \"#4C72B0\") for x in k]\nax.barh(k,v,color=cols); ax.invert_yaxis(); ax.set_xscale(\"log\")\nfor i,(a,b) in enumerate(zip(k,v)): ax.text(b*1.1,i,f\"{b:,.0f}\",va=\"center\",fontsize=9)\nax.set_xlabel(\"pancreas nTPM (Human Protein Atlas consensus)\")\nax.set_title(\"PNLIP is the most abundant transcript in human pancreas;\\ncolipase (CLPS) is co-expressed at similar level\")\nax.set_xlim(5e3,2e6)\n\nax=axes[1]\ntop=d.head(10).iloc[::-1]\nax.barh(top[\"tissueSiteDetailId\"],top[\"median\"]+0.01,color=[\"#C44E52\" if t==\"Pancreas\" else \"#AAAAAA\" for t in top[\"tissueSiteDetailId\"]])\nax.set_xscale(\"log\"); ax.set_xlabel(\"GTEx v8 median TPM (log scale)\")\nax.set_title(f\"PNLIP expression is restricted to pancreas\\n({pan:,.0f} TPM vs {nxt:,.2f} TPM in the next tissue)\")\nplt.tight_layout(); plt.show()\nglobals()['gtex_pnlip']=d\n",
  "plot_number": 4
}