npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

neighbor-joining

v1.0.4

Published

Neighbor Joining library for NPM.

Downloads

31

Readme

Neighbor-joining is an NPM package for creating phylogenetic trees. It bases on Rapid Neighbour-Joining algorithm.

Installation

To install Neighbor-joining package with NPM use: npm install neighbor-joining

Usage

var RNJ = new RapidNeighborJoining(D, taxa, copyDistanceMatrix, taxonIdAccessor);

Description of arguments used in initialization:

  • D - distance matrix (two dimensional array of size NxN)
  • taxa - array of size N with taxa data (such as strings or objects). Element (taxon) at first index corresponds to first row/column of the distance matrix and so on.
  • copyDistanceMatrix - flag specifying whether D can be modified or must be copied. Copying might minimally increase the initialization time. Default: false.
  • taxonIdAccessor - function for retrieving the name/identifier of a taxon. It is only called during Newick tree creation. Default: function(t){ return t.name }.

Example

var D = [
    [0,  5,  9,  9, 8],
    [5,  0, 10, 10, 9],
    [9, 10,  0,  8, 7],
    [9, 10,  8,  0, 3],
    [8,  9,  7,  3, 0]
];
var taxa = [
    {
        name: "A",
        genotype: "g1"
    },
    {
        name: "B",
        genotype: "g2"
    },
    {
        name: "C",
        genotype: "g3"
    },
    {
        name: "D",
        genotype: "g4"
    },
    {
        name: "E",
        genotype: "g5"
    }
];
var RNJ = new RapidNeighborJoining(D, taxa);
RNJ.run();
var treeObject = RNJ.getAsObject();
var treeNewick = RNJ.getAsNewick();

Then, treeObject will contain the following object:

{
    "taxon": null,
    "length": null,
    "children": [{
        "taxon": {
            "name": "C",
            "genotype": "g3"
        },
        "length": 2,
        "children": []
    }, {
        "taxon": null,
        "length": 2,
        "children": [{
            "taxon": null,
            "length": 3,
            "children": [{
                "taxon": {
                    "name": "A",
                    "genotype": "g1"
                },
                "length": 2,
                "children": []
            }, {
                "taxon": {
                    "name": "B",
                    "genotype": "g2"
                },
                "length": 3,
                "children": []
            }]
        }, {
            "taxon": null,
            "length": 2,
            "children": [{
                "taxon": {
                    "name": "D",
                    "genotype": "g4"
                },
                "length": 2,
                "children": []
            }, {
                "taxon": {
                    "name": "E",
                    "genotype": "g5"
                },
                "length": 1,
                "children": []
            }]
        }]
    }]
}

treeNewick will keep the following string:

"(C:2,((A:2,B:3):3,(D:2,E:1):2):2);"