Download code/09_calibration.py from HarriziSaad/BULMA: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/datasets/HarriziSaad/BULMA/resolve/main/code/09_calibration.py
- Command line
-
hf download hf://datasets/HarriziSaad/BULMA/code/09_calibration.py
-
curl -L -o 09_calibration.py https://huggingface.co/datasets/HarriziSaad/BULMA/resolve/main/code/09_calibration.py
1.47 kB
| import numpy as np | |
| import pandas as pd | |
| from scipy import stats | |
| from common import RES, hom, axes, centre, effects, abc | |
| TARGET = "YPL270W" | |
| Z = hom() | |
| _, ox, os_, _ = axes(Z.columns) | |
| e_ox, e_os = effects(centre(Z), ox, os_) | |
| cd = (e_ox - e_os).abs().dropna() | |
| tail = (cd >= cd[TARGET]).mean() | |
| pct = stats.percentileofscore(cd.values, cd[TARGET]) | |
| A = abc() | |
| abc_cd = cd.reindex(A.systematic).dropna() | |
| others = cd.drop(abc_cd.index) | |
| mw = stats.mannwhitneyu(abc_cd.values, others.values, alternative="greater") | |
| pd.DataFrame({"gene": A.set_index("systematic").gene.reindex(abc_cd.index).values, | |
| "cd": abc_cd.round(3).values}).to_csv(RES / "abc_cd.csv", index=False) | |
| pd.DataFrame({"what": ["MDL2_cd", "reference_p90"], | |
| "value": [round(cd[TARGET], 3), round(np.percentile(cd.values, 90), 3)]} | |
| ).to_csv(RES / "mdl2_reference_markers.csv", index=False) | |
| pd.DataFrame({"cd": cd.values}, index=cd.index).rename_axis("gene").to_csv(RES / "null_cd.csv") | |
| pd.DataFrame([("MDL2 |cd|", cd[TARGET]), ("reference tail fraction (all analysed genes)", tail), | |
| ("reference percentile (all analysed genes)", pct), ("reference size", len(cd)), | |
| ("ABC vs other genes Mann-Whitney U", mw.statistic), ("ABC vs other genes p (one-sided)", mw.pvalue), | |
| ("ABC transporters", len(abc_cd)), ("other genes", len(others))], | |
| columns=["quantity", "value"]).to_csv(RES / "calibration_summary.csv", index=False) | |