Getting tree attributes
Methods on TreeSets
Phylo.ntrees — Functionntrees(tree::AbstractTree)Returns the number of trees in a tree object, 1 for a OneTree tree type, and the count of trees for a ManyTrees type.
Phylo.gettree — Functiongettree(tree::AbstractTree, label)Returns a single OneTree object tree corresponding to the label given.
Phylo.gettrees — Functiongettrees(tree::AbstractTree)Returns an iterable of trees.
Phylo.nroots — Functionnroots(::AbstractTree)Returns the number of roots in a tree. For OneTree types, Unrooted trees will return 0, OneRoot trees should return 1, and manyroots tree (ones with multiple subtrees) will return the number of subtrees. ManyTrees types will return a Dict of counts of the number of roots for each tree in the set.
Phylo.getroots — Functiongetroots(::AbstractTree)
getroots(::AbstractTree, id)Returns a vector containing the root(s) of a single (OneTree) tree or a set of (ManyTrees) trees.
Phylo.gettreenames — Functiongettreenames(tree::AbstractTree)Returns the names of the trees.
Methods on Trees
Phylo.mrca — Functionmrca(tree::AbstractTree, target)Returns the node within tree that is the Most Recent Common Ancestor of the leaves (or internal nodes) defined by target. target can be an iterator over nodes or an AbstractArray of nodes. The return value has the same node type as the elements of target.
Examples
≡≡≡≡≡≡≡≡≡≡≡
julia> tree = open(parsenewick, Phylo.path("H1N1.newick")) RootedTree with 507 tips, 1013 nodes and 1012 branches. Leaf names are 227, 294, 295, 110, 390, ... [501 omitted] ... and 418
julia> tips = rand(collect(nodefilter(isleaf, tree)), 3) 3-element Vector{RecursiveNode{OneRoot, String, Dict{String, Any}, Dict{String, Any}, PolytomousBranching, Float64}}: leaf node '414' leaf node '232' leaf node '216'
julia> mrca(tree, tips) internal node 'Node 980'
Phylo.nodeheights — Functionnodeheights(tree::Phylo.AbstractTree; onlyleaves = false, noleaves = false)Returns an AxisArray of the height of all nodes in tree over the root node. onlyleaves and noleaves filter the nodes for leaves and internal nodes, respectively
Phylo.getleafnames — Functiongetleafnames(::AbstractTree[, ::TraversalOrder])Retrieve the leaf names from the tree (in some specific order).
Phylo.getleaves — Functiongetleaves(::AbstractTree[, ::TraversalOrder])Retrieve the leaves from the tree.
Phylo.nleaves — Functionnleaves(::AbstractTree)Returns the number of leaves (tips) in a tree.
Phylo.nnodes — Functionnnodes(::AbstractTree)Returns the number of nodes of a single tree, or a Dict of numbers of nodes for multiple trees.
Phylo.ninternal — Functionninternal(::AbstractTree)Returns the number of internal nodes of a single tree, or a Dict of numbers of nodes for multiple trees.
Phylo.nbranches — Functionnbranches(::AbstractTree)Returns the number of branches of a single tree, or a Dict of numbers of branches for multiple trees.
Phylo.distance — Functiondistance(tree::AbstractTree, node1, node2)Distance between two nodes on a tree
Phylo.distances — Functiondistances(tree::AbstractTree)Pairwise distances between all leaf nodes on a tree
Phylo.heighttoroot — Functionheighttoroot(tree::AbstractTree, node)Height of a node of the tree above the root
Phylo.heightstoroot — Functionheightstoroot(tree::AbstractTree)Height of all of the leaves of the tree above the root
Phylo.getroot — Functiongetroot(::AbstractTree)Returns the root of a single tree (must be only one tree for a ManyTrees tree).
Phylo.treenametype — Functiontreenametype(::Type{AbstractTree})Returns the name type for a tree type.
Phylo.gettreename — Functiongettreename(tree::AbstractTree)Returns the name of the single tree.
Phylo.roottype — Functionroottype(::Type{AbstractTree})
roottype(::Type{AbstractElt})Returns root type from a tree, node, branch or other element type.
Phylo.nodetype — Functionnodetype(::Type{AbstractTree})Returns type of nodes from a tree type.
Phylo.nodedatatype — Functionnodedatatype(::Type{<: AbstractTree})retrieve the node info type of a tree.
Phylo.nodenametype — Functionnodenametype(::Type{AbstractTree})
nodenametype(::Type{AbstractElt})Returns type of node names from a tree type.
Phylo.branchtype — Functionbranchtype(::Type{AbstractTree})Returns type of branches from a tree type.
Phylo.branchdatatype — Functionbranchdatatype(::Type{<: AbstractTree})retrieve the branch info type of a tree.
Phylo.branchnametype — Functionbranchnametype(::AbstractTree)Returns type of branch names from a branch type.
Phylo.getnodenames — Functiongetnodenames(::AbstractTree[, ::TraversalOrder])Return a vector of node names of a single tree (identified by id for a ManyTrees tree), or a Dict of vectors of node names for multiple trees.
Phylo.getnodename — Functiongetnodename(::AbstractTree, node)Returns the node name associated with a node from a tree.
Phylo.hasnode — Functionhasnode(tree::AbstractTree, node)Returns whether a tree has a given node (or node name) or not.
Phylo.getnode — Functiongetnode(tree::AbstractTree, node[name])Returns a node from a tree.
Phylo.getnodes — Functiongetnodes(::AbstractTree[, ::TraversalOrder])Returns the vector of nodes of a single tree, or a Dict of vectors of nodes for multiple trees.
Phylo.getinternalnodes — Functiongetinternalnodes(t::AbstractTree)Function to retrieve only the internal nodes from a tree, t, which does not include tips or root.
Phylo.getbranchnames — Functiongetbranchnames(tree::AbstractTree)Return a vector of branch names of a single tree, or a Dict of vectors of branch names for multiple trees.
Phylo.getbranchname — Functiongetbranchname(::AbstractTree, branch)
getbranchname(branch)Returns the branch name associated with a branch from a tree. For some branch types, it will be able to extract the branch name without reference to the tree.
Phylo.hasbranch — Functionhasbranch(tree::AbstractTree, branch)
hasbranch(tree::AbstractTree, source, dest)Does tree have a branch branch or a branch from source to dest?
Phylo.getbranch — Functiongetbranch(tree::AbstractTree, branch)
getbranch(tree::AbstractTree, source, dest)Returns a branch from a tree by name or by source and destination node.
Phylo.getbranches — Functiongetbranches(::AbstractTree)Returns the vector of branches of a single tree, or a Dict of vectors of branches for multiple trees.
Phylo.gettreeinfo — Functiongettreeinfo(tree::AbstractTree)
gettreeinfo(tree::AbstractTree, treename)Returns the info data associated with the tree(s).
Phylo.validate! — Functionvalidate!(tree::AbstractTree)Validate the tree by making sure that it is connected up correctly.
Phylo.invalidate! — Functioninvalidate!(tree::AbstractTree, state = missing)Confirm that the tree is no longer necessarily valid, and remove cache information.
Phylo.branchdims — Functionbranchdims(::Type{<: AbstractTree})retrieve the dimensions of the branch lengths for the tree.
Phylo.treetype — Functiontreetype(::Type{AbstractTree})Returns tree number (OneTree, ManyTrees) from a tree type.
Phylo.treesettype — Functiontreesettype(::Type{AbstractTree}, ::Type{LABEL} = String)Returns type of a TreeSet containing a collection of trees, from those trees' type and the type of label used to identify trees.
Methods on Nodes
Phylo.isleaf — Functionisleaf(tree::AbstractTree, node)Is the node (referenced by name or node object) a leaf of the tree?
Phylo.isroot — Functionisroot(tree::AbstractTree, node)Is the node (referenced by name or node object) a root of the tree?
Phylo.isinternal — Functionisinternal(tree::AbstractTree, node)Is the node (referenced by name or node object) internal to the tree (neither root nor leaf)?
Phylo.isunattached — Functionisunattached(tree::AbstractTree, node)Is the node (referenced by name or node object) unattached (i.e. not connected to other nodes)?
Graphs.degree — Functiondegree(tree::AbstractTree, node)Return the degree of a node including all connections.
Graphs.indegree — Functionindegree(tree::AbstractTree, node)Return in degree of node.
Graphs.outdegree — Functionoutdegree(tree::AbstractTree, node)Return out degree of node.
Phylo.hasinbound — Functionhasinbound(tree::AbstractTree, node)Does the node have an inbound connection?
Phylo.getinbound — Functiongetinbound(tree::AbstractTree, node)return the inbound branch to this node (returns name for node name, branch for node).
Phylo.getoutbounds — Functiongetoutbounds(tree::AbstractTree, nodename)Return the names of the outbound branches from this node.
Phylo.getconnections — Functiongetconnections(tree::AbstractTree, node, exclude = [])Returns all of the branches connected to a node.
Phylo.hasoutboundspace — Functionhasoutboundspace(tree::AbstractTree, node)Does the node have space for an[other] outbound connection?
Phylo.hasinboundspace — Functionhasinboundspace(tree::AbstractTree, node)Does the node have space for an inbound connection?
Phylo.getleafinfo — Functiongetleafinfo(::AbstractTree[, label])retrieve the leaf info for a leaf of the tree.
Phylo.setleafinfo! — Functionsetleafinfo!(::AbstractTree, table)Set the leaf info for the leaves of the tree.
Phylo.leafinfotype — Functionleafinfotype(::Type{<: AbstractTree})retrieve the leaf info type of a tree.
Phylo.getnodedata — Functiongetnodedata(::AbstractTree, node)retrieve the node data for a node of the tree.
Phylo.setnodedata! — Functionsetnodedata!(::AbstractTree, node, label, value)
setnodedata!(::AbstractTree, node, data)Set the node data for a node of the tree.
Phylo.hasheight — Functionhasheight(tree::AbstractTree, node)Does the node have a height defined?
Phylo.getheight — Functiongetheight(tree::AbstractTree, node)Return the height of the node.
Phylo.setheight! — Functionsetheight!(tree::AbstractTree, nodename, height)Set the height of the node.
Phylo.getparent — Functiongetparent(tree::AbstractTree, node)Return [the name of] the parent node for this node [name]. Second method may not be implemented for some node types.
Phylo.getancestors — Functiongetancestors(tree::AbstractTree, node)Return the name of all of the nodes that are ancestral to this node.
Phylo.getchildren — Functiongetchildren(tree::AbstractTree, node)Return the [name(s) of] the child node(s) for this node [name].
Phylo.getdescendants — Functiongetdescendants(tree::AbstractTree, node)Return the names of all of the nodes that descend from this node.
Phylo.getsiblings — Functiongetsiblings(tree::AbstractTree, node)Returns all of the siblings of a node. Must be implemented for any unrooted AbstractNode subtype, can be inferred from _getparent and _getchildren for a rooted node.
Phylo.renamenode! — Functionrenamenode!(tree::AbstractTree, oldnode[name], newname)Renames a node in a tree. Optional - not implemented for most tree types and returns false.
Methods on Branches
Graphs.src — Functionsrc(tree::AbstractTree, branch)Return the source node for this branch.
Graphs.dst — Functiondst(tree::AbstractTree, branch)Return the destination node for this branch.
Phylo.conn — Functionconn(tree::AbstractTree, branch, exclude)Return the other node connected to branch that is not exclude.
Phylo.conns — Functionconns(tree::AbstractTree, branch)Return the nodes connected to branch.
Phylo.haslength — Functionhaslength(tree::AbstractTree, branch)Return whether the branch has a length.
Phylo.getlength — Functiongetlength(tree::AbstractTree, branch)Return the length of this branch.
Phylo.hasrootheight — Functionhasrootheight(tree::AbstractTree)Does the tree have an explicit root height
Phylo.getrootheight — Functiongetrootheight(tree::AbstractTree)Get the tree's root height.
Phylo.setrootheight! — Functionsetrootheight!(tree::AbstractTree, height)Set the tree's root height.
Phylo.getbranchdata — Functiongetbranchdata(::AbstractTree, label)retrieve the branch data for a leaf of the tree.
Phylo.setbranchdata! — Functionsetbranchdata!(::AbstractTree, branch, label, value)
setbranchdata!(::AbstractTree, branch, data)Set the branch data for a branch of the tree.