Skip to main content

viro-networks

PyPI CI & Coverage License: MIT

Compositional CLR Consensus Co-Occurrence Networks, Sloan Neutral Community Modeling, and Pure-Python Topological Hub Perturbation.

viro-networks is a standalone package within the Virome-Suite ecosystem developed at the Molecular Plant Pathology Lab, ICAR-Indian Sugarcane Research Institute.


Ecological & Statistical Methodology

  1. Sample-Size Safety Gate & CLR Normalization (viro_networks.clr_consensus):
    • Enforces a minimum cohort size guard ($N_{\text{samples}} < 5 \implies$ CohortInsufficientError / CLI exit code 4 ABSTAIN_INSUFFICIENT_SAMPLES) to prevent underpowered false-positive networks.
    • Applies Centered Log-Ratio (CLR) transformation across a pseudocount sensitivity grid $\delta \in {0.1, 0.5, 1.0}$ and reports edge Jaccard concordance across pseudocount extremes.
  2. Three-Estimator Bootstrap Consensus Network (viro_networks.clr_consensus): Retains an undirected signed edge $(i, j)$ if and only if $\ge 2$ of 3 compositional estimators agree in sign above threshold AND sample-level bootstrap stability across $B = 100$ resamples meets stability_threshold ($\ge 0.80$):
    • Positive-Floored SparCC: Log-ratio variation basis variance floored at $\omega_i^2 \ge \max(0.10,\mathrm{Var}(\mathrm{CLR}_{\cdot i}), 10^{-6})$ ($|r^{\text{SparCC}}| \ge 0.35$).
    • Shrinkage Graphical Partial Correlation: Regularized CLR correlation precision inversion $\mathbf{\Theta} = ((1 - \alpha)\mathbf{R}{\text{CLR}} + \alpha \mathbf{I})^{-1}$ with $\alpha = 0.15$ ($|\omega{ij}| \ge 0.25$).
    • CLR Rank Association: Spearman rank correlation on CLR coordinates ($|\rho^{\text{rank}}_{ij}| \ge 0.35$).
  3. Domain-Clipped Sloan Neutral Community Model (viro_networks.sloan_neutral): Fits Sloan's (2006) neutral immigration-drift parameter $N_e m \in [10^{-3}, 10^4]$ predicting taxon occupancy $\hat{f}_i = 1 - \mathrm{I}_d(2 N_e m p_i, 2 N_e m (1 - p_i))$ from mean relative abundance $p_i$, reporting zero-variance-guarded $R^2$, 95% Wilson score intervals, and Benjamini-Hochberg FDR-adjusted binomial departure $q$-values (neutral_drift_consistent, candidate_above_neutral_partition, candidate_below_neutral_partition).
  4. Topological Hub Perturbation (viro_networks.hub_perturbation): Computes degree centrality, exact Brandes shortest-path betweenness centrality, largest connected component (LCC) retention, and eigenvalue natural connectivity drop $\Delta \bar{\lambda}%$ upon in silico single-node removal using pure NumPy/Python (zero networkx dependency).

Installation

pip install viro-networks

Command-Line Usage (viro-networks)

Input Cohort Count Matrix (virome_cohort_counts.tsv)

Rows represent samples ($N \ge 5$) and columns represent viral taxa/OTUs (raw mapped read counts or RPKM/CPM):

sample_id	Badnavirus_A	Badnavirus_B	Poacevirus_SCSMV	Polerovirus_SCYLV	Begomovirus_C	Mastrevirus_D
SAMPLE_01	169	560	0	0	552	68
SAMPLE_02	1327	1053	3486	2921	665	112
SAMPLE_03	833	0	0	0	269	320
...

Run Network & Neutral Model Inference

viro-networks infer \
  --counts virome_cohort_counts.tsv \
  --metadata cohort_metadata.tsv \
  --bootstraps 100 \
  --stability 0.80 \
  --output network_results/

CLI Options (viro-networks infer)

Argument Required Default Description
--counts Yes — Tab-separated sample $\times$ taxon abundance matrix TSV (first column = sample_id)
--metadata No None Optional sample metadata TSV
--bootstraps No 100 Number of sample-level bootstrap resamples for consensus stability
--stability No 0.80 Minimum bootstrap selection frequency in $[0, 1]$ required to retain an edge
-o, --output Yes — Output directory for network edges, Sloan neutral fit, and hub rankings

Exit Codes: 0 = success, 2 = missing/malformed count table, 4 = safe abstention when cohort has $N < 5$ samples (ABSTAIN_INSUFFICIENT_SAMPLES).


Python API Usage

import pandas as pd
from viro_networks.clr_consensus import infer_consensus_network
from viro_networks.sloan_neutral import fit_sloan_neutral_model
from viro_networks.hub_perturbation import evaluate_hub_perturbation

df = pd.read_csv("virome_cohort_counts.tsv", sep="\t", index_col=0)
counts = df.to_numpy(dtype=float)
taxa = list(df.columns)

edges, net_diag = infer_consensus_network(counts, taxa, n_boot=100, stability_threshold=0.80)
sloan_rows, sloan_diag = fit_sloan_neutral_model(counts, taxa)
hubs = evaluate_hub_perturbation(taxa, [(e.taxon_a, e.taxon_b) for e in edges])

Output Files & Column Schema

  • consensus_edges.tsv: taxon_a, taxon_b, sign (+1 or -1), sparcc_r, partial_omega, spearman_rho, estimators_supporting, bootstrap_stability, pseudocount_concordance.
  • sloan_neutral_fit.tsv: taxon, mean_rel_abundance, observed_occurrence, predicted_occurrence, wilson_95_low, wilson_95_high, p_value, q_value, partition_class.
  • topological_hub_candidates.tsv: taxon, degree, degree_centrality, betweenness_centrality, natural_connectivity_drop_pct, lcc_fraction_after_removal.
  • network_summary.json: Cohort sample/taxon counts, pseudocount Jaccard concordance, $N_e m$ estimate, and $R^2$ goodness-of-fit.

Metadata

Release files for viro-networks 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 viro-networks 0.1.0
File Size Uploaded Provenance Actions
viro_networks-0.1.0.tar.gz 15.7 kB Without provenance Details for viro_networks-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 31.0 kB

Release files / viro_networks-0.1.0.tar.gz

Download URL viro_networks-0.1.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2fdef1b7e97b3522c80f61c7a1964338cbd3e7f0b810146481ac7e106df86b3a
BLAKE2b-256 checksum
How to use checksums
0ca2add43eb62bc820049e0feccb746fafd6fb9937c6f98ca16307074ba35c7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

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

Download URL viro_networks-0.1.0-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b01cbf00bb66db15c342723bfa98f2a794a64db229a7d16d6acdd0f16d45c38c
BLAKE2b-256 checksum
How to use checksums
84a96741c9b5d83a17707a1d10fd90da5975f09e8130e7d20dc61fd5b31ccc49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for viro-networks 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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