Skip to main content

Fast NeighbourNet (Rust) with Python bindings

Project description

DOI

fast-nnt

fast-nnt (read Fast Ent) is a simple Rust implementation of the Neighbour Net algorithm with both R and Python bindings.

Introduction

Fast-NNT is a Rust implementation of the NeighbourNet algorithm, designed for efficient phylogenetic analysis. It constructs split trees from distance matrices, providing a fast and reliable tool for researchers in evolutionary biology. R and Python bindings are provided so that users can easily integrate Fast-NNT into their existing workflows.

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.

Additionally, we provide R and Python bindings that allow you pass in memory data matrices directly with a single command and get results without having to write intermediate files. For installation instructions, please refer to the respective documentation for R and Python.

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.

Comparison to SplitsTree4

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")

# Or if CRAN is unavailable and you have Rust on your machine, i think this will work
devtools::install_github("rhysnewell/fast-nnt", subdir = "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

  • Work on parallelism. Not a priority as the program is fast enough.
  • Test on giant datasets. (works >400 taxa in ~5s, but need to test bigger)

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:

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

fastnntpy-0.2.1-cp313-cp313-win_amd64.whl (357.5 kB view details)

Uploaded CPython 3.13Windows x86-64

fastnntpy-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (553.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.1-cp313-cp313-macosx_11_0_arm64.whl (476.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fastnntpy-0.2.1-cp312-cp312-win_amd64.whl (357.8 kB view details)

Uploaded CPython 3.12Windows x86-64

fastnntpy-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (553.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (476.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fastnntpy-0.2.1-cp311-cp311-win_amd64.whl (358.2 kB view details)

Uploaded CPython 3.11Windows x86-64

fastnntpy-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (554.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.1-cp311-cp311-macosx_11_0_arm64.whl (478.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

fastnntpy-0.2.1-cp310-cp310-win_amd64.whl (358.2 kB view details)

Uploaded CPython 3.10Windows x86-64

fastnntpy-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (554.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.1-cp310-cp310-macosx_11_0_arm64.whl (478.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

fastnntpy-0.2.1-cp39-cp39-win_amd64.whl (359.3 kB view details)

Uploaded CPython 3.9Windows x86-64

fastnntpy-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (555.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.1-cp39-cp39-macosx_11_0_arm64.whl (479.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

fastnntpy-0.2.1-cp38-cp38-win_amd64.whl (358.7 kB view details)

Uploaded CPython 3.8Windows x86-64

fastnntpy-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (555.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.1-cp38-cp38-macosx_11_0_arm64.whl (478.9 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file fastnntpy-0.2.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fastnntpy-0.2.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 357.5 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

Hashes for fastnntpy-0.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 24c1879494a0a826a08c92ce172d71ddb6ec0c24f336369351a5b57e8febb343
MD5 1cbbca40e0682c98d1f0d4e158d27e40
BLAKE2b-256 a95457be369536d32d715d83f769105af16b6c9e8d542e4f25e77f3b27dbc8d7

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d2b1dd4235ad827e6e6a67b256f1651ddfba8ecc06a96a832809f1f0b056f6d
MD5 88d44f4e83446dd3cd711bc9300dce5d
BLAKE2b-256 d041ff79699cc88bd69b9d64938f48b01bd22181bb66532f012a87febdcbbbcc

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c0d3dc03ec63b44b70ef41691e0ebdce7c2c89e3f9c29f5021d40ab9c1b2c67
MD5 ccf0c670d61ca2403567c9d22d498bd0
BLAKE2b-256 26e6ff26d3a688c2f808d259a4a7a64850126aa8186d31029aeaba87094f132b

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fastnntpy-0.2.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 357.8 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

Hashes for fastnntpy-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 59d493587d66a1fb604673c953527863a8aaf19c60f784e59b0e41273c079527
MD5 7eaff27a76255c5a28451f25ea01f4cf
BLAKE2b-256 2c094004bdf2c5324f9b6f08199bd394830af3b3a403299b084e0ff4d3e1da71

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ad988fb5d2ca1553c80d726ca6b13b0f1d5924754a712969cfee9c10d1a8e5ca
MD5 6213a5b997a8fc4848a53daa33dc71f5
BLAKE2b-256 125d5d39726567d7f8464b462306ff309c4bfbf46a3bba84751838d91e0a9cf3

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd227c47d60cf953e615d347f4262e8819b9c7986c11ac1e600da83b1a17d321
MD5 67124ff69fac41520de9a3e8de610345
BLAKE2b-256 0f9d18d63da85f19ad64fe5b293497d601486d22c84ddc2ebc044f63136ef923

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: fastnntpy-0.2.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 358.2 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

Hashes for fastnntpy-0.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9e02e45ba32d6a9fe467204f864d82bd94b79b5675e74c312e57c5fb63458f6c
MD5 c651ec4e0ce0e18591c9e6ca48a8c8c1
BLAKE2b-256 436a6198dd201ee27b9f9dc2aeeab2f64fcccfd1dda675de563fae8f803c3a52

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7985d4d807b0e3745ca9ce49b44b852425369573f8fe6b70b0eeb5ab8acbf4ae
MD5 2399f5349828780ed06ef6308733ac10
BLAKE2b-256 da3683a6d85860ed3f3c3d283a351ea1a5c601fa447fe3d71352e78f7bef0f69

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eeb017a1823fb6c283040d81296a8e548859c6a0338bcccf2ecdffa0cbec875f
MD5 41d0cbb0b0803dca40c91b22376ad5c6
BLAKE2b-256 f3d1a388b12907cfa80f7328f69f74bbdf986b1e0f9aa31b98c3882f95c07a55

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: fastnntpy-0.2.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 358.2 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

Hashes for fastnntpy-0.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 293bdbb908963235f7f3d304b683c45b2dc540bb2457854674d99288a42a41be
MD5 bff2c7cd17f1e198913e7a007fc36ef7
BLAKE2b-256 a36e057459b4dc24804ff1086a21d14bc75db326c8ba3922ed0a38f746401614

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 570221c6eb861c3e585630f8daa75d6e56bca77212f2e486637571139a38e802
MD5 5d2c504bd2b938153c62b00ed51d46b2
BLAKE2b-256 2d52e28dfb4035852cdd071588b5a338c83379600369c8aba6e830aeddb9b59b

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 669e6813d92811147060659c9b6549a1abd912b5d2c8463f72c2e212ed205b26
MD5 18c58cf0500d426a0f78a91cb8e6a9aa
BLAKE2b-256 a0da3174c98e3f8de70969deabed27a513e3568343ee554ef7e2bdc1f22de159

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: fastnntpy-0.2.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 359.3 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

Hashes for fastnntpy-0.2.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 74440c25df28cc340c5665d427ec0224803eba6fcbaa00afa1bb8f513be43db1
MD5 451a14830f9488a404029e711d357c23
BLAKE2b-256 7f77761a1224f2562ea22d6baa6e8d60fb864f683787cb11f46eaf80d312e50a

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 039763ffd8a6d0a47beca036c10e9ee09c1c04df1a32d2f97cd2a102800fa88f
MD5 ef44172ed5d42edc5914d39e60dd8149
BLAKE2b-256 44faaa6755f84bc0d4eeb65e25be0439e4cc6dbf52ac43e4ad2076951583a269

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67d06ed801d14afbe20500f4cccce317572595e12ab430dbb2acaf8963f38076
MD5 e0951b8f44c9e4b943c9842befdeefc6
BLAKE2b-256 c4bab564af99d8e05d12b4c8ca94338a9d0161f8d63adc5cd922b72d27549a40

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: fastnntpy-0.2.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 358.7 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

Hashes for fastnntpy-0.2.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9de6a15cf311cab4efbcbf6d64442fcc1a469765b00708900035f50b90305412
MD5 6c4e87423bfc7e3a131e4b3efa8fe28a
BLAKE2b-256 f1c8e12a7369db7267fe72e0a9b69801fd682dbd057822ae444cb1fa81b95972

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3a30dbe02bd63b1686c311f910ad7583ea984ff087a92724126133b7e48c952
MD5 f3297db0a29b1e0678b9a196c0d57833
BLAKE2b-256 88fc8431fff06ec763807fff6da64322f4d6753dbbcaf4744050d55f4207d665

See more details on using hashes here.

File details

Details for the file fastnntpy-0.2.1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastnntpy-0.2.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed5f5b6cc32f072044c0fbefa6686160651dfbf66d0593c5983258792f040a38
MD5 2275230029f43de23d03e5b8df797057
BLAKE2b-256 9a6a3513f2de319de6042f0882c2197dfe21c3cb72fb3dd9da33d69de45532b4

See more details on using hashes here.

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