Metadata-Version: 2.4
Name: phenosign
Version: 0.1.5
Summary: A Python package for synergy and correlation analysis of HPO annotations in GA4GH phenopacket cohorts
Author-email: Jing Chen <jing.chen@bih-charite.de>
Maintainer-email: Peter Robinson <peter.robinson@bih-charite.de>, Daniel Danis <daniel.danis@bih-charite.de>
License: BSD 3-Clause License
        
        Copyright (c) 2024, Monarch Initiative and contributors
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: homepage, https://github.com/P2GX/phenosign
Project-URL: repository, https://github.com/P2GX/phenosign.git
Project-URL: documentation, https://P2GX.github.io/phenosign/
Project-URL: bugtracker, https://github.com/P2GX/phenosign/issues
Keywords: Global Alliance for Genomics and Health,GA4GH Phenopacket Schema,Human Phenotype Ontology,GA4GH,HPO
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: hpo-toolkit<0.6,>=0.5.0
Requires-Dist: phenopackets<3.0,>=2.0.2
Requires-Dist: scikit-learn<2.0,>=1.6.1
Requires-Dist: numpy<3.0,>=1.26.4
Requires-Dist: pandas<3.0,>=2.2.3
Requires-Dist: plotly>=6.1.1
Requires-Dist: kaleido>=1.0.0
Requires-Dist: gpsea>=0.9.11
Requires-Dist: scipy<2.0,>=1.15.1
Requires-Dist: joblib<2.0,>=1.4.2
Requires-Dist: tqdm<5.0,>=4.67.1
Requires-Dist: statsmodels<1.0,>=0.14.4
Provides-Extra: test
Requires-Dist: pytest<8.0.0,>=7.0.0; extra == "test"
Provides-Extra: docs
Requires-Dist: mkdocs-material[imaging]<10,>=9.5.10; extra == "docs"
Requires-Dist: mkdocs-material-extensions<2.0,>=1.3; extra == "docs"
Requires-Dist: mkdocstrings[python]<1.0,>=0.22; extra == "docs"
Requires-Dist: mkdocs-gen-files>=0.5.0; extra == "docs"
Requires-Dist: pillow; extra == "docs"
Requires-Dist: cairosvg; extra == "docs"
Dynamic: license-file

# phenosign

**phenosign** is a Python library for analyzing pairwise relationships between Human Phenotype Ontology (HPO) features in [GA4GH Phenopacket](https://www.ga4gh.org/product/phenopackets/) cohorts.

It provides two complementary analyses:

1. **Pairwise association analysis**, which measures associations between binary phenotype annotations using the phi coefficient and Fisher's exact test.
2. **Target-specific synergy analysis**, which evaluates whether a pair of phenotype features provides joint information about a predefined target beyond the information provided by the individual features.

---

## Installation

```bash
pip install phenosign
```


## Features

* Construction of phenotype matrices from GA4GH Phenopackets, with separate representation of observed, excluded, and unreported HPO annotations
* Ontology-aware propagation of phenotype annotations
* Pairwise phenotype association analysis using the phi coefficient, Fisher's exact test, and Benjamini–Hochberg correction, with exclusion of ancestor–descendant HPO term pairs
* Mutual-information-based phenotype-pair synergy analysis with permutation testing and Benjamini–Hochberg correction, supporting targets such as disease diagnosis, variant effect, and sex
* Tabular results and interactive heatmaps, including contingency counts, effective sample sizes, adjusted p-values, and publication provenance where available


## Quickstart

```python
from pathlib import Path
from google.protobuf.json_format import Parse
from phenosign import (
    PhenotypeDatasetBuilder,
    HPOCorrelationAnalyzer,
)

# Load phenopackets
phenopacket_dir = Path("path/to/your/fbn1_phenopackets/")

phenopackets = []
for file_path in phenopacket_dir.glob("*.json"):
    with open(file_path, "r", encoding="utf-8") as f:
        data: str = f.read()
        phenopacket: Phenopacket = Parse(data, Phenopacket())
        phenopackets.append(phenopacket)

# Build dataset
dataset = PhenotypeDatasetBuilder(phenopackets).build(build_gpsea_cohort=False)

# Run correlation analysis
analyzer = HPOCorrelationAnalyzer(dataset)
results = analyzer.compute_correlation_matrix()
results.result_table.head()
```

For complete workflows, synergy analysis, visualization options, and API details, see the [Documentation](https://phenosign.readthedocs.io/).



