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

If you are developing locally and have changed the R bindings:

rextendr::document()
devtools::load_all()

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.

Ordering and inference methods

Fast-NNT exposes two knobs that match the algorithmic choices in SplitsTree:

  • Ordering (ordering_method / -O): the cycle construction step. Options are splitstree4 (SplitsTree4-style ordering) and huson2023 (the improved ordering from Bryant & Huson 2023). The default is huson2023.
  • Inference (inference_method / --inference): the split-weight solver. Options are active-set (active-set NNLS, default) and splitstree4 (SplitsTree4-style optimizer).
  • For SplitsTree6-style defaults, use ordering_method="splitstree4" with inference_method="active-set" (or -O splits-tree4 --inference active-set in the CLI).
  • For SplitsTree4-style defaults, use ordering_method="splitstree4" with inference_method="splitstree4" (or -O splits-tree4 --inference splitstree4 in the CLI).

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,
    ordering_method="huson2023",
    inference_method="active-set",
)
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 <- fastnntr::run_neighbournet_networkx(
  data,
  ordering_method="huson2023",
  inference_method="active-set"
)

The run_neighbournet_networkx 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

Select the split-weight inference method:

fast_nnt neighbour_net -t 4 -i test/data/large_dist_matrix.csv -d output_dir -o prefix --inference active-set
fast_nnt neighbour_net -t 4 -i test/data/large_dist_matrix.csv -d output_dir -o prefix --inference splitstree4

Output

The output will include a nexus file containing the split network and network layout.

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.4-cp313-cp313-win_amd64.whl (406.1 kB view details)

Uploaded CPython 3.13Windows x86-64

