nvpersist 1.0.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Muhammad Khubaib Ahmad (Emerson University Multan / INFERENCE Lab)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: nvpersist
3
+ Version: 1.0.0
4
+ Summary: Cross-compartment transcriptomic modeling of post-washout neuronal injury and human microvascular/BBB dysfunction
5
+ Author-email: Muhammad Khubaib Ahmad <khubaib.ahmad@inference-lab.org>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Inference-LAB/nvpersist
8
+ Project-URL: Repository, https://github.com/Inference-LAB/nvpersist
9
+ Project-URL: Issues, https://github.com/Inference-LAB/nvpersist/issues
10
+ Keywords: neurovascular-unit,microvascular-endothelium,blood-brain-barrier,neuropharmacology,differential-expression,gsea,toxcast
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy>=1.26
21
+ Requires-Dist: pandas>=2.2
22
+ Requires-Dist: scipy>=1.12
23
+ Requires-Dist: statsmodels>=0.14
24
+ Requires-Dist: scikit-learn>=1.4
25
+ Requires-Dist: matplotlib>=3.8
26
+ Requires-Dist: seaborn>=0.13
27
+ Requires-Dist: openpyxl>=3.1
28
+ Requires-Dist: requests>=2.31
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=8.0; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # `nvpersist`: Cross-Compartment Neurovascular & Post-Washout Injury Modeling
34
+
35
+ Official Python package, command-line toolkit, empirical Bayes summary outputs, leave-one-cohort-out cross-validation (LOCO-CV) tables, 2x2 JNK epistasis results, EPA ToxCast `invitrodb` v4.3 coverage audits, and publication figures for:
36
+
37
+ > **Cross-compartment transcriptomic modeling links post-washout neuronal injury to human microvascular and blood-brain barrier dysfunction** (*Microvascular Research*, Elsevier)
38
+
39
+ **Author:** Muhammad Khubaib Ahmad
40
+ **Affiliations:** Emerson University Multan, Pakistan; INFERENCE Lab, Multan
41
+ **Correspondence:** [khubaib.ahmad@inference-lab.org](mailto:khubaib.ahmad@inference-lab.org)
42
+ **Repository:** [https://github.com/Inference-LAB/nvpersist](https://github.com/Inference-LAB/nvpersist)
43
+
44
+ ---
45
+
46
+ ## Key Features & Package Capabilities
47
+
48
+ `nvpersist` (`v1.0.0`) provides both a **reusable Python API + CLI (`nvpersist`)** and the **complete study reproduction pipeline**:
49
+
50
+ 1. **Statistical Core (`nvpersist.stats` & `nvpersist.id_map`):**
51
+ - `voom_limma_contrast`, `eb_moderated_from_log_matrix`, `fit_f_dist_smyth`, `deseq_size_factors`: Within-study differential expression with LOWESS mean-variance precision weights and Smyth empirical Bayes variance moderation mapped to signed normal `z_score` deviates.
52
+ - `preranked_gsea`: Vectorized $O(k \log k)$ sparse-hit weighted preranked GSEA computing `ES`, `NES`, empirical `pvalue`, `padj`, and Stouffer `stouffer_z`.
53
+ - `HGNCMapper`: Canonical HGNC gene symbol normalization across Ensembl IDs, Entrez IDs, aliases, and legacy symbols.
54
+ 2. **Longitudinal Trajectory Decomposition (`nvpersist.kinetics`):**
55
+ - `compute_spi_and_escalation`: Susceptibility Persistence Index ($\mathrm{SPI}_g$) and washout escalation ($E_g$).
56
+ - `classify_kinetic_regimes`: Mutually exclusive 5-regime decomposition (`Persistent_Conserved`, `Delayed_Washout_Escalating`, `Transient_Reversible`, `Intermediate_Partial`, `Rebound_Recovery`, plus `Unchanged`).
57
+ - `enrich_kinetic_regimes`: Fisher exact over-representation tests with Benjamini-Hochberg FDR across regimes.
58
+ 3. **Cross-Compartment Neurovascular Modeling (`nvpersist.neurovascular` & `nvpersist.nv_modules`):**
59
+ - `NVU_MODULES`: 12 curated Neurovascular Unit gene modules (BBB tight/adherens junctions, efflux/influx transporters, glycocalyx/ECM, microvascular adhesion, senescence/SASP, angiogenesis, JNK/AP-1, ISR/UPR, neuronal injury, axonal transport, sterol/lipid, and OXPHOS/Complex I).
60
+ - `load_consensus_signature`: Bundled **668-gene consensus Neurovascular Persistence (`NVP`) signature** (`328` Up, `340` Down).
61
+ - `compute_nvp_score`: Out-of-cohort directional scoring with 95% bootstrap CI and expression-decile-matched random-gene empirical null tests.
62
+ - `directional_nv_concordance`, `compute_cross_compartment_coupling`, `compute_jnk_epistasis`, `audit_toxcast_coverage`.
63
+ 4. **Command-Line Interface (`nvpersist`):**
64
+ - `nvpersist info`, `nvpersist list-modules`, `nvpersist score`, and `nvpersist decompose` work directly out of the box after `pip install`.
65
+
66
+ ---
67
+
68
+ ## Installation
69
+
70
+ ### Install from PyPI
71
+ ```bash
72
+ pip install nvpersist
73
+ ```
74
+
75
+ ### Install latest development version from GitHub
76
+ ```bash
77
+ pip install git+https://github.com/Inference-LAB/nvpersist.git
78
+ ```
79
+
80
+ ### Local editable installation (from cloned repository)
81
+ ```bash
82
+ git clone https://github.com/Inference-LAB/nvpersist.git
83
+ cd nvpersist
84
+ pip install -r requirements.txt
85
+ pip install -e ".[dev]"
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Quickstart (CLI & Python API)
91
+
92
+ ### Command-Line Interface
93
+ ```bash
94
+ # Inspect packaged signature & metadata
95
+ nvpersist info
96
+
97
+ # Inspect curated Neurovascular Unit barrier/stress modules
98
+ nvpersist list-modules
99
+ nvpersist list-modules --module NVU_BBB_Tight_Adherens_Junctions
100
+
101
+ # Score any differential expression CSV (requiring 'gene' and 'z_score' columns)
102
+ nvpersist score --de-csv path/to/endothelial_contrast.csv --out nvp_scored.csv
103
+
104
+ # Run 5-regime exposure + washout trajectory decomposition on longitudinal z-scores
105
+ nvpersist decompose --z-csv path/to/z_matrix.csv --padj-csv path/to/padj_matrix.csv --out regimes.csv
106
+ ```
107
+
108
+ ### Python API
109
+ ```python
110
+ import pandas as pd
111
+ from nvpersist import (
112
+ NVU_MODULES,
113
+ classify_kinetic_regimes,
114
+ compute_nvp_score,
115
+ directional_nv_concordance,
116
+ load_consensus_signature,
117
+ )
118
+
119
+ up_genes, dn_genes, sig_df = load_consensus_signature()
120
+ print(f"Consensus NVP genes: {len(up_genes)} Up, {len(dn_genes)} Down")
121
+
122
+ # Score a differential expression table indexed by HGNC symbol with a 'z_score' column
123
+ # result = compute_nvp_score(de_df, n_boot=1000)
124
+
125
+ # Directional Neurovascular Concordance (DNC) and Divergence (Delta_NV)
126
+ dnc, div = directional_nv_concordance(z_neuronal=15.87, z_vascular=5.13)
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Study Datasets & Directory Layout
132
+
133
+ `NV-Persist` integrates **279 unique human RNA-sequencing libraries** across **11 public NCBI GEO cohorts** (`138` neuronal libraries; `141` microvascular, aortic/iPSC endothelial, and brain BBB libraries; **89** within-study empirical Bayes contrasts) plus **EPA ToxCast `invitrodb` v4.3** (August 2025):
134
+
135
+ - **Neuronal GEO Cohorts:** `GSE312881` (`n=71`), `GSE305998` (`n=48`), `GSE173610` (`n=5`), `GSE245060` (`n=14` unique paired).
136
+ - **Peripheral Microvascular, Endothelial & Brain BBB GEO Cohorts:** `GSE261326` (`n=25`), `GSE217550` (`n=12`), `GSE275667` (`n=6`), `GSE217898` (`n=72`), `GSE305805` (`n=8`), `GSE303528` (`n=6`), `GSE211439` (`n=12` analyzed).
137
+
138
+ ```text
139
+ nvpersist/
140
+ ├── src/nvpersist/ # Installable package (stats, kinetics, neurovascular, id_map, nv_modules, cli, bundled data)
141
+ ├── tests/ # Unit & CLI test suite (pytest)
142
+ ├── scripts/ # Full pipeline scripts (05-20, 18b)
143
+ ├── data/metadata/ # Sample manifests for all 11 GEO series
144
+ ├── results/
145
+ │ ├── de_cohort_summary.csv # Empirical Bayes summary across all 89 contrasts
146
+ │ ├── nv_persist/ # Regime decomposition, Stouffer/NES/FDR matrices, donor & 72h stats, Reactome
147
+ │ ├── microvascular/ # Endothelial barrier atlas, BBB marker Z-matrix, 16 paracrine L-R axes
148
+ │ ├── validation/ # LOCO-CV + matched-null stats, 2x2 JNK epistasis, ToxCast v4.3 audit, NVP genes
149
+ │ ├── gsea/ # KEGG preranked GSEA outputs across 20 focal contrasts
150
+ │ └── figures/ # 300-DPI PNG and vector PDF figures (Fig1-Fig5)
151
+ ├── pyproject.toml # Package metadata, dependencies & console script entrypoint
152
+ ├── requirements.txt
153
+ ├── CITATION.cff
154
+ └── LICENSE # MIT License
155
+ ```
156
+
157
+ *Note on `.gitignore` exclusions:* Large raw GEO archives (`data/raw/`, ~119 MB), Enrichr/HGNC lookup files (`data/genesets/`, ~20 MB), and the 89 individual gzip DE files (`results/de/`, ~88 MB) are excluded from git tracking and regenerated deterministically via `scripts/05_download_geo.py`, `scripts/06_download_genesets_and_idmap.py`, and `scripts/13_run_within_study_de.py`.
158
+
159
+ ---
160
+
161
+ ## Reproducing Manuscript Results & Tests
162
+
163
+ ```bash
164
+ # 1. Run full unit and CLI test suite
165
+ pytest -v
166
+
167
+ # 2. Regenerate all 5 publication figures directly from results CSVs
168
+ python -u scripts/18b_generate_publication_figures.py
169
+
170
+ # 3. (Optional) Reproduce from raw NCBI GEO + EPA ToxCast v4.3 Excel release
171
+ python -u scripts/05_download_geo.py
172
+ python -u scripts/06_download_genesets_and_idmap.py
173
+ # Place ToxCast v4.3 files (annotations, target mappings, cytotox) in data/raw/toxcast_v4_3/
174
+ python -u scripts/13_run_within_study_de.py
175
+ python -u scripts/14_qc_pca_diagnostics.py
176
+ python -u scripts/15_nv_persist_modeling.py
177
+ python -u scripts/16_validation_and_toxcast.py
178
+ python -u scripts/16b_fixed_validation_and_toxcast.py
179
+ python -u scripts/17_loco_cv_and_marker_audit.py
180
+ python -u scripts/19_critical_audit.py
181
+ python -u scripts/19b_inspect_toxcast_exact.py
182
+ python -u scripts/20_microvascular_barrier_and_paracrine.py
183
+ python -u scripts/18b_generate_publication_figures.py
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Citation
189
+
190
+ If you use `nvpersist` in your research, please cite the software and accompanying manuscript using [CITATION.cff](https://github.com/Inference-LAB/nvpersist/blob/main/CITATION.cff).
191
+
192
+ ## License
193
+
194
+ MIT License - Copyright (c) 2026 Muhammad Khubaib Ahmad. See [LICENSE](https://github.com/Inference-LAB/nvpersist/blob/main/LICENSE).
@@ -0,0 +1,162 @@
1
+ # `nvpersist`: Cross-Compartment Neurovascular & Post-Washout Injury Modeling
2
+
3
+ Official Python package, command-line toolkit, empirical Bayes summary outputs, leave-one-cohort-out cross-validation (LOCO-CV) tables, 2x2 JNK epistasis results, EPA ToxCast `invitrodb` v4.3 coverage audits, and publication figures for:
4
+
5
+ > **Cross-compartment transcriptomic modeling links post-washout neuronal injury to human microvascular and blood-brain barrier dysfunction** (*Microvascular Research*, Elsevier)
6
+
7
+ **Author:** Muhammad Khubaib Ahmad
8
+ **Affiliations:** Emerson University Multan, Pakistan; INFERENCE Lab, Multan
9
+ **Correspondence:** [khubaib.ahmad@inference-lab.org](mailto:khubaib.ahmad@inference-lab.org)
10
+ **Repository:** [https://github.com/Inference-LAB/nvpersist](https://github.com/Inference-LAB/nvpersist)
11
+
12
+ ---
13
+
14
+ ## Key Features & Package Capabilities
15
+
16
+ `nvpersist` (`v1.0.0`) provides both a **reusable Python API + CLI (`nvpersist`)** and the **complete study reproduction pipeline**:
17
+
18
+ 1. **Statistical Core (`nvpersist.stats` & `nvpersist.id_map`):**
19
+ - `voom_limma_contrast`, `eb_moderated_from_log_matrix`, `fit_f_dist_smyth`, `deseq_size_factors`: Within-study differential expression with LOWESS mean-variance precision weights and Smyth empirical Bayes variance moderation mapped to signed normal `z_score` deviates.
20
+ - `preranked_gsea`: Vectorized $O(k \log k)$ sparse-hit weighted preranked GSEA computing `ES`, `NES`, empirical `pvalue`, `padj`, and Stouffer `stouffer_z`.
21
+ - `HGNCMapper`: Canonical HGNC gene symbol normalization across Ensembl IDs, Entrez IDs, aliases, and legacy symbols.
22
+ 2. **Longitudinal Trajectory Decomposition (`nvpersist.kinetics`):**
23
+ - `compute_spi_and_escalation`: Susceptibility Persistence Index ($\mathrm{SPI}_g$) and washout escalation ($E_g$).
24
+ - `classify_kinetic_regimes`: Mutually exclusive 5-regime decomposition (`Persistent_Conserved`, `Delayed_Washout_Escalating`, `Transient_Reversible`, `Intermediate_Partial`, `Rebound_Recovery`, plus `Unchanged`).
25
+ - `enrich_kinetic_regimes`: Fisher exact over-representation tests with Benjamini-Hochberg FDR across regimes.
26
+ 3. **Cross-Compartment Neurovascular Modeling (`nvpersist.neurovascular` & `nvpersist.nv_modules`):**
27
+ - `NVU_MODULES`: 12 curated Neurovascular Unit gene modules (BBB tight/adherens junctions, efflux/influx transporters, glycocalyx/ECM, microvascular adhesion, senescence/SASP, angiogenesis, JNK/AP-1, ISR/UPR, neuronal injury, axonal transport, sterol/lipid, and OXPHOS/Complex I).
28
+ - `load_consensus_signature`: Bundled **668-gene consensus Neurovascular Persistence (`NVP`) signature** (`328` Up, `340` Down).
29
+ - `compute_nvp_score`: Out-of-cohort directional scoring with 95% bootstrap CI and expression-decile-matched random-gene empirical null tests.
30
+ - `directional_nv_concordance`, `compute_cross_compartment_coupling`, `compute_jnk_epistasis`, `audit_toxcast_coverage`.
31
+ 4. **Command-Line Interface (`nvpersist`):**
32
+ - `nvpersist info`, `nvpersist list-modules`, `nvpersist score`, and `nvpersist decompose` work directly out of the box after `pip install`.
33
+
34
+ ---
35
+
36
+ ## Installation
37
+
38
+ ### Install from PyPI
39
+ ```bash
40
+ pip install nvpersist
41
+ ```
42
+
43
+ ### Install latest development version from GitHub
44
+ ```bash
45
+ pip install git+https://github.com/Inference-LAB/nvpersist.git
46
+ ```
47
+
48
+ ### Local editable installation (from cloned repository)
49
+ ```bash
50
+ git clone https://github.com/Inference-LAB/nvpersist.git
51
+ cd nvpersist
52
+ pip install -r requirements.txt
53
+ pip install -e ".[dev]"
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Quickstart (CLI & Python API)
59
+
60
+ ### Command-Line Interface
61
+ ```bash
62
+ # Inspect packaged signature & metadata
63
+ nvpersist info
64
+
65
+ # Inspect curated Neurovascular Unit barrier/stress modules
66
+ nvpersist list-modules
67
+ nvpersist list-modules --module NVU_BBB_Tight_Adherens_Junctions
68
+
69
+ # Score any differential expression CSV (requiring 'gene' and 'z_score' columns)
70
+ nvpersist score --de-csv path/to/endothelial_contrast.csv --out nvp_scored.csv
71
+
72
+ # Run 5-regime exposure + washout trajectory decomposition on longitudinal z-scores
73
+ nvpersist decompose --z-csv path/to/z_matrix.csv --padj-csv path/to/padj_matrix.csv --out regimes.csv
74
+ ```
75
+
76
+ ### Python API
77
+ ```python
78
+ import pandas as pd
79
+ from nvpersist import (
80
+ NVU_MODULES,
81
+ classify_kinetic_regimes,
82
+ compute_nvp_score,
83
+ directional_nv_concordance,
84
+ load_consensus_signature,
85
+ )
86
+
87
+ up_genes, dn_genes, sig_df = load_consensus_signature()
88
+ print(f"Consensus NVP genes: {len(up_genes)} Up, {len(dn_genes)} Down")
89
+
90
+ # Score a differential expression table indexed by HGNC symbol with a 'z_score' column
91
+ # result = compute_nvp_score(de_df, n_boot=1000)
92
+
93
+ # Directional Neurovascular Concordance (DNC) and Divergence (Delta_NV)
94
+ dnc, div = directional_nv_concordance(z_neuronal=15.87, z_vascular=5.13)
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Study Datasets & Directory Layout
100
+
101
+ `NV-Persist` integrates **279 unique human RNA-sequencing libraries** across **11 public NCBI GEO cohorts** (`138` neuronal libraries; `141` microvascular, aortic/iPSC endothelial, and brain BBB libraries; **89** within-study empirical Bayes contrasts) plus **EPA ToxCast `invitrodb` v4.3** (August 2025):
102
+
103
+ - **Neuronal GEO Cohorts:** `GSE312881` (`n=71`), `GSE305998` (`n=48`), `GSE173610` (`n=5`), `GSE245060` (`n=14` unique paired).
104
+ - **Peripheral Microvascular, Endothelial & Brain BBB GEO Cohorts:** `GSE261326` (`n=25`), `GSE217550` (`n=12`), `GSE275667` (`n=6`), `GSE217898` (`n=72`), `GSE305805` (`n=8`), `GSE303528` (`n=6`), `GSE211439` (`n=12` analyzed).
105
+
106
+ ```text
107
+ nvpersist/
108
+ ├── src/nvpersist/ # Installable package (stats, kinetics, neurovascular, id_map, nv_modules, cli, bundled data)
109
+ ├── tests/ # Unit & CLI test suite (pytest)
110
+ ├── scripts/ # Full pipeline scripts (05-20, 18b)
111
+ ├── data/metadata/ # Sample manifests for all 11 GEO series
112
+ ├── results/
113
+ │ ├── de_cohort_summary.csv # Empirical Bayes summary across all 89 contrasts
114
+ │ ├── nv_persist/ # Regime decomposition, Stouffer/NES/FDR matrices, donor & 72h stats, Reactome
115
+ │ ├── microvascular/ # Endothelial barrier atlas, BBB marker Z-matrix, 16 paracrine L-R axes
116
+ │ ├── validation/ # LOCO-CV + matched-null stats, 2x2 JNK epistasis, ToxCast v4.3 audit, NVP genes
117
+ │ ├── gsea/ # KEGG preranked GSEA outputs across 20 focal contrasts
118
+ │ └── figures/ # 300-DPI PNG and vector PDF figures (Fig1-Fig5)
119
+ ├── pyproject.toml # Package metadata, dependencies & console script entrypoint
120
+ ├── requirements.txt
121
+ ├── CITATION.cff
122
+ └── LICENSE # MIT License
123
+ ```
124
+
125
+ *Note on `.gitignore` exclusions:* Large raw GEO archives (`data/raw/`, ~119 MB), Enrichr/HGNC lookup files (`data/genesets/`, ~20 MB), and the 89 individual gzip DE files (`results/de/`, ~88 MB) are excluded from git tracking and regenerated deterministically via `scripts/05_download_geo.py`, `scripts/06_download_genesets_and_idmap.py`, and `scripts/13_run_within_study_de.py`.
126
+
127
+ ---
128
+
129
+ ## Reproducing Manuscript Results & Tests
130
+
131
+ ```bash
132
+ # 1. Run full unit and CLI test suite
133
+ pytest -v
134
+
135
+ # 2. Regenerate all 5 publication figures directly from results CSVs
136
+ python -u scripts/18b_generate_publication_figures.py
137
+
138
+ # 3. (Optional) Reproduce from raw NCBI GEO + EPA ToxCast v4.3 Excel release
139
+ python -u scripts/05_download_geo.py
140
+ python -u scripts/06_download_genesets_and_idmap.py
141
+ # Place ToxCast v4.3 files (annotations, target mappings, cytotox) in data/raw/toxcast_v4_3/
142
+ python -u scripts/13_run_within_study_de.py
143
+ python -u scripts/14_qc_pca_diagnostics.py
144
+ python -u scripts/15_nv_persist_modeling.py
145
+ python -u scripts/16_validation_and_toxcast.py
146
+ python -u scripts/16b_fixed_validation_and_toxcast.py
147
+ python -u scripts/17_loco_cv_and_marker_audit.py
148
+ python -u scripts/19_critical_audit.py
149
+ python -u scripts/19b_inspect_toxcast_exact.py
150
+ python -u scripts/20_microvascular_barrier_and_paracrine.py
151
+ python -u scripts/18b_generate_publication_figures.py
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Citation
157
+
158
+ If you use `nvpersist` in your research, please cite the software and accompanying manuscript using [CITATION.cff](https://github.com/Inference-LAB/nvpersist/blob/main/CITATION.cff).
159
+
160
+ ## License
161
+
162
+ MIT License - Copyright (c) 2026 Muhammad Khubaib Ahmad. See [LICENSE](https://github.com/Inference-LAB/nvpersist/blob/main/LICENSE).
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nvpersist"
7
+ version = "1.0.0"
8
+ description = "Cross-compartment transcriptomic modeling of post-washout neuronal injury and human microvascular/BBB dysfunction"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "Muhammad Khubaib Ahmad", email = "khubaib.ahmad@inference-lab.org" },
15
+ ]
16
+ keywords = [
17
+ "neurovascular-unit",
18
+ "microvascular-endothelium",
19
+ "blood-brain-barrier",
20
+ "neuropharmacology",
21
+ "differential-expression",
22
+ "gsea",
23
+ "toxcast",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 5 - Production/Stable",
27
+ "Intended Audience :: Science/Research",
28
+ "Operating System :: OS Independent",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
32
+ ]
33
+ dependencies = [
34
+ "numpy>=1.26",
35
+ "pandas>=2.2",
36
+ "scipy>=1.12",
37
+ "statsmodels>=0.14",
38
+ "scikit-learn>=1.4",
39
+ "matplotlib>=3.8",
40
+ "seaborn>=0.13",
41
+ "openpyxl>=3.1",
42
+ "requests>=2.31",
43
+ ]
44
+
45
+ [project.optional-dependencies]
46
+ dev = [
47
+ "pytest>=8.0",
48
+ ]
49
+
50
+ [project.urls]
51
+ Homepage = "https://github.com/Inference-LAB/nvpersist"
52
+ Repository = "https://github.com/Inference-LAB/nvpersist"
53
+ Issues = "https://github.com/Inference-LAB/nvpersist/issues"
54
+
55
+ [project.scripts]
56
+ nvpersist = "nvpersist.cli:main"
57
+
58
+ [tool.setuptools.packages.find]
59
+ where = ["src"]
60
+
61
+ [tool.setuptools.package-data]
62
+ nvpersist = ["data/*.tsv"]
63
+
64
+ [tool.pytest.ini_options]
65
+ testpaths = ["tests"]
66
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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
+ ]
@@ -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())