nvpersist 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nvpersist/__init__.py +54 -0
- nvpersist/cli.py +125 -0
- nvpersist/data/nvp_signature.tsv +669 -0
- nvpersist/id_map.py +73 -0
- nvpersist/kinetics.py +171 -0
- nvpersist/neurovascular.py +208 -0
- nvpersist/nv_modules.py +80 -0
- nvpersist/stats.py +407 -0
- nvpersist-1.0.0.dist-info/METADATA +194 -0
- nvpersist-1.0.0.dist-info/RECORD +14 -0
- nvpersist-1.0.0.dist-info/WHEEL +5 -0
- nvpersist-1.0.0.dist-info/entry_points.txt +2 -0
- nvpersist-1.0.0.dist-info/licenses/LICENSE +21 -0
- nvpersist-1.0.0.dist-info/top_level.txt +1 -0
nvpersist/__init__.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""NV-Persist: Cross-compartment temporal & neurovascular injury modeling."""
|
|
2
|
+
|
|
3
|
+
from nvpersist.id_map import HGNCMapper
|
|
4
|
+
from nvpersist.kinetics import (
|
|
5
|
+
classify_kinetic_regimes,
|
|
6
|
+
compute_spi_and_escalation,
|
|
7
|
+
enrich_kinetic_regimes,
|
|
8
|
+
)
|
|
9
|
+
from nvpersist.neurovascular import (
|
|
10
|
+
audit_toxcast_coverage,
|
|
11
|
+
compute_cross_compartment_coupling,
|
|
12
|
+
compute_jnk_epistasis,
|
|
13
|
+
compute_nvp_score,
|
|
14
|
+
directional_nv_concordance,
|
|
15
|
+
load_consensus_signature,
|
|
16
|
+
)
|
|
17
|
+
from nvpersist.nv_modules import NVU_MODULES
|
|
18
|
+
from nvpersist.stats import (
|
|
19
|
+
benjamini_hochberg,
|
|
20
|
+
deseq_size_factors,
|
|
21
|
+
eb_moderated_from_log_matrix,
|
|
22
|
+
fit_f_dist_smyth,
|
|
23
|
+
load_gmt,
|
|
24
|
+
preranked_gsea,
|
|
25
|
+
voom_limma_contrast,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__version__ = "1.0.0"
|
|
29
|
+
__author__ = "Muhammad Khubaib Ahmad"
|
|
30
|
+
__email__ = "khubaib.ahmad@inference-lab.org"
|
|
31
|
+
|
|
32
|
+
__all__ = [
|
|
33
|
+
"__version__",
|
|
34
|
+
"__author__",
|
|
35
|
+
"__email__",
|
|
36
|
+
"HGNCMapper",
|
|
37
|
+
"NVU_MODULES",
|
|
38
|
+
"benjamini_hochberg",
|
|
39
|
+
"deseq_size_factors",
|
|
40
|
+
"fit_f_dist_smyth",
|
|
41
|
+
"voom_limma_contrast",
|
|
42
|
+
"eb_moderated_from_log_matrix",
|
|
43
|
+
"load_gmt",
|
|
44
|
+
"preranked_gsea",
|
|
45
|
+
"compute_spi_and_escalation",
|
|
46
|
+
"classify_kinetic_regimes",
|
|
47
|
+
"enrich_kinetic_regimes",
|
|
48
|
+
"load_consensus_signature",
|
|
49
|
+
"directional_nv_concordance",
|
|
50
|
+
"compute_cross_compartment_coupling",
|
|
51
|
+
"compute_nvp_score",
|
|
52
|
+
"compute_jnk_epistasis",
|
|
53
|
+
"audit_toxcast_coverage",
|
|
54
|
+
]
|
nvpersist/cli.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Command-line interface for NV-Persist."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
import nvpersist
|
|
11
|
+
from nvpersist.kinetics import classify_kinetic_regimes
|
|
12
|
+
from nvpersist.neurovascular import compute_nvp_score, load_consensus_signature
|
|
13
|
+
from nvpersist.nv_modules import NVU_MODULES
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _cmd_info(_args: argparse.Namespace) -> int:
|
|
17
|
+
up, dn, _ = load_consensus_signature()
|
|
18
|
+
payload = {
|
|
19
|
+
"package": "nvpersist",
|
|
20
|
+
"version": nvpersist.__version__,
|
|
21
|
+
"author": nvpersist.__author__,
|
|
22
|
+
"email": nvpersist.__email__,
|
|
23
|
+
"repository": "https://github.com/Inference-LAB/nvpersist",
|
|
24
|
+
"n_nvu_modules": len(NVU_MODULES),
|
|
25
|
+
"consensus_signature": {"up": len(up), "down": len(dn), "total": len(up) + len(dn)},
|
|
26
|
+
}
|
|
27
|
+
print(json.dumps(payload, indent=2))
|
|
28
|
+
return 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _cmd_list_modules(args: argparse.Namespace) -> int:
|
|
32
|
+
if args.module:
|
|
33
|
+
if args.module not in NVU_MODULES:
|
|
34
|
+
print(f"Unknown module '{args.module}'. Available: {', '.join(NVU_MODULES)}", file=sys.stderr)
|
|
35
|
+
return 2
|
|
36
|
+
genes = sorted(NVU_MODULES[args.module])
|
|
37
|
+
print(f"{args.module} ({len(genes)} genes):")
|
|
38
|
+
print(", ".join(genes))
|
|
39
|
+
return 0
|
|
40
|
+
for name, gset in NVU_MODULES.items():
|
|
41
|
+
print(f"{name:45s} ({len(gset):2d} genes)")
|
|
42
|
+
return 0
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _cmd_score(args: argparse.Namespace) -> int:
|
|
46
|
+
df = pd.read_csv(args.de_csv)
|
|
47
|
+
if args.gene_col not in df.columns:
|
|
48
|
+
raise ValueError(f"Expected gene column '{args.gene_col}' in {args.de_csv}")
|
|
49
|
+
if args.z_col not in df.columns:
|
|
50
|
+
raise ValueError(f"Expected z-score column '{args.z_col}' in {args.de_csv}")
|
|
51
|
+
de = df.rename(columns={args.gene_col: "gene", args.z_col: "z_score"})
|
|
52
|
+
res = compute_nvp_score(de, n_boot=args.n_boot, seed=args.seed)
|
|
53
|
+
print(json.dumps(res, indent=2))
|
|
54
|
+
if args.out:
|
|
55
|
+
pd.DataFrame([res]).to_csv(args.out, index=False)
|
|
56
|
+
return 0
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _cmd_decompose(args: argparse.Namespace) -> int:
|
|
60
|
+
z_df = pd.read_csv(args.z_csv, index_col=0)
|
|
61
|
+
padj_df = pd.read_csv(args.padj_csv, index_col=0) if args.padj_csv else None
|
|
62
|
+
early_cols = tuple(c.strip() for c in args.early_cols.split(",") if c.strip())
|
|
63
|
+
late_cols = tuple(c.strip() for c in args.late_cols.split(",") if c.strip())
|
|
64
|
+
kin_df = classify_kinetic_regimes(
|
|
65
|
+
z_df=z_df,
|
|
66
|
+
padj_df=padj_df,
|
|
67
|
+
early_cols=early_cols,
|
|
68
|
+
late_cols=late_cols,
|
|
69
|
+
wo_early_col=args.wo_early_col,
|
|
70
|
+
wo_late_col=args.wo_late_col,
|
|
71
|
+
tau=args.tau,
|
|
72
|
+
)
|
|
73
|
+
summary = pd.crosstab(kin_df["regime"], kin_df["direction"])
|
|
74
|
+
print(summary.to_string())
|
|
75
|
+
if args.out:
|
|
76
|
+
kin_df.to_csv(args.out)
|
|
77
|
+
print(f"Saved decomposed trajectories to {args.out}")
|
|
78
|
+
return 0
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
82
|
+
parser = argparse.ArgumentParser(
|
|
83
|
+
prog="nvpersist",
|
|
84
|
+
description="NV-Persist: Cross-compartment neuronal washout and microvascular neurotoxicity toolkit.",
|
|
85
|
+
)
|
|
86
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
87
|
+
|
|
88
|
+
p_info = sub.add_parser("info", help="Display package metadata and consensus signature counts.")
|
|
89
|
+
p_info.set_defaults(func=_cmd_info)
|
|
90
|
+
|
|
91
|
+
p_mod = sub.add_parser("list-modules", help="List curated Neurovascular Unit (NVU) gene modules.")
|
|
92
|
+
p_mod.add_argument("--module", type=str, default=None, help="Inspect genes inside a specific module.")
|
|
93
|
+
p_mod.set_defaults(func=_cmd_list_modules)
|
|
94
|
+
|
|
95
|
+
p_score = sub.add_parser("score", help="Score a differential expression CSV against the 668-gene NVP consensus.")
|
|
96
|
+
p_score.add_argument("--de-csv", required=True, help="Input CSV with gene symbol and signed z-score columns.")
|
|
97
|
+
p_score.add_argument("--gene-col", default="gene", help="Column name containing HGNC symbols (default: gene).")
|
|
98
|
+
p_score.add_argument("--z-col", default="z_score", help="Column name containing signed z-scores (default: z_score).")
|
|
99
|
+
p_score.add_argument("--n-boot", type=int, default=1000, help="Bootstrap replicates for 95% CI (default: 1000).")
|
|
100
|
+
p_score.add_argument("--seed", type=int, default=42, help="Random seed (default: 42).")
|
|
101
|
+
p_score.add_argument("--out", default=None, help="Optional CSV output path.")
|
|
102
|
+
p_score.set_defaults(func=_cmd_score)
|
|
103
|
+
|
|
104
|
+
p_dec = sub.add_parser("decompose", help="Run 5-regime post-washout kinetic trajectory decomposition.")
|
|
105
|
+
p_dec.add_argument("--z-csv", required=True, help="Gene x timepoint z-score matrix CSV.")
|
|
106
|
+
p_dec.add_argument("--padj-csv", default=None, help="Optional matched FDR padj CSV.")
|
|
107
|
+
p_dec.add_argument("--early-cols", default="2h,6h,12h", help="Comma-separated early exposure columns.")
|
|
108
|
+
p_dec.add_argument("--late-cols", default="24h,48h", help="Comma-separated late exposure columns.")
|
|
109
|
+
p_dec.add_argument("--wo-early-col", default="72h_wo24h", help="Early post-washout column name.")
|
|
110
|
+
p_dec.add_argument("--wo-late-col", default="5d_wo5d", help="Late post-washout column name.")
|
|
111
|
+
p_dec.add_argument("--tau", type=float, default=1.5, help="SPI stabilization constant (default: 1.5).")
|
|
112
|
+
p_dec.add_argument("--out", default=None, help="Optional CSV output path.")
|
|
113
|
+
p_dec.set_defaults(func=_cmd_decompose)
|
|
114
|
+
|
|
115
|
+
return parser
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def main(argv: list[str] | None = None) -> int:
|
|
119
|
+
parser = build_parser()
|
|
120
|
+
args = parser.parse_args(argv)
|
|
121
|
+
return int(args.func(args))
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
raise SystemExit(main())
|