Skip to content

Latest commit

 

History

History
551 lines (423 loc) · 19.2 KB

API.md

File metadata and controls

551 lines (423 loc) · 19.2 KB

Classes

Phylotree

An instance of a phylotree. Sets event listeners, parses tags, and creates links that represent branches.

Functions

getBranchLengths()Array

Returns branch lengths

setBranchLength(attr)Object

Get or set branch length accessor.

normalize()

Normalizes branch lengths

scale(function)

Scales branch lengths

branchName(attr)

Get or set branch name accessor.

mrca()

Return most recent common ancestor of a pair of nodes.

deleteANode(The)

Delete a given node.

getTips()Array

Get the tips of the tree

getInternals()Array

Get the internal nodes of the tree

getRootNode()

Get the root node.

getNodes()Array

Get an array of all nodes.

getNodeByName(name)Node

Get a node by name.

assignAttributes(attributes)

Add attributes to nodes. New attributes will be placed in the annotations key of any nodes that are matched.

isLeafNode(A)Bool

Determine if a given node is a leaf node.

updateKeyName(old_key, new_key)

Update a given key name in each node.

reroot(node, if)Phylotree

Reroot the tree on the given node.

leftChildRightSibling(tree)Object

Traverses a tree that represents left-child right-sibling

clusterPicker(tree, bootstrap_thresold, diameter_threshold, root_node, missing_bootstrap_value)

Implements a linear time / space version of the Cluster picker algorithm

newickParser(nwk_str)Object

Parses a Newick string into an equivalent JSON representation that is suitable for consumption by hierarchy.

Optionally accepts bootstrap values. Currently supports Newick strings with or without branch lengths, as well as tagged trees such as (a,(b{TAG},(c{TAG},d{ANOTHERTAG})))

getNewick(annotator)String

Return Newick string representation of a phylotree.

loadAnnotations(tree, NEXUS)Object

Loads annotations from a nexus-formatted buffer and annotates existing tree nodes appropriately.

computeMidpoint(tree)Object

Compute midpoint of a phylogenetic tree

toggleCollapse(node)Phylotree

Toggle collapsed view of a given node. Either collapses a clade into a smaller blob for viewing large trees, or expands a node that was previously collapsed.

modifySelection(node_selecter, attr, place, skip_refresh, mode)

Modify the current selection, via functional programming.

getSelection()Array

Get nodes which are currently selected.

selectAllDescendants(node, terminal, internal)Array

Select all descendents of a given node, with options for selecting terminal/internal nodes.

selectionCallback(callback)

Getter/setter for the selection callback. This function is called every time the current selection is modified, and its argument is an array of nodes that make up the current selection.

nodeSpan(attr)

Get or set the current node span. If setting, the argument should be a function of a node which returns a number, so that node spans can be determined dynamically. Alternatively, the argument can be the string "equal", to give all nodes an equal span.

nodeLabel(attr)

Get or set nodeLabel accessor.

nodeBubbleSize(A)Float

Return the bubble size of the current node.

selectionLabel(attr)

Getter/setter for the selection label. Useful when allowing users to make multiple selections.

nodeSpan(attr)

Get or set the current node span. If setting, the argument should be a function of a node which returns a number, so that node spans can be determined dynamically. Alternatively, the argument can be the string "equal", to give all nodes an equal span.

selectionCallback(callback)

Getter/setter for the selection callback. This function is called every time the current selection is modified, and its argument is an array of nodes that make up the current selection.

Phylotree

An instance of a phylotree. Sets event listeners, parses tags, and creates links that represent branches.

Kind: global class

new Phylotree(nwk, options)

Returns: Phylotree - phylotree - itself, following the builder pattern.

Param Type Description
nwk Object A Newick string, PhyloXML string, or hierarchical JSON representation of a phylogenetic tree.
options Object - boostrap_values - type - format type

getBranchLengths() ⇒ Array

Returns branch lengths

Kind: global function
Returns: Array - array of branch lengths

setBranchLength(attr) ⇒ Object

Get or set branch length accessor.

Kind: global function
Returns: Object - The branch length accessor if getting, or the current this if setting.

