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.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{LinkNode{OneRoot, String, Dict{String, Any}, LinkBranch{OneRoot, String, Dict{String, Any}, Float64}}}: LinkNode 153, a tip of the tree with an incoming connection (branch 888).

LinkNode 120, a tip of the tree with an incoming connection (branch 195).

LinkNode 504, a tip of the tree with an incoming connection (branch 44).

julia> mrca(tree, tips) LinkNode Node 1003, an internal node with 1 inbound and 2 outbound connections (branches 1001 and 999, 1000)

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.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

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
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.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

Methods on Branches

LightGraphs.dstFunction
dst(tree::AbstractTree, branch)

Return the destination node for this branch.

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

Set the branch data for a branch of the tree.

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{AbstractNode})
roottype(::Type{AbstractBranch})

Returns root type from a tree type.

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

Returns type of nodes from a tree type.

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

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. For some node types, it will be able to extract the node name without reference to the 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, nodename)

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.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.validate!Function
validate!(tree::AbstractTree)

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

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

retrieve the dimensions of the branch lengths for the tree.

source