Show code
import os, json, time, hashlib
import pandas as pd, requests
REPO = os.environ.get("PIGNET_REPO", os.path.abspath(os.path.join(os.getcwd(), "..", "..", "..")))
CG = os.path.join(REPO, "comparative-genomics")
# --- Provenance manifest: every raw input, where it comes from, and how to regenerate it. ---
# (mirrors the repo-level DATA_SOURCES.md; keep in sync if a source changes)
INPUTS = {
"network_nodes": {
"path": "comparative-genomics/analysis/data/pigmentation_network_nodes.csv",
"notebook": "NB07 (07_harmonized_substrate.ipynb) — byte-identical frozen copy of nb7_substrate_nodes.csv",
"what": "803-node curated pigmentation network with per-gene evidence layers "
"(supporting_layers, omim_phenotype_class, massspec_detected_flag, bajpai_hit_flag)",
"source": "DATA_SOURCES.md entries 5 (Raghunath 2015), 2 (Bajpai 2023 CRISPR), "
"6/7 (OMIM/MGI/ZFIN/GO + D'Arcy 2023 STRING/mass-spec), 6c (KEGG hsa04916)",
"produced_by": "Notebooks 1-7 (network assembly); this notebook only reads it",
},
"hormone_axes": {
"path": "comparative-genomics/analysis/data/hormone_axes.csv",
"notebook": "NB13 (13_sex_hormone_layer.ipynb) — KEGG pathway pull + design-added receptors/cofactors",
"what": "53 sex-hormone genes labeled by endocrine axis (steroid biosynthesis, HPG, "
"androgen/estrogen receptor, GnRH, coactivators)",
"source": "Seeded from KEGG steroid hormone biosynthesis (hsa00140, 27 genes) + KEGG GnRH signaling (hsa04912, 8 genes), plus androgen/estrogen receptor->target genes (AR, ESR1/2, GPER1, FSHR, LHCGR) and steroid-signaling cofactors/carriers (NCOA1/2/3, NCOR1/2, SHBG, FKBP5, SCARB1, LDLR, STAR, KISS1/1R) added per design; then axis-annotated",
"produced_by": "Notebook 13 (sex-hormone layer)",
},
"baxter": {
"path": "data/processed/baxter2018_650_pigmentation_genes.csv",
"notebook": "NB01b (01b_extract_baxter_genes.ipynb) — extracts Baxter Table S7",
"what": "Baxter 2019 curated cross-species pigmentation reference (Table S7; 635 unique human symbols)",
"source": "DATA_SOURCES.md entry 3 + docs/specs/baxter2018.spec.md "
"(Baxter et al. 2019, Pigment Cell Melanoma Res 32:348, doi:10.1111/pcmr.12743)",
"produced_by": "derived CSV from author-supplied Table S7; raw .xlsx git-ignored, re-obtain via DOI",
},
}
def load_input(key):
"""Load a manifest input, printing its provenance and a checksum of the exact bytes read."""
m = INPUTS[key]; fp = os.path.join(REPO, m["path"])
raw = open(fp, "rb").read()
sha = hashlib.sha256(raw).hexdigest()[:16]
df = pd.read_csv(fp)
print(f"[{key}] {m['path']}")
print(f" notebook : {m['notebook']}")
print(f" what : {m['what']}")
print(f" source : {m['source']}")
print(f" produced : {m['produced_by']}")
print(f" loaded : {df.shape[0]} rows x {df.shape[1]} cols | sha256[:16]={sha}\n")
return df
NET = load_input("network_nodes")
HAX = load_input("hormone_axes")
BAX = load_input("baxter")
BAX_GENES = set(BAX["Human gene symbol"].dropna().astype(str).str.strip())
# --- The panel this notebook MOTIVATES (output/reference, not a raw evidence input). ---
# Loaded only to (a) find network genes not yet in the scan and (b) measure module balance.
SCAN_PANEL_PATH = "comparative-genomics/config/gene_panel.csv"
SCAN_PANEL = pd.read_csv(os.path.join(REPO, SCAN_PANEL_PATH))
_sha = hashlib.sha256(open(os.path.join(REPO, SCAN_PANEL_PATH), "rb").read()).hexdigest()[:16]
IN_PANEL = set(SCAN_PANEL.gene)
print(f"[SCAN_PANEL — output this notebook justifies] {SCAN_PANEL_PATH}")
print(f" composite: hormone set == hormone_axes.csv (KEGG-seeded); pigmentation set = 27 melanogenesis-core (NB07 network + Nadeau anchor)")
print(f" loaded : {SCAN_PANEL.shape[0]} genes ({(SCAN_PANEL.set=='pigmentation').sum()} pigmentation + {(SCAN_PANEL.set=='hormone').sum()} hormone) | sha256[:16]={_sha}\n")
print(f"network nodes: {len(NET)} | genes already in scan panel: {len(IN_PANEL)} | Baxter reference: {len(BAX_GENES)}")[network_nodes] comparative-genomics/analysis/data/pigmentation_network_nodes.csv
notebook : NB07 (07_harmonized_substrate.ipynb) — byte-identical frozen copy of nb7_substrate_nodes.csv
what : 803-node curated pigmentation network with per-gene evidence layers (supporting_layers, omim_phenotype_class, massspec_detected_flag, bajpai_hit_flag)
source : DATA_SOURCES.md entries 5 (Raghunath 2015), 2 (Bajpai 2023 CRISPR), 6/7 (OMIM/MGI/ZFIN/GO + D'Arcy 2023 STRING/mass-spec), 6c (KEGG hsa04916)
produced : Notebooks 1-7 (network assembly); this notebook only reads it
loaded : 803 rows x 17 cols | sha256[:16]=4053c652a8d4f832
[hormone_axes] comparative-genomics/analysis/data/hormone_axes.csv
notebook : NB13 (13_sex_hormone_layer.ipynb) — KEGG pathway pull + design-added receptors/cofactors
what : 53 sex-hormone genes labeled by endocrine axis (steroid biosynthesis, HPG, androgen/estrogen receptor, GnRH, coactivators)
source : Seeded from KEGG steroid hormone biosynthesis (hsa00140, 27 genes) + KEGG GnRH signaling (hsa04912, 8 genes), plus androgen/estrogen receptor->target genes (AR, ESR1/2, GPER1, FSHR, LHCGR) and steroid-signaling cofactors/carriers (NCOA1/2/3, NCOR1/2, SHBG, FKBP5, SCARB1, LDLR, STAR, KISS1/1R) added per design; then axis-annotated
produced : Notebook 13 (sex-hormone layer)
loaded : 53 rows x 2 cols | sha256[:16]=bba7cfd487770220
[baxter] data/processed/baxter2018_650_pigmentation_genes.csv
notebook : NB01b (01b_extract_baxter_genes.ipynb) — extracts Baxter Table S7
what : Baxter 2019 curated cross-species pigmentation reference (Table S7; 635 unique human symbols)
source : DATA_SOURCES.md entry 3 + docs/specs/baxter2018.spec.md (Baxter et al. 2019, Pigment Cell Melanoma Res 32:348, doi:10.1111/pcmr.12743)
produced : derived CSV from author-supplied Table S7; raw .xlsx git-ignored, re-obtain via DOI
loaded : 659 rows x 12 cols | sha256[:16]=1c1ce3cf945dabb4
[SCAN_PANEL — output this notebook justifies] comparative-genomics/config/gene_panel.csv
composite: hormone set == hormone_axes.csv (KEGG-seeded); pigmentation set = 27 melanogenesis-core (NB07 network + Nadeau anchor)
loaded : 80 genes (27 pigmentation + 53 hormone) | sha256[:16]=b3dc6fe918f64694
network nodes: 803 | genes already in scan panel: 80 | Baxter reference: 635



