MOSSN
mossn packages the MOSSN algorithm for constructing sample-specific protein
interaction networks from gene expression data, together with a data-driven
mode and a direct-coupled multi-omics extension.
Highlights
- Single-sample and multi-sample workflows for sample-specific network scoring
- Support for either a PPI links table or a custom
networkx.Graph - Data-driven graph construction when no prior network is available
- Direct-coupled multi-omics workflow for integrating matched omics layers
- Bundled example datasets for quick experiments and reproducible demos
Method Overview
MOSSN builds a sample-specific interaction network by combining a background protein-protein interaction graph with sample-level molecular measurements. By default, every background edge starts with the same weight, following the uniform MOSSN workflow. Input edge scores can be enabled explicitly. In the single-omics workflow, the package follows four main steps:
- Filter the background network and expression matrix to their shared genes.
- Reweight each edge using IQR-normalized sample expression and the
gammacorrection strength. - Run random walk with restart from high-expression seed genes, or from a uniform prior when seed selection is disabled.
- Combine edge-level correction and node-level importance into final sample-specific edge weights.
The data-driven workflow replaces the prior PPI graph with a graph inferred directly from expression correlations. The direct-coupled multi-omics workflow adds cross-layer edges linking expression nodes to other omics measurements for the same gene, then applies a similar propagation scheme on the coupled graph.
When To Use Which Workflow
- Use
prepare_data(...)andrun_single_sample(...)when you already have a curated PPI network and matched expression data. - Use
prepare_data_driven(...)when you want a graph inferred directly from the expression matrix. - Use
prepare_data_direct_coupled(...)when you have matched expression and additional omics layers such as CNV.
Installation
mossn supports Python 3.9, 3.10, and 3.11. The GitHub Actions CI workflow
tests these versions on every push and pull request.
pip install mossn
For local development:
pip install -e .[test]
Quick Start
import pandas as pd
from mossn import prepare_data, run_single_sample
links = pd.DataFrame(
{
"protein1": ["A", "A", "B"],
"protein2": ["B", "C", "C"],
"score": [0.8, 0.6, 0.9],
}
)
expression_data = 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_data = prepare_data(
expression_data=expression_data,
links=links,
)
edge_table = run_single_sample(
sample_id="sample_1",
graph=graph,
base_weights=base_weights,
expression_data=expression_data,
gamma=2.0,
rwr_alpha=0.3,
seed_quantile=0.9,
)
print(edge_table.head())
To process every sample in the expression matrix:
from mossn import prepare_data, run_samples
graph, base_weights, expression_data = prepare_data(
expression_data=expression_data,
links=links,
)
edge_table = run_samples(
graph=graph,
base_weights=base_weights,
expression_data=expression_data,
)
Core API
The recommended public API consists of these six functions:
prepare_data(...): build a single-omics background network from a links table ornetworkx.Graphrun_single_sample(...): infer a sample-specific network for one samplerun_samples(...): run the single-omics workflow across multiple samplesprepare_data_driven(...): infer a background graph directly from expression dataprepare_data_direct_coupled(...): construct a direct-coupled multi-omics graphrun_direct_coupled_single_sample(...): score one sample in the direct-coupled multi-omics setting
Common Inputs
PPI links table
The links table should contain:
protein1protein2score(only required whenuse_prior=True)
Expression matrix
The expression matrix should use:
- rows as genes or proteins
- columns as sample IDs
Main Parameters
The single-omics workflow exposes three main numeric parameters:
gamma: strength of expression-based edge reweightingrwr_alpha: restart probability in random walk with restartseed_quantile: expression quantile used to define seed genes
It also exposes the following switches:
use_seed=True: use high-expression seed genesuse_rwr=True: use random walk with restartuse_correction=True: use expression-based edge correctionuse_prior=False: useuniform_weightfor every background edge (default)use_prior=True: use input edge weights from the column selected byweight_key
For example, to disable seed genes:
edge_table = run_single_sample(
sample_id="sample_1",
graph=graph,
base_weights=base_weights,
expression_data=expression_data,
use_seed=False,
)
To use input edge scores instead of uniform weights:
graph, base_weights, expression_data = prepare_data(
expression_data=expression_data,
links=links,
use_prior=True,
)
Output Format
The main scoring functions return a tidy edge table with these columns:
Sample: sample identifierNode1: first endpoint of the interactionNode2: second endpoint of the interactionBaseWeight: background-network edge weight before sample-specific scoringFinalWeight: sample-specific edge score returned by MOSSN
This output format is designed to be easy to sort, filter, merge, and export for downstream biological analysis.
More Examples
Use your own network
import networkx as nx
from mossn import prepare_data, run_single_sample
from mossn.example_data import load_example_expression
graph = nx.Graph()
graph.add_edge("A", "B", weight=0.8)
graph.add_edge("B", "C", weight=0.6)
expression_data = load_example_expression()
graph, base_weights, expression_data = prepare_data(
expression_data=expression_data,
graph=graph,
)
edge_table = run_single_sample(
sample_id=expression_data.columns[0],
graph=graph,
base_weights=base_weights,
expression_data=expression_data,
gamma=1.5,
rwr_alpha=0.2,
seed_quantile=0.8,
)
Use the bundled example data
from mossn import prepare_data, run_single_sample
from mossn.example_data import load_example_expression, load_example_links
links = load_example_links()
expression_data = load_example_expression()
graph, base_weights, expression_data = prepare_data(
expression_data=expression_data,
links=links,
)
edge_table = run_single_sample(
sample_id=expression_data.columns[0],
graph=graph,
base_weights=base_weights,
expression_data=expression_data,
)
Data-driven background network
from mossn import prepare_data_driven, run_samples
from mossn.example_data import load_example_expression
expression_data = load_example_expression()
graph, base_weights, expression_data = prepare_data_driven(
expression_data=expression_data,
cor_threshold=0.9,
)
edge_table = run_samples(
graph=graph,
base_weights=base_weights,
expression_data=expression_data,
sample_ids=[expression_data.columns[0]],
)
Direct-coupled multi-omics
from mossn import prepare_data_direct_coupled, run_direct_coupled_single_sample
graph, base_weights, omic_data, exp_genes = prepare_data_direct_coupled(
links=links,
omic_data=omic_data,
coupled_omics=["CNV"],
)
edge_table = run_direct_coupled_single_sample(
sample_id=sample_id,
graph=graph,
base_weights=base_weights,
omic_data=omic_data,
exp_genes=exp_genes,
coupled_omics=["CNV"],
)
Example Data Helpers
The package includes:
- TCGA BLCA expression matrix
- STRING-derived PPI links
You can access them with:
from mossn.example_data import (
get_example_expression_path,
get_example_links_path,
load_example_expression,
load_example_links,
)
Repository Guide
- CONTRIBUTING.md: local development and pull request notes
.github/workflows/: CI and release automation.github/ISSUE_TEMPLATE/: issue forms for bug reports, feature requests, and usage questionsexamples/: runnable scriptstests/: automated test suitesrc/mossn/: package source code
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.
Development Status
The repository currently maintains CI coverage for Python 3.9, 3.10, and 3.11. If you encounter a version-specific issue, please open a GitHub issue and include your Python version and a minimal reproduction example.
Metadata
Release files for mossn 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mossn-0.1.2.tar.gz | 3.0 MB | Without provenance | Details for mossn-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mossn-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for mossn-0.1.2-py3-none-any.whl |
Total release size: 6.1 MB
Release files / mossn-0.1.2.tar.gz
| Download URL | mossn-0.1.2.tar.gz |
|---|---|
| Size | 3.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c9314a79fe481506da1216059e110bceeb92bc8591e441e476ea3f05f516b8f
|
|
BLAKE2b-256 checksum How to use checksums |
80b422799518246734f738bdcaaa414c4837ca77196106ff91a8ddec54905926
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.7
|
Release files / mossn-0.1.2-py3-none-any.whl
| Download URL | mossn-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b3dac4ebf75cab9c54ad008d7184f8dc07d1d3fd58f94ff7e44fb95cd8f36d6
|
|
BLAKE2b-256 checksum How to use checksums |
e4949af6ee6410b29aa78ee6495ec6103fcf0b478bda90bb50032c6e98f3dfa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.7
|
Security for mossn 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.