Metadata-Version: 2.4
Name: trident-validator
Version: 0.1.0
Summary: TRIDENT, TRIadic DEtectioN via staTistical validation
Author: Mattia Marzi
License: MIT License
        
        Copyright (c) 2026 Mattia Marzi
        
        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/<YOUR-USER>/TRIDENT
Project-URL: Repository, https://github.com/<YOUR-USER>/TRIDENT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.23
Requires-Dist: scipy>=1.10
Requires-Dist: pandas>=2.0
Requires-Dist: tqdm>=4.66
Provides-Extra: dev
Requires-Dist: pytest>=7.4; extra == "dev"
Requires-Dist: ruff>=0.5; extra == "dev"
Requires-Dist: black>=24.3; extra == "dev"
Requires-Dist: pre-commit>=3.7; extra == "dev"
Provides-Extra: speed
Requires-Dist: numba>=0.57; extra == "speed"
Dynamic: license-file

# TRIDENT

**TRIDENT** (TRIplets DEtectioN via staTistical validation) is a Python package
for the statistical validation of pairwise and triadic interactions in binary
bipartite data.

TRIDENT implements a maximum-entropy validation pipeline:

- **BiCM** (Bipartite Configuration Model) for validating pairs,
- **BiPLOM** (Bipartite Partial Local Overlap Model) for validating triplets,
- Poisson-binomial p-values (exact or approximated), with multiple-testing
  correction (Bonferroni or FDR, with FDR recommended) to produce validated
  networks and hypergraphs.

The methodology is described in the companion preprint
*Signatures of higher-order cooperation/coordination in the human brain*.

## Installation

```bash
pip install trident-validator
```

For development:

```bash
git clone <repo-url>
cd TRIDENT
pip install -e ".[dev]"
pytest -q
```

## Quick start

### Validate pairs (BiCM)

```python
import numpy as np

from trident import bicm_solver, probability_matrix_from_bicm
from trident import TwoStarValidator

A = ...  # binary biadjacency matrix (N x M)

res = bicm_solver(A)
P   = probability_matrix_from_bicm(res)

val = TwoStarValidator(A, P, n_jobs=1)
pvals = val.compute_pvals(method="normal")
df_pairs, thr = val.validate(pvals, alpha=0.05, method="fdr")
```

### Validate triplets (BiPLOM)

```python
from trident import biplom_solver, probability_matrix_from_biplom
from trident import TripletValidator

res = biplom_solver(A)
P   = probability_matrix_from_biplom(res)

val = TripletValidator(A, P, n_jobs=1)
pvals = val.compute_pvals(method="normal")
df_triplets, thr = val.validate(pvals, alpha=0.05, method="fdr")
```

## Documentation

See the `docs/` folder:

- `docs/api_quick_reference.md`
- `docs/math.md`
- `docs/usage.md`

## Acknowledgements and citations

TRIDENT builds on and extends maximum-entropy methods for bipartite networks and statistically validated projections.

If you use TRIDENT, please also consider citing the reference BiCM implementation and the following foundational works:

- Reference implementation (BiCM module): https://github.com/mat701/BiCM
- N. Vallarano, M. Bruno, E. Marchese, G. Trapani, F. Saracco, T. Squartini, G. Cimini, M. Zanon, "Fast and scalable likelihood maximization for Exponential Random Graph Models with local constraints", Scientific Reports (2021).
- F. Saracco, R. Di Clemente, A. Gabrielli, T. Squartini, "Randomizing bipartite networks: the case of the World Trade Web", Scientific Reports 5, 10595 (2015).
- F. Saracco, M. J. Straka, R. Di Clemente, A. Gabrielli, G. Caldarelli, T. Squartini, "Inferring monopartite projections of bipartite networks: an entropy-based approach", New Journal of Physics 19, 053022 (2017).

## License

MIT (see `LICENSE`).
