Download code/src/analysis/scan_report.py from bryan7264/lorapop: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/datasets/bryan7264/lorapop/resolve/main/code/src/analysis/scan_report.py
- Command line
-
hf download hf://datasets/bryan7264/lorapop/code/src/analysis/scan_report.py
-
curl -L -o scan_report.py https://huggingface.co/datasets/bryan7264/lorapop/resolve/main/code/src/analysis/scan_report.py
1.69 kB
| # MIT License, Bryan Cheng, 2026. | |
| """Text summary of a scan directory: population sizes, lambda_GC and hit counts per estimator, null diagnostics, | |
| descent variance share (python src/analysis/scan_report.py [scan_dir]).""" | |
| import sys | |
| import json, numpy as np | |
| S = json.load(open((sys.argv[1] if len(sys.argv) > 1 else "results/scans/qwen05") + "/summary.json")) | |
| print({k: S[k] for k in ("n", "n_loci", "M_eff", "bonferroni_p", "n_eff_desc", "n_eff_func", "n_desc_families", "n_recipe_families", "share_with_relative", "split_sizes")}) | |
| E = ["naive", "pc", "mm_f", "mm_fd", "wf_d", "wf_r", "dup_afe"] | |
| T = S["traits"] | |
| prim = [t for t in T if not t.startswith("__")] | |
| for t in [x for x in T if x.startswith("__")]: | |
| print(t, {e: round(T[t]["lambda_gc"][e], 2) for e in E}, "bonf", T[t]["hits_bonf_full"], "fdrD", T[t]["hits_fdr_D"]) | |
| lam = np.array([[T[t]["lambda_gc"][e] for e in E] for t in prim]) | |
| print("median lambda over", len(prim), "traits", dict(zip(E, np.round(np.median(lam, 0), 2)))) | |
| print("max lambda", dict(zip(E, np.round(lam.max(0), 2))), "min", dict(zip(E, np.round(lam.min(0), 2)))) | |
| print("traits with lambda_naive>1.1:", int((lam[:, 0] > 1.1).sum())) | |
| hb = np.array([[T[t]["hits_bonf_full"][e] for e in E] for t in prim]); hf = np.array([[T[t]["hits_fdr_D"][e] for e in E] for t in prim]) | |
| print("total bonf hits", dict(zip(E, hb.sum(0))), "\ntotal fdr D hits", dict(zip(E, hf.sum(0)))) | |
| vd = [] | |
| for t in prim: | |
| v = T[t]["variance_components_full"].get("mm_fd", {}) | |
| for b, c in v.items(): | |
| vd.append(c[1] / sum(c)) | |
| vd = np.array(vd); print("mm_fd descent VC share: median", np.median(vd).round(4), "share>0.01", (vd > 0.01).mean().round(3), "max", vd.max().round(3)) | |