fastnntpy-0.2.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (661.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.4-cp313-cp313-macosx_11_0_arm64.whl (528.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fastnntpy-0.2.4-cp312-cp312-win_amd64.whl (406.2 kB view details)

Uploaded CPython 3.12Windows x86-64

fastnntpy-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (661.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.4-cp312-cp312-macosx_11_0_arm64.whl (527.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fastnntpy-0.2.4-cp311-cp311-win_amd64.whl (405.7 kB view details)

Uploaded CPython 3.11Windows x86-64

fastnntpy-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (662.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.4-cp311-cp311-macosx_11_0_arm64.whl (531.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

fastnntpy-0.2.4-cp310-cp310-win_amd64.whl (405.9 kB view details)

Uploaded CPython 3.10Windows x86-64

fastnntpy-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (662.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.4-cp310-cp310-macosx_11_0_arm64.whl (531.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

fastnntpy-0.2.4-cp39-cp39-win_amd64.whl (406.9 kB view details)

Uploaded CPython 3.9Windows x86-64

fastnntpy-0.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (662.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.4-cp39-cp39-macosx_11_0_arm64.whl (531.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

fastnntpy-0.2.4-cp38-cp38-win_amd64.whl (406.1 kB view details)

Uploaded CPython 3.8Windows x86-64

fastnntpy-0.2.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (662.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

fastnntpy-0.2.4-cp38-cp38-macosx_11_0_arm64.whl (531.5 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fastnntpy-0.2.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 406.1 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fastnntpy-0.2.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 28b90ef072d9046ac5cc9614966b225e75412b33baa355ca715b8e4f2b2d6f7b
MD5 a742c0c8ce2917f989672e4b038fd6ce
BLAKE2b-256 6e90d712cec9f67893a4b6b33e743eef8c81bbfb79798407a1cb047966418fc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 274870f8e059a445c97304922ac611106a88af8a5af123e91b698972e201a972
MD5 2c434ce77548d4d31372266e0a6021a9
BLAKE2b-256 37bfa5718f560ba8aad2633790b73664562664a9b7dbac3d544a8d7c8f3bf198

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d7186f1c3d9b230db1c8f11af31739e93ccac95b40a9417ab8b4aab29fd78825
MD5 65eaa3426555bd09ca07eec961a60666
BLAKE2b-256 8e65baf91f3b8ce0308d27455c0f85fc6cf7af14a2695426dea57b820471cbef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastnntpy-0.2.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 406.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fastnntpy-0.2.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d9d0601eecfe7b8d779fd3981fb0ff2a6c32a2e924ec982acee3cd5ab60c7039
MD5 a5e2474c7f5d4d98029560f86ef586ec
BLAKE2b-256 22bc0c8418bd8a00ce21b72a9c4c25fcd77f0b722e27c9a53638b2eecd9876e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fd99b9a1a3eb6c7bd15c4de89d5cc98bbf0ec31dc662e890ff37851f2d79e35
MD5 3e137780334863257a2e3c78789445a4
BLAKE2b-256 02229ee3ee8529ef463c71858b19f3bf387c8b7f3b7400534794db3c8351665f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a076181fd761ca27c232da3e172d6979b8436633551cb6a0f4bdbf094dc6e455
MD5 3e1e152b5568bd5dad29f22becd79d00
BLAKE2b-256 ee0d09777f62383e756367bbb36bed41303d9d0e166e75f55906670e4654bbbf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastnntpy-0.2.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 405.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fastnntpy-0.2.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2f2fc159feb596b8285d55057ad60e6d119ab909d9fe26410ce4a2f9fcd69b0b
MD5 bcadb606ea65e233cd7ce3b943d1c74f
BLAKE2b-256 6185515cd7054a85b6e2ec0567a7a8980a1cda0f55a8c01d2269338bb9629116

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4d3dfa7a6dc0257c7d77733f212865028182760aac57f030e01ecaabd265221e
MD5 353d5262d38d472f9e5e3123e03a3b81
BLAKE2b-256 61872dee50e7fc4adbe79b15409e166be9730cd81d2c791948b1dd228a26da66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0936947cebaecdb1d0effed42de4903a2845d95d7e324d9fabad0814803fb50c
MD5 85fe2b3a97a663b531ab3d51fe3dc5cf
BLAKE2b-256 20031bbb161f6e6a4a7b923ac1ed24ccbc8a0c7244e76f43416573c2a4af53e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastnntpy-0.2.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 405.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fastnntpy-0.2.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d102a93a9e8fd6849045071e95a84358115a65e022499fdd077308ac52ec36ca
MD5 2f5d52b0a15ed93ddb03f7028aa4c859
BLAKE2b-256 a95673e33aa7dfba3b2a0b562092551595ea6d341d0278e3249e39576fc77ebc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3237cfb41bf9cc5fd16acbed3998fcbaa0bac8cc5e99f410a5d1f17d7f1ad1e8
MD5 d21c5d44a0c8e7a047fe55f36eb6d8d4
BLAKE2b-256 08450e2cd15a84d86d66f91e71db66b807233a986afdbf8a9d2988a41d5fce96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a7fca5da13cd1f260e3d063cadac0efe9bdda757d23622f84ce94860b9ff685
MD5 11e8d103c08a762c1e955da6f17650de
BLAKE2b-256 1b5e09df064ac6c7c1a6502007683ae9d258a48c96dc89ad9f4ec9a63c53ef9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastnntpy-0.2.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 406.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fastnntpy-0.2.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ff7c28740e604dc9d5db428971e2f3497a74076c1e4cffe925af4e679cb3f454
MD5 1613441126a6d99ff845d07beea443a3
BLAKE2b-256 a029024b00f7e54cc61727a70694552ac53a2bb2febb933863138b066b6e5473

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ba69814fbd7a14405fb2f6c6c5679399a0aaa7b7bf2a311b06a72fb3d51ccef
MD5 cfab4343eccf179d102aa1e0e6f8db59
BLAKE2b-256 952b4c84e2bb3af54aee5075d12c4d55fcfc3970a83493bfd5c2403595444f23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3beeaad8db158320ca7419ef971341db1abc157830b2729280dee4d3b346a85a
MD5 df765ecb7ebf0b610ecc9ea29e991f19
BLAKE2b-256 fd5b1276cf8615578abe3af81ee45d4de27bea12be2c070333861f8f78804089

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastnntpy-0.2.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 406.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fastnntpy-0.2.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 772a030d0591a0e89765ab927dece6757a3c4e38367440208abb1e68f3ab2f8b
MD5 591f31837308524717353ae810b12f48
BLAKE2b-256 597bf8260a187d2f96de81702a0f9c5baef96eebab6c6eaf2945a0707b9b2e47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7cebf066da5d0aaa8e11614a74c9619b8067a3432e3f49209683648e8ca2658f
MD5 e71deee117e87a9888c4d3513c5dbe10
BLAKE2b-256 cda5fd2242e13de7cbb0e21d07a2076f40a08529f3262ca25a766a3b87363d7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastnntpy-0.2.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e48d02993ed18e44a8c7004a0c1a064c6fb7655627cb63eead2399bbec9734b3
MD5 0b7d5cfb481374c22f96830ace84150c
BLAKE2b-256 f06f643586503cae4545a4db36b39afa1dec80d14533c9bb1c60a73d2ddbc85e

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