Skip to main content

Creating a neighbour joining tree.

Project description

This repository stores a basic implementation for creating a neighbour joining tree from a given distance or similarity matrix.

Generating a distance matrix (A good way to do this is to use sklearn.DistanceMetrics with real data):

from sklearn.neighbors import DistanceMetric

dist = DistanceMetric.get_metric('euclidean')
X = [[0, 1, 2],
     [3, 4, 5],
     [2, 3, 1],
     [0, 2, 1]]
dist_mat = dist.pairwise(X)

Now that we have our distance matrix, we can now use it to construct a neighbour joining tree, giving some labels for the different samples:

import numpy
import TreeMethods.TreeBuild as TB

tree = TB.njTree(dist_mat, numpy.array(['A', 'B', 'C', 'D']))

We can then use ete3 to construct this into a tree object:

from ete3 import Tree

tree = Tree(tree)
print(tree)

   /-B
  |
  |   /-D
--|--|
  |   \-A
  |
   \-C

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TreeMethods-1.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

TreeMethods-1.0.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file TreeMethods-1.0.3.tar.gz.

File metadata

  • Download URL: TreeMethods-1.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for TreeMethods-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a890bee6de98d1f96425d59f5e17125f49504096262f16bc60586e81efb4db1f
MD5 1d79cb83ca124692fef6aeeadc4f9eb8
BLAKE2b-256 228fab8a71428b507449e9f492f75f02d07cade4fc7b909cc3e43c55b458804c

See more details on using hashes here.

File details

Details for the file TreeMethods-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: TreeMethods-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for TreeMethods-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b317f4a3e78e02143b971fd2fad5ab8171e84fc57980773c4366e28497da90f4
MD5 ed3741ca21a46580e1fd578035450eee
BLAKE2b-256 1562854233be901bdcfeb6098553025312e7671ef2577eb9e5ccee81b0245241

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