Metadata-Version: 2.4
Name: pathlaw
Version: 0.1.0
Summary: Supervised Pathway Projection + Symbolic Regression for Interpretable Drug Response Prediction
Author-email: Seokchol Hong <seokcholhong@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Seokchol Hong
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/satchellhong/pathlaw
Project-URL: Paper, https://github.com/satchellhong/xai-dr
Keywords: drug response prediction,symbolic regression,explainability,pathway analysis,bioinformatics,interpretable machine learning
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.0
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Requires-Dist: scikit-learn>=1.3
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Provides-Extra: viz
Requires-Dist: matplotlib>=3.7; extra == "viz"
Requires-Dist: pandas>=2.0; extra == "viz"
Dynamic: license-file

# pathlaw

**Supervised Pathway Projection + Symbolic Regression for Interpretable Drug Response Prediction**

[![PyPI](https://img.shields.io/pypi/v/pathlaw)](https://pypi.org/project/pathlaw/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![GitHub](https://img.shields.io/badge/GitHub-satchellhong%2Fpathlaw-black?logo=github)](https://github.com/satchellhong/pathlaw)

pathlaw compresses a deep drug response model's latent representation into biologically
named pathway scores, then fits a symbolic regression head — producing a single, globally
readable formula:

```
lnIC50 ≈ 2.51 × EML(x, y) − 2.09
  x (resistance) = +1.56·KRAS  +1.12·DNA_REPAIR  +1.04·G2M  + ···
  y (sensitivity) = +0.87·APOPTOSIS  +0.70·PI3K_AKT  + ···
```

No post-hoc aggregation. No direction analysis. No manual interpretation.  
**The formula is the explanation.**

## Install

```bash
pip install pathlaw
```

## Quick start

```python
from pathlaw import PathLaw

# X: intermediate representations from your model  (N, n_input)
# y: target values, e.g. lnIC50                    (N,)
model = PathLaw(n_input=1536, n_pathways=8, depth=3)
model.fit(X, y, epochs=300)

print(model.formula())   # human-readable formula
print(model.explain())   # clinical sentences from coefficients
```

## How it works

```
Your model's latent (1536-dim)
        ↓
Pathway Projection  Linear(1536 → 8)   ← trainable, named after Hallmark gene sets
        ↓
EML Symbolic Head   depth-3 tree       ← learns lnIC50 ≈ EML(x, y)
        ↓
Formula + clinical sentences           ← 0 analyst steps
```

The 8 default pathways (`HALLMARK_PATHWAYS`):
`APOPTOSIS`, `G2M_CHECKPOINT`, `DNA_REPAIR`, `PI3K_AKT_MTOR`,
`KRAS_SIGNALING`, `ESTROGEN_RESPONSE`, `HYPOXIA`, `E2F_TARGETS`

You can supply any pathway names matching your domain.

## API

| Method | Description |
|--------|-------------|
| `PathLaw(n_input, n_pathways, depth, pathway_names)` | Create model |
| `model.fit(X, y, epochs, ...)` | Train on intermediate reps + targets |
| `model.predict(X)` | Predict lnIC50 |
| `model.pathway_scores(X)` | Get named pathway activations |
| `model.formula()` | Human-readable formula string |
| `model.explain(threshold)` | Clinical sentences from coefficients |
| `model.formula_dict()` | Full formula as dict (includes LaTeX) |
| `model.evaluate(X, y)` | Pearson r, Spearman ρ, RMSE |
| `model.save(path)` / `PathLaw.load(path)` | Persistence |

## Citation

If you use pathlaw in your research, please cite:

```bibtex
@article{hong2026pathlaw,
  author  = {Hong, Seokchol},
  title   = {Supervised Pathway Projection with Symbolic Regression
             Enables Interpretable Drug Response Prediction},
  year    = {2026},
  url     = {https://github.com/seokcholhong/pathlaw}
}
```

## License

MIT
