-
Notifications
You must be signed in to change notification settings - Fork 78
Core
Wiki ▸ phylotree.js API ▸ Core
Functions tasked with creating phylogenetic tree objects, binding them to SVG elements, reading tree data, and accessing object data.
# d3.layout.phylotree([container])
Create a phylogenetic tree viewer with default settings (which can be modified before rendering). If container is specified (as a CSS selector), sets the DOM element whose events will be tracked by the tree viewer to; by default this is set to body
. If multiple tree viewers are shown on the same page, this needs to be set to different values for different objects (e.g. to enclosing <div>
elements).
Returns a phylotree
function (object) which is then instantiated with tree data (e.g. through Newick string).
var tree_object = d3.layout.phylotree ("#my_container");
... apply settings ...
tree_object = tree_object (newick_string);
# phylotree(data, [bootstrap])
Instantiate a tree object: build the tree structure and lay it out to screen coordinates (but do not render yet), using current settings.
If data is a string, calls an internal Newick string parser d3_phylotree_newick_parser to convert the string to an hierarchical collection of nodes consumed by d3.layout.hierarchy, with default accessor functions. If data is not a string, it is expected to be an object having the same format as that produced by d3_phylotree_newick_parser.
When set, bootstrap controls how internal node names are interpreted: as names (if false), or bootstrap support values (numeric, if true).
Returns the instantiated phylotree
object.
# node
A constituent component of the phylotree object, which represents a node in the phylogenetic tree, together with the incident branch (except for the root node). This is a JavaScript Object with the following keys, of which those shown in [] can be missing or null.
- name - the name of the node (set by d3_phylotree_newick_parser).
- original_child_oder - the order (left-to-right) in which this node appeared in its parents children list (set by d3_phylotree_newick_parser).
-
children -
null
for leafs, otherwise an array ofnode
objects (set by d3_phylotree_newick_parser). - [bootstrap_values] - if available, bootstrap (or other) support for the node/split/branch (set by d3_phylotree_newick_parser).
- [attribute] - if available, the value following the ':' in the Newick string; usually a branch length (set by d3_phylotree_newick_parser).
- annotation - any string included in [] following the node definition; see an example in d3_phylotree_newick_parser (set by d3_phylotree_newick_parser)
- [angle] - the angle (in radians) of the node in polar coordinates (radial layout only, set by placenodes).
- [radius] - the radial displacement (in pixels) of the node in polar coordinates, relative to the center of the layout (radial layout only, set by placenodes).
- depth - how many branches separate this node from the root (set by placenodes). Depth of the root node is 0.
-
parent - reference to the parent node, or
null
for the root (set by placenodes). -
screen_x - the x (left-to-right) coordinate of the node SVG object relative to the plotting area (set by update). Top left corner is (0,0). This value is obtained from the x,y pair set by placenodes by calling
phylotree.x_coord
, which is currently not exposed. -
screen_y - the y (top-to-botto,) coordinate of the node SVG object relative to the plotting area (set by update). Top left corner is (0,0). This value is obtained from the x,y pair set by placenodes by calling
phylotree.y_coord
, which is currently not exposed. - [text_align] - how the text label of the node will be aligned using this mode (e.g. start or end, set by update).
- [text angle] - the rotation transform for the text label (in degrees, set by update).