Giter Site home page Giter Site logo

neighbor-joining's Introduction

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

neighbor-joining's People

Contributors

maciejkorzepa avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.