Param Type Description
attr function Empty if getting, or new branch length accessor if setting.

normalize()

Normalizes branch lengths

Kind: global function

scale(function)

Scales branch lengths

Kind: global function

Param Type Description
function function that scales the branches

branchName(attr) ⇒

Get or set branch name accessor.

Kind: global function
Returns: The nodeLabel accessor if getting, or the current this if setting.

Param Type Description
attr function (Optional) If setting, a function that accesses a branch name from a node.

mrca() ⇒

Return most recent common ancestor of a pair of nodes.

Kind: global function
Returns: An array of strings, comprising each tag that was read.

deleteANode(The) ⇒

Delete a given node.

Kind: global function
Returns: The current phylotree.

Param Type Description
The Node node to be deleted, or the index of such a node.

getTips() ⇒ Array

Get the tips of the tree

Kind: global function
Returns: Array - Nodes in the current phylotree.

getInternals() ⇒ Array

Get the internal nodes of the tree

Kind: global function
Returns: Array - Nodes in the current phylotree.

getRootNode() ⇒

Get the root node.

Kind: global function
Returns: the current root node of the phylotree.

getNodes() ⇒ Array

Get an array of all nodes.

Kind: global function
Returns: Array - Nodes in the current phylotree.

getNodeByName(name) ⇒ Node

Get a node by name.

Kind: global function
Returns: Node - Desired node.

Param Type Description
name String Name of the desired node.

assignAttributes(attributes)

Add attributes to nodes. New attributes will be placed in the annotations key of any nodes that are matched.

Kind: global function

Param Type Description
attributes Object An object whose keys are the names of nodes to modify, and whose values are the new attributes to add.

isLeafNode(A) ⇒ Bool

Determine if a given node is a leaf node.

Kind: global function
Returns: Bool - Whether or not the node is a leaf node.

Param Type Description
A Node node in a tree.

updateKeyName(old_key, new_key) ⇒

Update a given key name in each node.

Kind: global function
Returns: The current this.

Param Type Description
old_key String The old key name.
new_key String The new key name.

reroot(node, if) ⇒ Phylotree

Reroot the tree on the given node.

Kind: global function
Returns: Phylotree - The current phylotree.

Param Type Description
node Node Node to reroot on.
if fraction specified, partition the branch not into 0.5 : 0.5, but according to the specified fraction

reroot~nodes

TODO add the option to root in the middle of a branch

Kind: inner property of reroot

leftChildRightSibling(tree) ⇒ Object

Traverses a tree that represents left-child right-sibling

Kind: global function
Returns: Object - An edge list that represents the original multi-way tree

Param Type Description
tree Object - the phylotree.js tree object

clusterPicker(tree, bootstrap_thresold, diameter_threshold, root_node, missing_bootstrap_value) ⇒

Implements a linear time / space version of the Cluster picker algorithm

Kind: global function
Returns: an array of clusters, where cluster = { 'root' : [root node of cluster], 'members' : [list of leaf. nodes], 'diameter' : max distance in the cluster, 'bootstrap' : bootstrap support at the root node }

Param Description
tree - the tree object
bootstrap_thresold - value in [0,1] that sets the stringency of bootstrap support
diameter_threshold - value >=0 that defines the maximum allowable pairwise distance in a cluster
root_node - if specified, traverse the tree starting here (useful for only looking at parts of the tree), tree root by default
missing_bootstrap_value - if a branch is missing bootstrap support value, use this value instead (1.0 by default)

newickParser(nwk_str) ⇒ Object

Parses a Newick string into an equivalent JSON representation that is suitable for consumption by hierarchy.

Optionally accepts bootstrap values. Currently supports Newick strings with or without branch lengths, as well as tagged trees such as (a,(b{TAG},(c{TAG},d{ANOTHERTAG})))

Kind: global function
Returns: Object - An object with keys json and error.

Param Type Description
nwk_str String A string representing a phylogenetic tree in Newick format.
bootstrap_values. Object

getNewick(annotator) ⇒ String

Return Newick string representation of a phylotree.

