Metadata-Version: 2.4
Name: mossn
Version: 0.1.5
Summary: MOSSN: uniform-baseline reweighting of a reference PPI network for individual samples
Author: Zihao Chen
License-Expression: LicenseRef-Research-Only
Keywords: bioinformatics,network,ppi,multi-omics,gene-expression
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: networkx>=3.0
Requires-Dist: numpy>=1.23
Requires-Dist: pandas>=1.5
Requires-Dist: scipy>=1.10
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Dynamic: license-file

# mossn

`mossn` implements MOSSN (Multi-Omics Single-Sample Network reweighting), a
framework for generating sample-specific protein-interaction network (ssPIN)
edge weights from a fixed reference PPI topology.

MOSSN does not infer new protein interactions. The input PPI supplies the
reference edge set and topology only: every retained PPI edge starts at a
uniform weight of `1.0`. Its final, sample-specific weight is determined by
within-sample molecular signals and network propagation.

## Installation

```bash
pip install mossn
```

For local development:

```bash
pip install -e .[test]
```

## Input format

- `expression_data`: a genes × samples `pandas.DataFrame`.
- `links`: a dataframe containing `protein1` and `protein2`. Additional
  confidence-score columns are allowed but are ignored by MOSSN.

Gene identifiers must match between the expression matrix and PPI network.

## Single-omics MOSSN

For each sample, MOSSN IQR-normalizes expression, applies sigmoid edge
correction, initializes RWR from genes above the 90th expression percentile,
runs RWR (`alpha=0.3`), rank-normalizes node importance, and returns one score
per reference PPI edge.

```python
import pandas as pd
from mossn import prepare_data, run_single_sample

links = pd.DataFrame({
    "protein1": ["A", "A", "B"],
    "protein2": ["B", "C", "C"],
})
expression = pd.DataFrame(
    {"sample_1": [4.2, 7.1, 3.5], "sample_2": [5.3, 6.4, 2.8]},
    index=["A", "B", "C"],
)

graph, base_weights, expression = prepare_data(expression, links=links)
edge_table = run_single_sample("sample_1", graph, base_weights, expression)
```

`edge_table` has columns `Sample`, `Node1`, `Node2`, `BaseWeight`, and
`FinalWeight`. `BaseWeight` is `1.0` for every PPI edge in standard MOSSN.

Use `run_samples(...)` to process all, or a selected subset, of matrix columns.
The switches `use_correction=False`, `use_rwr=False`, and `use_seed=False`
correspond to the noCorr, noRWR, and noSeed single-omics ablations.

## Multi-omics models

All multi-omics functions expect an `omic_data` dictionary containing
`"EXP"` and, as needed, `"MET"` and/or `"CNV"` gene × sample dataframes.
Sample IDs are normalized by replacing `-` with `_` and keeping the first 12
characters, matching the analysis workflow.

### MOSSN-Direct

MOSSN-Direct maintains a PPI graph only for the expression layer. Each
auxiliary MET/CNV node is connected solely to its corresponding expression
gene. Cross-layer weights are based on within-sample cross-omics concordance.

```python
from mossn import prepare_data_direct_coupled, run_direct_coupled_single_sample

graph, base_weights, omics, exp_genes = prepare_data_direct_coupled(
    links, {"EXP": expression, "CNV": cnv}, coupled_omics=["CNV"]
)
edge_table = run_direct_coupled_single_sample(
    "sample_1", graph, base_weights, omics, exp_genes, coupled_omics=["CNV"]
)
```

## Bundled example data

```python
from mossn.example_data import load_example_expression, load_example_links

expression = load_example_expression()
links = load_example_links()
```

## License

`mossn` is distributed under a research-only license. Non-commercial research,
teaching, and evaluation use are allowed. Commercial use requires prior written
permission from the copyright holder.
