Metadata-Version: 2.4
Name: nwnet
Version: 0.1.0
Summary: Small-world network based protein orthogroup inference pipeline.
Author: Yi-Fei Lu
Author-email: Xiao-Yang Zhi <xyzhi@ynu.edu.cn>
Maintainer-email: Xiao-Yang Zhi <xyzhi@ynu.edu.cn>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/MSE-Lab/NWNet
Project-URL: Repository, https://github.com/MSE-Lab/NWNet
Project-URL: Documentation, https://github.com/MSE-Lab/NWNet/tree/master/docs
Project-URL: Changelog, https://github.com/MSE-Lab/NWNet/blob/master/CHANGELOG.md
Project-URL: Issues, https://github.com/MSE-Lab/NWNet/issues
Keywords: orthology,orthogroup,small-world network,MCL,DIAMOND,bioinformatics,clustering
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: igraph>=0.11
Requires-Dist: numpy>=1.24
Requires-Dist: matplotlib>=3.7
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# NWNet

**Small-world network based orthogroup inference.**

NWNet infers orthogroups from protein FASTA files (one file per genome) through a four-stage pipeline. To avoid the quadratic cost of all-against-all sequence comparison, NWNet builds a Newman–Watts small-world graph over the input genomes and aligns proteins only along the edges of this graph; a graph-based network-optimisation step then recovers orthologs that the sparse initial alignment would otherwise miss.

## Key features

- **Small-world sparsification** — at the default neighbourhood size (k = n/4), NWNet removes roughly 70% of the genome-pair comparisons while keeping the genome graph connected and every genome sampled at least k times.
- **Four network filters** — reciprocal best hit (RBH), a fixed cutoff, and graph-based refinement with a median/MAD fallback (GBR, GBR_MAD).
- **Adaptive Markov clustering** — global MCL or adaptive MCL with a per-component inflation interpolated from the copy-number ratio (proteins per covered genome).
- **Main-tier accuracy** — on the Quest for Orthologs 2022 benchmark, NWNet reaches precision comparable to scalability-oriented methods such as FastOMA.

## Installation

NWNet requires Python ≥ 3.10. Install from source:

```bash
git clone https://github.com/MSE-Lab/NWNet.git
cd NWNet
pip install .
```

The Python dependencies are installed automatically; the external alignment, clustering and
phylogenetics tools listed below must be installed separately and be on `PATH`.

For development (editable install with test dependencies):

```bash
pip install -e ".[dev]"
pytest
```

## Dependencies

### Python libraries (installed automatically by pip)

| Library | Minimum version | Purpose |
| :--- | :--- | :--- |
| `igraph` | 0.11 | Graph construction, connected components, and network representation |
| `numpy` | 1.24 | Numerical computation |
| `matplotlib` | 3.7 | Plotting |

### External tools (install separately; must be on `PATH`)

| Tool | Required for | Purpose |
| :--- | :--- | :--- |
| [DIAMOND](https://github.com/bbuchfink/diamond) | `nwnet run` | Protein alignment (default backend) |
| [NCBI BLAST+](https://blast.ncbi.nlm.nih.gov/) (`blastp`) | `nwnet run` | Optional alternative backend (`--align-method blastp`) |
| [MCL](https://micans.org/mcl/) | `nwnet run` | Graph clustering |
| [MAFFT](https://mafft.cbrc.jp/alignment/software/) | `nwnet phylo` | Single-gene alignment |
| [trimAl](https://github.com/inab/trimal) | `nwnet phylo` | Alignment trimming |
| [FastTree](http://www.microbesonline.org/fasttree/) | `nwnet phylo` | Tree inference |

## Quick start

```bash
nwnet run \
  --input-dir /path/to/protein_fastas \
  --output-dir /path/to/result \
  --threads 32
```

The input is a directory of protein FASTA files, one per genome. The orthogroups are written to `result/Orthogroups/Orthogroups.txt`.

## Usage

NWNet provides four subcommands:

- **`nwnet run`** — the full orthology pipeline (small-world network → alignment → network optimisation → clustering → orthogroup output).
- **`nwnet compare`** — evaluate the agreement between two orthogroup sets (adjusted Rand index, adjusted/normalised mutual information, Fowlkes–Mallows index, V-measure, and split/merge statistics).
- **`nwnet pan`** — pangenome analysis: classify orthogroups into core/softcore/shell/cloud, fit the pangenome accumulation curve (Heaps' law), and produce visualisations.
- **`nwnet phylo`** — build a supermatrix species tree from single-copy core orthogroups (MAFFT + trimAl + FastTree).

Key options for `nwnet run`:

```
--network-method {RBH,cutoff,GBR,GBR_MAD}   base network filter (default: RBH)
--weighting      {identity,bitscore,evalue,normbitscore}
                                            edge weighting (default: normbitscore)
--k              n                          neighbourhood size (default: n/4)
--p              p                          random long-range edge probability (default: 0.2)
--mcl-mode       {global,adaptive}          clustering mode (default: adaptive)
--inflation      i                          MCL inflation (default: 1.2)
```

Run `nwnet run --help` for the complete list of options.

## Documentation

- [`nwnet run` user guide](https://github.com/MSE-Lab/NWNet/blob/master/docs/nwnet-run-user-guide.md) — the orthology inference pipeline
- [`nwnet compare` user guide](https://github.com/MSE-Lab/NWNet/blob/master/docs/nwnet-compare-user-guide.md) — compare two orthogroup sets
- [`nwnet pan` user guide](https://github.com/MSE-Lab/NWNet/blob/master/docs/nwnet-pan-user-guide.md) — pangenome analysis
- [`nwnet phylo` user guide](https://github.com/MSE-Lab/NWNet/blob/master/docs/nwnet-phylo-user-guide.md) — species-tree reconstruction

The guides are also shipped inside the source distribution under `docs/`.
The release history is in [CHANGELOG.md](https://github.com/MSE-Lab/NWNet/blob/master/CHANGELOG.md).

## Citation

The NWNet manuscript is in preparation. Until it appears, please cite the software itself:

> Lu Y-F, Zhi X-Y. NWNet: small-world network based orthogroup inference. Version 0.1.0.
> https://github.com/MSE-Lab/NWNet

This entry will be replaced by the paper upon publication.

## License

NWNet is licensed under the GNU General Public License v3 (GPL-3.0-or-later).
See [LICENSE](https://github.com/MSE-Lab/NWNet/blob/master/LICENSE).

Contact: Xiao-Yang Zhi ([xyzhi@ynu.edu.cn](mailto:xyzhi@ynu.edu.cn)).