Kind: global function
Returns: String - newick - Phylogenetic tree serialized as a Newick string.

Param Type Description
annotator function Function to apply to each node, determining what label is written (optional).

loadAnnotations(tree, NEXUS) ⇒ Object

Loads annotations from a nexus-formatted buffer and annotates existing tree nodes appropriately.

Kind: global function
Returns: Object - Annotations

Param Type Description
tree Object Instatiated phylotree
NEXUS String string

computeMidpoint(tree) ⇒ Object

Compute midpoint of a phylogenetic tree

Kind: global function
Returns: Object - the calculated midpoint to root on { location: root_node, breakpoint: 0 }

Param Type Description
tree Object - the phylotree.js tree object

toggleCollapse(node) ⇒ Phylotree

Toggle collapsed view of a given node. Either collapses a clade into a smaller blob for viewing large trees, or expands a node that was previously collapsed.

Kind: global function
Returns: Phylotree - The current phylotree.

Param Type Description
node Node The node to toggle.

modifySelection(node_selecter, attr, place, skip_refresh, mode) ⇒

Modify the current selection, via functional programming.

Kind: global function
Returns: The current this.

Param Type Description
node_selecter function A function to apply to each node, which determines whether they become part of the current selection. Alternatively, if restricted-selectable mode is enabled, a string describing one of the pre-defined restricted-selectable options.
attr String (Optional) The selection attribute to modify.
place Boolean (Optional) Whether or not placenodes should be called.
skip_refresh Boolean (Optional) Whether or not a refresh is called.
mode String (Optional) Can be "toggle", "true", or "false".

getSelection() ⇒ Array

Get nodes which are currently selected.

Kind: global function
Returns: Array - An array of nodes that match the current selection.

selectAllDescendants(node, terminal, internal) ⇒ Array

Select all descendents of a given node, with options for selecting terminal/internal nodes.

Kind: global function
Returns: Array - An array of selected nodes.

Param Type Description
node Node The node whose descendents should be selected.
terminal Boolean Whether to include terminal nodes.
internal Boolean Whther to include internal nodes.

selectionCallback(callback) ⇒

Getter/setter for the selection callback. This function is called every time the current selection is modified, and its argument is an array of nodes that make up the current selection.

Kind: global function
Returns: The current selectionCallback if getting, or the current this if setting.

Param Type Description
callback function (Optional) The selection callback function.

nodeSpan(attr) ⇒

Get or set the current node span. If setting, the argument should be a function of a node which returns a number, so that node spans can be determined dynamically. Alternatively, the argument can be the string "equal", to give all nodes an equal span.

Kind: global function
Returns: The nodeSpan if getting, or the current phylotree if setting.

Param Type Description
attr function Optional; if setting, the nodeSpan function.

nodeLabel(attr) ⇒

Get or set nodeLabel accessor.

Kind: global function
Returns: The nodeLabel accessor if getting, or the current this if setting.

Param Type Description
attr function (Optional) If setting, a function that accesses a branch name from a node.

nodeBubbleSize(A) ⇒ Float

Return the bubble size of the current node.

Kind: global function
Returns: Float - The size of the bubble associated to this node.

Param Type Description
A Node node in the phylotree.

selectionLabel(attr) ⇒

Getter/setter for the selection label. Useful when allowing users to make multiple selections.

Kind: global function
Returns: The current selection label if getting, or the current phylotree if setting.

Param Type Description
attr String (Optional) If setting, the new selection label.

nodeSpan(attr) ⇒

Get or set the current node span. If setting, the argument should be a function of a node which returns a number, so that node spans can be determined dynamically. Alternatively, the argument can be the string "equal", to give all nodes an equal span.

Kind: global function
Returns: The nodeSpan if getting, or the current phylotree if setting.

Param Type Description
attr function Optional; if setting, the nodeSpan function.

selectionCallback(callback) ⇒

Getter/setter for the selection callback. This function is called every time the current selection is modified, and its argument is an array of nodes that make up the current selection.

Kind: global function
Returns: The current selectionCallback if getting, or the current this if setting.

Param Type Description
callback function (Optional) The selection callback function.