Metadata-Version: 2.5
Name: cbrviz
Version: 0.1.0
Summary: Composable Matplotlib building blocks for statistical figures
Project-URL: Homepage, https://github.com/fossbert/cbrviz
Project-URL: Issues, https://github.com/fossbert/cbrviz/issues
Project-URL: Changelog, https://github.com/fossbert/cbrviz/blob/main/CHANGELOG.md
Author: H. Carlo Maurer
License: MIT License
        
        Copyright (c) 2026 H. Carlo Maurer
        
        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.
License-File: LICENSE
Keywords: boxplot,kde,matplotlib,plotting,statistics,survival,visualization
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Matplotlib
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.10
Requires-Dist: adjusttext>=0.8
Requires-Dist: matplotlib>=3.6
Requires-Dist: numpy>=1.23
Requires-Dist: pandas>=2.2
Requires-Dist: scipy>=1.11
Requires-Dist: statsmodels>=0.13
Provides-Extra: all
Requires-Dist: scikit-posthocs>=0.7; extra == 'all'
Requires-Dist: scikit-survival>=0.22; extra == 'all'
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: scikit-posthocs>=0.7; extra == 'dev'
Requires-Dist: scikit-survival>=0.22; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: stats
Requires-Dist: scikit-posthocs>=0.7; extra == 'stats'
Provides-Extra: survival
Requires-Dist: scikit-survival>=0.22; extra == 'survival'
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Requires-Dist: scikit-posthocs>=0.7; extra == 'test'
Requires-Dist: scikit-survival>=0.22; extra == 'test'
Description-Content-Type: text/markdown

# cbrviz

Small, composable Matplotlib building blocks for statistical figures — strip/box
plots with p-value annotation, KDE ridges and split violins, XY panels with
correlation and zoom, dot plots / correlation plots, and Kaplan-Meier curves.

Every class is a thin wrapper around a validated DataFrame plus a handful of
`ax`-based draw methods, so you keep full control of the figure.

## Install

```bash
pip install cbrviz
```

Two statistics back-ends are optional:

```bash
pip install "cbrviz[survival]"   # KME  (scikit-survival)
pip install "cbrviz[stats]"      # StripBox.calc_pairwise_p  (scikit-posthocs)
pip install "cbrviz[all]"        # both
```

## Quickstart

```python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from cbrviz import StripBox

rng = np.random.default_rng(0)
df = pd.DataFrame({
    "expression": np.concatenate([rng.normal(m, 1, 30) for m in (5.0, 6.5, 5.2)]),
    "genotype":   np.repeat(["WT", "KO", "Rescue"], 30),
})

sb = StripBox(df, s1_order=["WT", "KO", "Rescue"])

fig, ax = plt.subplots()
sb.boxplt(ax=ax, showfliers=False)
sb.add_strips(ax=ax, s=12)
sb.add_global_p(ax=ax)
sb.calc_pairwise_p(posthoc_method="dunn")   # needs cbrviz[stats]
sb.add_pair_p("WT", "KO", ax=ax)
```

### `usage()` — a runnable example for every class

Not sure how a class works? Ask it:

```python
>>> from cbrviz import Ridge
>>> Ridge.usage()
# Typical use of Ridge
import numpy as np
...
```

## Modules

| import | what it draws |
|---|---|
| `StripBox`, `SplitStripBox`, `PairedStripBox` | box + strip plots, global & pairwise p-values |
| `KDE`, `KDE2D`, `Ridge`, `SplitViolin` | 1-D / 2-D kernel density, ridgeline, split violin |
| `XYview`, `XYpairs`, `XYzoom` | scatter with correlation / regression / labelled points / zoom inset |
| `Dotplot`, `Corrplot` | grid dot plots and clustered correlation plots |
| `KME` | Kaplan-Meier curves, log-rank, pairwise log-rank heatmap *(needs `cbrviz[survival]`)* |
| `resolve_categories`, `resolve_colors` | helpers for level ordering and palette resolution |

`Heatmap` (`cbrviz.heatmap`) is a placeholder and raises `NotImplementedError`.

## Development

```bash
git clone https://github.com/fossbert/cbrviz
cd cbrviz
pip install -e ".[test]"
pytest
```

## License

MIT — see [LICENSE](LICENSE).
