Skip to main content

Balance and visualize multi-cluster interaction networks

Project description

netbalance

netbalance is a Python library and CLI tool for balancing and visualizing multi-cluster interaction (association) networks.

Installation

pip install netbalance

Quick start

Balancing an interaction network using entity-balanced sampling:

cat data/virus-host.csv | netbalance --seed 0 --max-iter 1000

Balancing an interaction network using uniform random sampling with a 1:1 negative-to-positive ratio:

cat data/virus-host.csv | netbalance -m balanced --negative-ratio 1.0

Visualizing a bipartite network:

cat data/virus-host.csv | netbalance viz -o virus-host.png

Data format

All inputs are CSVs where the first N columns are entity names (one per cluster) and the last column is a binary label (1 = positive interaction, 0 = negative):

A,B,interaction
A1,B2,1
A1,B4,0

The viz subcommand requires exactly 2 entity columns (bipartite).

Python API

If you prefer to use the Python API instead of the CLI, see the example notebook.

Example usage

Balancing and visualizing a virus-host interaction network

The following cammand uses the entity-balanced sampling method to balance a virus-host interaction network, then visualizes the balanced network as a bipartite graph.

cat data/virus-host.csv | netbalance --seed 0 --max-iter 20000 --delta 0.001| netbalance viz -o virus-host.png

The resulting graph is shown below:

virus-host

Entity-balanced sampling without the degree-ratio guided intialization

cat data/virus-host.csv | netbalance --seed 0 --max-iter 20000 --delta 0.001 --no-heuristic

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netbalance-0.2.0.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netbalance-0.2.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file netbalance-0.2.0.tar.gz.

File metadata

  • Download URL: netbalance-0.2.0.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for netbalance-0.2.0.tar.gz
Algorithm Hash digest
SHA256 92ee002cb265d613fdd49243a7bc41c9e2806b6129d767be1da60d43b23d80bb
MD5 fedcf574a09585c7833a2a22bf226a40
BLAKE2b-256 6bafce153cadbf2ae4f641d832974e899141af6d0fb2f92b563b985dd00a8309

See more details on using hashes here.

Provenance

The following attestation bundles were made for netbalance-0.2.0.tar.gz:

Publisher: python-publish.yml on sobhanAhmadian/netbalance

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file netbalance-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: netbalance-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for netbalance-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ec6838787f1164a3f9c1e00c8255f885ae75d16d22537106ec89ca1befe3659
MD5 70e7c646c3d262213c84c719472bfda3
BLAKE2b-256 1f1e438455d6075acae504e502cf0a6141da1b3e5f7cfe0a91e530542b11db80

See more details on using hashes here.

Provenance

The following attestation bundles were made for netbalance-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on sobhanAhmadian/netbalance

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page