Fast NeighborNet (Rust) with Python bindings
Project description
fast-nnt
fast-nnt (read Fast Ent) is a simple Rust implementation of the Neighbor Net algorithm
Introduction
Fast-NNT is a Rust implementation of the NeighborNet algorithm, designed for efficient phylogenetic analysis. It constructs split trees from distance matrices, providing a fast and reliable tool for researchers in evolutionary biology.
Why does this exist when SplitsTree is available?
Well, SplitsTree4/6 are GUI-based applications, while Fast-NNT is a command-line tool that can be easily integrated into automated workflows and pipelines. It's meant to be lightweight and simple to use, you provide a simple input and it generates the nexus file. You can then use this file in R or Python to generate your own plots. This is perfect for people who love to manually beautify their visualizations.
How do the results compare to SplitsTree?
Fast-NNT aims to produce results that are consistent with those generated by SplitsTree, but there may be differences due to the underlying implementations and algorithms used. Users are encouraged to compare the output from Fast-NNT with that of SplitsTree to assess any discrepancies and determine the best tool for their specific needs.
Installation
Install Rust via rustup.
Python
You can install the Python package via pip:
pip install fastnntpy
R
You can install the R package via:
install.packages("fastnntr")
CLI
cargo install fast-nnt
Alternatively, you can build from source. Clone and install this repo via:
git clone https://github.com/rhysnewell/fast-nnt.git
cd fast-nnt
cargo install --path .
Usage
For Python and R, complete usage examples can be found in test/python and test/R. But a brief summary is as follows.
Python
Read data in via numpy, pandas, or polars:
import fastnntpy as fn
import pandas as pd
data = pd.read_csv("test/data/large/large_dist_matrix.csv")
n = fn.run_neighbour_net(data, data.columns)
print("Labels")
print(len(n.get_labels()))
print("Splits Records")
print(len(n.get_splits_records()))
print("Node Translations")
print(len(n.get_node_translations()))
print("Node Positions")
print(len(n.get_node_positions()))
print("Graph Edges")
print(len(n.get_graph_edges()))
R
Read your distance matrix in using your preferred method (e.g., data.table):
library(fastnntr)
library(data.table)
data <- fread("test/data/large/large_dist_matrix.csv", header=TRUE)
# Load network
Nnet <- run_neighbornet_networx(data, names(data), TRUE)
The run_neighbornet_networx function will return an object almost identical to that produced by phangorn, so should be compatible with existing workflows.
CLI
Required input is a symmetrical distance matrix, ideally with a header row indicating the taxa labels. Can be separated by any delimiter.
To generate a split nexus file (mostly) identical to SplitsTree4 and SplitsTree6:
fast_nnt neighbour_net -t 4 -i test/data/large_dist_matrix.csv -d output_dir -o prefix -O splits-tree4
Use the new Huson 2023 ordering algorithm (default):
fast_nnt neighbour_net -t 4 -i test/data/large_dist_matrix.csv -d output_dir -o prefix -O huson2023
Output
The output will include a nexus file containing the split network and network layout.
Known issues
- Floating point drift in the CGNR function, as observed in the smoke_30 test.
- Not sure where it is happening, but the final results on real data end up looking pretty much the same so not sure if it is an issue. Will need to be fixed at some point.
TODO
- R bindings for direct use within R
- Python bindings for direct use within Python
- Work on parallelism. Not a priority as the program is fast enough.
- Test on giant datasets.
Citations
If you use this tool in your work, please cite the original authors work:
- Bryant & Huson 2023: D. Bryant and DH Huson, NeighborNet- improved algorithms and implementation. Front. Bioinform. 3, 2023.
- Bryant & Moulton 2004: D. Bryant and V. Moulton. Neighbor-net: An agglomerative method for the construction of phylogenetic networks. Molecular Biology and Evolution, 21(2):255– 265, 2004.
You can also cite this repository directly:
- Newell, R. J. P., & McMaster, E. S. (2025). Fast-NNT: Fast NeighborNet Split Trees For Unrooted Phylogenetic Analysis (v0.1.0). Zenodo. https://doi.org/10.5281/zenodo.16907380
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastnntpy-0.2.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 353.9 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e72be715e5d129decf0bb5129f6de7f8c8bc480bc62026f413abfba7581c5d61
|
|
| MD5 |
90cccd8efe47278cde46f44770bc09cd
|
|
| BLAKE2b-256 |
508f4b75a0b200e80f4110be64a0e98ef92c249ddcc1aaaffbc9d1303c0c50f7
|
File details
Details for the file fastnntpy-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 548.8 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dce916d0a3dce6dad7fcf55e1d091c17761def0e3e1e2473e91d2f7fc7bd271
|
|
| MD5 |
85c22f52e4ef2c2c3fc80bef8edbde60
|
|
| BLAKE2b-256 |
9157ee6ef5b00a56231bc40b2c4bbdd358deb58711a18cfb1989160183befdae
|
File details
Details for the file fastnntpy-0.2.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 473.6 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f5130805c66b44cbffbe6c88dd552bf684fbb0e47d0a3052081b5c8c375206d
|
|
| MD5 |
2c537f751187b6fe213810e4bddb3466
|
|
| BLAKE2b-256 |
2fa95906387d4aafc1914a12816efa2f02908f1b29211c495e31eb615e28c2f2
|
File details
Details for the file fastnntpy-0.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 354.2 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f104c995f1493e74a903e6edcabbb547af3086614a5de29e76d2ee91298a1de9
|
|
| MD5 |
43fdc1fce2dafb751b241ce2950dc632
|
|
| BLAKE2b-256 |
82d6a81e11cd23f898cf17786e27538653bf6edba9933ba555836f8a14fe2bb9
|
File details
Details for the file fastnntpy-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 548.4 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
204f316cc8d97b5cd8611e777ed45b9263e2a28bea4c10235e54a170c1ce4293
|
|
| MD5 |
c30f12a59d308a663da41bc9afb13b52
|
|
| BLAKE2b-256 |
2c865cb4606fae5fd9169489c43338626dac84f2d24560749a6009a1d868cdfa
|
File details
Details for the file fastnntpy-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 473.4 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7172e2a1ea15dae6278145893c78d6a721f6a1305f3e9e1a46a13ce1c2f41c6f
|
|
| MD5 |
405225145623025775c974057ff68369
|
|
| BLAKE2b-256 |
7a1b151d7145f68b6e14cde56f35cc30fe2d0fd2fe9d3794ec66cc4aa29bafb8
|
File details
Details for the file fastnntpy-0.2.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 354.1 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5426becb8038e65f64e26f3d64c8f1d97467753c390fec490e6ddca633aa4a51
|
|
| MD5 |
fe5e2abe54882f35c0c4c07831fe3c00
|
|
| BLAKE2b-256 |
5f67636356c0766e096ad1f4c75dc299b59fd883afa89f0b762e4597cda1793f
|
File details
Details for the file fastnntpy-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 549.4 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61c96ae362443c82171bd4c1bbe2d3c2fc2257111f49c0ac4b4abdb9458838b3
|
|
| MD5 |
075856efe5df53c044eab654fcfe756d
|
|
| BLAKE2b-256 |
9a5ab969f27870445f2b54b04aab3dac89003a3bef37edacb07ad64c40d0ba7b
|
File details
Details for the file fastnntpy-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 476.1 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e85fa2d63eb5c900d9d3c6ffb5efb03cf3d009b77f3e33dd1549c9eae0636ab9
|
|
| MD5 |
13f48076dcc6259df9d6eabc46f94f36
|
|
| BLAKE2b-256 |
af52104a38b3b4c43f67cf3499413bb6e39a693e13c1905f805a28bbcbf5c217
|
File details
Details for the file fastnntpy-0.2.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 354.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ed7c3b853a9b55302e5184bccfd6c4747b9667f3174abac4ac600f205e4993d
|
|
| MD5 |
5226e596dbd85e7d556103bf5c879598
|
|
| BLAKE2b-256 |
b40fdd41ad0e353ebc9f98d70900ff84d33636b4c10e0e7674989d153d17964e
|
File details
Details for the file fastnntpy-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 549.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff8b79adc2b85e2fac63ea446538bf1182d455185c32d6e4b94af34617b9eec8
|
|
| MD5 |
55ea6d9b3f65b98265cb4aadeecdfcbe
|
|
| BLAKE2b-256 |
a21eae85c933616b27468a2d9bff19e418d0c254822c6831b72ba95eb3f85bbe
|
File details
Details for the file fastnntpy-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 476.1 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59cfaee7fcdb4f06986f6a3d48e3a67d2d51871e8eb5471b7300d16d98dc1ee5
|
|
| MD5 |
a97b23bea027b7a2ec43c783fb39664b
|
|
| BLAKE2b-256 |
3768d2d77c3921eb911da8750b5d49dbb192ef4af8112cfc0b39fbb9adca055c
|
File details
Details for the file fastnntpy-0.2.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 355.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89222b7447bdab1be764430aead67ed2933e01daddb0d8a145389243bd208fee
|
|
| MD5 |
c4c22d8e7bfb7f6507ebb5ecda51e75c
|
|
| BLAKE2b-256 |
8ccb8c2431ae479e49899d00957a8d76c7389f6a7bdb1b38aad9fe36866a8adb
|
File details
Details for the file fastnntpy-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 550.3 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efdf29275e4ed44c2368d74764e9b0e969299ee3b91314537e2143e44eaa4d93
|
|
| MD5 |
c191c8dc1235673a4ff1d46737440f0c
|
|
| BLAKE2b-256 |
379f85d7ddc67cecbd54601d97431c0ee4fa3e5c6e074a781bb65dec495be307
|
File details
Details for the file fastnntpy-0.2.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 477.0 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aef315f23c8ad7f1d12b1835ab6f65813135d75c0226338ee2a98789736ba63c
|
|
| MD5 |
1da09c763d30c11533d63c41649fb88d
|
|
| BLAKE2b-256 |
8cc495afa8e48d4e2e50f3aa36f2caf7c0865e22c8d8c10f2e06124229470328
|
File details
Details for the file fastnntpy-0.2.0-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 354.8 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a15a102f710f28e599a59575104b0d3ac7934103dcda456760c4ed2cf821f8d
|
|
| MD5 |
a004833ed1a6cff04004120b4373944f
|
|
| BLAKE2b-256 |
58d588eac8a12935c6e8f39db369b6586fd0a95f353ba0e36dd13ede60678e4d
|
File details
Details for the file fastnntpy-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 550.0 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f56e79475312bccf9af4fd870a76486b54695bf7477a93ecb7295226bd581591
|
|
| MD5 |
0269a73ecfabae49d271a50c2992d5f1
|
|
| BLAKE2b-256 |
48f80862443c90cd221544d10f40edecd895b430497b3aa1b7dc0a89fd0428a3
|
File details
Details for the file fastnntpy-0.2.0-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastnntpy-0.2.0-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 476.4 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c499a208cdd17fe1b2bdee4c8b82a6921125fe9c733109ed6dfe6cdbb76c9a0
|
|
| MD5 |
55385b9c1b776b4943a4d3d24583af3d
|
|
| BLAKE2b-256 |
74c03ebecb60295a83afe4f9b95a7e3f04602c0583f5bfd13fe441996e3d7a36
|