Skip to main content

netComplex

netComplex scores protein-complex activity across samples by propagating gene expression signals through a sample-specific protein–protein interaction (PPI) network via Random Walk with Restart (RWR).

Algorithm overview

  1. Filter — retain only genes present in both the PPI network and the expression matrix.
  2. Rank-normalize — convert each sample's expression values to ranks in (0, 1].
  3. Re-weight edges — scale PPI edge scores by the expression ranks of both endpoints: weight = BaseScore × (rank_u × rank_v)^β.
  4. RWR — propagate the ranked expression as a restart signal over the weighted network to obtain node-level scores.
  5. Complex scoring — for each complex aggregate node scores into:
    • BaseActivity — expression-weighted mean of propagated node scores.
    • Coherence — mean pairwise score similarity across retained members × size penalty k/(k+1).
    • ComplexScore = BaseActivity × Coherence.

Installation

pip install netComplex

Quick start

import pandas as pd
from netcomplex import compute_all_sample_complex_scores, build_complex_score_matrix

# links: DataFrame with columns protein1, protein2, score
# expression_data: DataFrame, genes as index, samples as columns
# complex_data: DataFrame with columns Complex, Genes (semicolon-delimited)

scores = compute_all_sample_complex_scores(
    links=links,
    expression_data=expression_data,
    complex_data=complex_data,
    rwr_alpha=0.3,   # restart probability
    beta=0.5,        # edge re-weighting exponent
    gamma=1.0,       # coherence pairwise-similarity exponent
)

# Long-format table (one row per sample-complex pair)
print(scores.head())

# Wide-format matrix (complexes × samples)
matrix = build_complex_score_matrix(scores)

API reference

Function Description
prepare_data(links, expression_data) Filter shared genes and build base PPI graph.
run_rwr(sample_id, G, real_original_weights, expression_data, ...) Re-weight edges and run RWR for one sample.
compute_complex_score(sample_id, p_star, expression_ranked, complex_data, ...) Score all complexes for one sample.
compute_all_sample_complex_scores(links, expression_data, complex_data, ...) Run the full pipeline across all samples.
build_complex_score_matrix(all_complex_scores) Pivot long-format scores to a complex × sample matrix.
rank_normalize_series(sample_expression) Rank-normalize a single expression series to (0, 1].

Input formats

links — PPI network:

protein1 protein2 score
EGFR ERBB2 0.9

expression_data — gene × sample matrix (genes as row index, samples as column names).

complex_data — complex membership:

Complex Genes
COP9 signalosome COPS1;COPS2;COPS3

License

MIT

Metadata

Release files for netcomplex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netcomplex 0.1.0
File Size Uploaded Provenance Actions
netcomplex-0.1.0.tar.gz 6.1 kB Without provenance Details for netcomplex-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netcomplex 0.1.0
File Interpreter ABI Platform Actions
netcomplex-0.1.0-py3-none-any.whl Python 3 none any Details for netcomplex-0.1.0-py3-none-any.whl

Total release size: 12.5 kB

Release files / netcomplex-0.1.0.tar.gz

Download URL netcomplex-0.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9670758b9c842f0ae6ee0d1fec6158ea7c257b809efa567f7b4e947cc08ee425
BLAKE2b-256 checksum
How to use checksums
f34ea57bd43228c885712362365352fc8ed05b64995db1c6b4939a2edc065fb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / netcomplex-0.1.0-py3-none-any.whl

Download URL netcomplex-0.1.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1b85feeeecea9856150a33a255ad6c949ab4153e2ed15ce59cd2946ab2db2dc
BLAKE2b-256 checksum
How to use checksums
ea8f97aa28283e441be19ccde07929216b0b7c679bf827425bc46c8bc5d820e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Security for netcomplex 0.1.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page