Getting tree attributes

Methods on TreeSets

Phylo.ntreesFunction
ntrees(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.

source
Phylo.gettreeFunction
gettree(tree::AbstractTree, label)

Returns a single OneTree object tree corresponding to the label given.

source
Phylo.nrootsFunction
nroots(::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.

source
Phylo.getrootsFunction
getroots(::AbstractTree)
getroots(::AbstractTree, id)

Returns a vector containing the root(s) of a single (OneTree) tree or a set of (ManyTrees) trees.

source

Methods on Trees

Phylo.mrcaFunction
mrca(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'

source
Phylo.nodeheightsFunction
nodeheights(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

source
Phylo.getleafnamesFunction
getleafnames(::AbstractTree[, ::TraversalOrder])

Retrieve the leaf names from the tree (in some specific order).

source
Phylo.getleavesFunction
getleaves(::AbstractTree[, ::TraversalOrder])

Retrieve the leaves from the tree.

source
Phylo.nleavesFunction
nleaves(::AbstractTree)

Returns the number of leaves (tips) in a tree.

source
Phylo.nnodesFunction
nnodes(::AbstractTree)

Returns the number of nodes of a single tree, or a Dict of numbers of nodes for multiple trees.

source
Phylo.ninternalFunction
ninternal(::AbstractTree)

Returns the number of internal nodes of a single tree, or a Dict of numbers of nodes for multiple trees.

source
Phylo.nbranchesFunction
nbranches(::AbstractTree)

Returns the number of branches of a single tree, or a Dict of numbers of branches for multiple trees.

source
Phylo.distanceFunction
distance(tree::AbstractTree, node1, node2)

Distance between two nodes on a tree

source
Phylo.distancesFunction
distances(tree::AbstractTree)

Pairwise distances between all leaf nodes on a tree

source
Phylo.heightstorootFunction
heightstoroot(tree::AbstractTree)

Height of all of the leaves of the tree above the root

source
Phylo.getrootFunction
getroot(::AbstractTree)

Returns the root of a single tree (must be only one tree for a ManyTrees tree).

source
Phylo.roottypeFunction
roottype(::Type{AbstractTree})
roottype(::Type{AbstractElt})

Returns root type from a tree, node, branch or other element type.

source
Phylo.nodetypeFunction
nodetype(::Type{AbstractTree})

Returns type of nodes from a tree type.

source
Phylo.nodenametypeFunction
nodenametype(::Type{AbstractTree})
nodenametype(::Type{AbstractElt})

Returns type of node names from a tree type.

source
Phylo.getnodenamesFunction
getnodenames(::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.

source
Phylo.getnodenameFunction
getnodename(::AbstractTree, node)

Returns the node name associated with a node from a tree.

source
Phylo.hasnodeFunction
hasnode(tree::AbstractTree, node)

Returns whether a tree has a given node (or node name) or not.

source
Phylo.getnodeFunction
getnode(tree::AbstractTree, node[name])

Returns a node from a tree.

source
Phylo.getnodesFunction
getnodes(::AbstractTree[, ::TraversalOrder])

Returns the vector of nodes of a single tree, or a Dict of vectors of nodes for multiple trees.

source
Phylo.getinternalnodesFunction
getinternalnodes(t::AbstractTree)

Function to retrieve only the internal nodes from a tree, t, which does not include tips or root.

source
Phylo.getbranchnamesFunction
getbranchnames(tree::AbstractTree)

Return a vector of branch names of a single tree, or a Dict of vectors of branch names for multiple trees.

source
Phylo.getbranchnameFunction
getbranchname(::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.

source
Phylo.hasbranchFunction
hasbranch(tree::AbstractTree, branch)
hasbranch(tree::AbstractTree, source, dest)

Does tree have a branch branch or a branch from source to dest?

source
Phylo.getbranchFunction
getbranch(tree::AbstractTree, branch)
getbranch(tree::AbstractTree, source, dest)

Returns a branch from a tree by name or by source and destination node.

source
Phylo.getbranchesFunction
getbranches(::AbstractTree)

Returns the vector of branches of a single tree, or a Dict of vectors of branches for multiple trees.

source
Phylo.gettreeinfoFunction
gettreeinfo(tree::AbstractTree)
gettreeinfo(tree::AbstractTree, treename)

Returns the info data associated with the tree(s).

source
Phylo.validate!Function
validate!(tree::AbstractTree)

Validate the tree by making sure that it is connected up correctly.

source
Phylo.invalidate!Function
invalidate!(tree::AbstractTree, state = missing)

Confirm that the tree is no longer necessarily valid, and remove cache information.

source
Phylo.branchdimsFunction
branchdims(::Type{<: AbstractTree})

retrieve the dimensions of the branch lengths for the tree.

source
Phylo.treetypeFunction
treetype(::Type{AbstractTree})

Returns tree number (OneTree, ManyTrees) from a tree type.

source
Phylo.treesettypeFunction
treesettype(::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.

source

Methods on Nodes

Phylo.isleafFunction
isleaf(tree::AbstractTree, node)

Is the node (referenced by name or node object) a leaf of the tree?

source
Phylo.isrootFunction
isroot(tree::AbstractTree, node)

Is the node (referenced by name or node object) a root of the tree?

source
Phylo.isinternalFunction
isinternal(tree::AbstractTree, node)

Is the node (referenced by name or node object) internal to the tree (neither root nor leaf)?

source
Phylo.isunattachedFunction
isunattached(tree::AbstractTree, node)

Is the node (referenced by name or node object) unattached (i.e. not connected to other nodes)?

source
Graphs.degreeFunction
degree(tree::AbstractTree, node)

Return the degree of a node including all connections.

source
Phylo.hasinboundFunction
hasinbound(tree::AbstractTree, node)

Does the node have an inbound connection?

source
Phylo.getinboundFunction
getinbound(tree::AbstractTree, node)

return the inbound branch to this node (returns name for node name, branch for node).

source
Phylo.getoutboundsFunction
getoutbounds(tree::AbstractTree, nodename)

Return the names of the outbound branches from this node.

source
Phylo.getconnectionsFunction
getconnections(tree::AbstractTree, node, exclude = [])

Returns all of the branches connected to a node.

source
Phylo.hasoutboundspaceFunction
hasoutboundspace(tree::AbstractTree, node)

Does the node have space for an[other] outbound connection?

source
Phylo.getleafinfoFunction
getleafinfo(::AbstractTree[, label])

retrieve the leaf info for a leaf of the tree.

source
Phylo.getnodedataFunction
getnodedata(::AbstractTree, node)

retrieve the node data for a node of the tree.

source
Phylo.setnodedata!Function
setnodedata!(::AbstractTree, node, label, value)
setnodedata!(::AbstractTree, node, data)

Set the node data for a node of the tree.

source
Phylo.hasheightFunction
hasheight(tree::AbstractTree, node)

Does the node have a height defined?

source
Phylo.setheight!Function
setheight!(tree::AbstractTree, nodename, height)

Set the height of the node.

source
Phylo.getparentFunction
getparent(tree::AbstractTree, node)

Return [the name of] the parent node for this node [name]. Second method may not be implemented for some node types.

source
Phylo.getancestorsFunction
getancestors(tree::AbstractTree, node)

Return the name of all of the nodes that are ancestral to this node.

source
Phylo.getchildrenFunction
getchildren(tree::AbstractTree, node)

Return the [name(s) of] the child node(s) for this node [name].

source
Phylo.getdescendantsFunction
getdescendants(tree::AbstractTree, node)

Return the names of all of the nodes that descend from this node.

source
Phylo.getsiblingsFunction
getsiblings(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.

source
Phylo.renamenode!Function
renamenode!(tree::AbstractTree, oldnode[name], newname)

Renames a node in a tree. Optional - not implemented for most tree types and returns false.

source

Methods on Branches

Graphs.srcFunction
src(tree::AbstractTree, branch)

Return the source node for this branch.

source
Graphs.dstFunction
dst(tree::AbstractTree, branch)

Return the destination node for this branch.

source
Phylo.connFunction
conn(tree::AbstractTree, branch, exclude)

Return the other node connected to branch that is not exclude.

source
Phylo.connsFunction
conns(tree::AbstractTree, branch)

Return the nodes connected to branch.

source
Phylo.haslengthFunction
haslength(tree::AbstractTree, branch)

Return whether the branch has a length.

source
Phylo.setbranchdata!Function
setbranchdata!(::AbstractTree, branch, label, value)
setbranchdata!(::AbstractTree, branch, data)

Set the branch data for a branch of the tree.

source