Description Usage Arguments Details Slots See Also Examples
S4 class for representing phylogenetic trees as a list of nodes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## S4 method for signature 'TreeMan,character'
x[[i]]
## S4 method for signature 'TreeMan,character,missing,missing'
x[i, j, ..., drop = TRUE]
## S4 method for signature 'TreeMan'
as.character(x)
## S4 method for signature 'TreeMan'
show(object)
## S4 method for signature 'TreeMan'
print(x)
## S4 method for signature 'TreeMan'
str(object, max.level = 2L, ...)
## S4 method for signature 'TreeMan'
summary(object)
## S4 method for signature 'TreeMan'
cTrees(x, ...)
|
x |
|
i |
node ID or slot name |
j |
missing |
... |
additional tree objects |
drop |
missing |
object |
|
max.level |
|
A TreeMan
object holds a list of nodes. The idea of the TreeMan
class is to make adding and removing nodes as similar as possible to adding
and removing elements in a list. Note that internal nodes and tips are
both considered nodes. Trees can be polytomous but not unrooted.
Each node within the TreeMan
ndlst
contains the following data slots:
id
: character string for the node ID
txnym
: name of taxonomic clade (optional)
spn
: length of the preceding branch
prid
: ID of the immediately preceding node, NULL if root
ptid
: IDs of the immediately connecting nodes
See below in 'Examples' for these methods in use.
ndlst
list of nodes
nds
vector of node ids that are internal nodes
nnds
numeric of number of internal nodes in tree
tips
vector of node ids that are tips
ntips
numeric of number of internal nodes in tree
all
vector of all node ids
nall
numeric of number of all nodes in tree
pd
numeric of total branch length of tree
tinds
indexes of all tip nodes in tree
prinds
indexes of all pre-nodes in tree
wspn
logical, do nodes have spans
wtxnyms
logical, do nodes have txnyms
ply
logical, is tree bifurcating
root
character of node id of root, if no root then empty character
updtd
logical, if tree slots have been updated since initiation or change
othr_slt_nms
vector, character list of additional data slots added to nodes
ndmtrx
matrix, T/Fs representing tree structure
randTree
, Node-class
,
phylo-to-TreeMan
, TreeMan-to-phylo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | library(treeman)
# Generate random tree
tree <- randTree(10)
# Print to get basic stats
summary(tree)
# Slots....
tree['tips'] # return all tips IDs
tree['nds'] # return all internal node IDs
tree['ntips'] # count all tips
tree['nnds'] # count all internal nodes
tree['root'] # identify root node
tree[['t1']] # return t1 node object
tree['pd'] # return phylogenetic diversity
tree['ply'] # is polytomous?
# Additional special slots (calculated upon call)
tree['age'] # get tree's age
tree['ultr'] # determine if tree is ultrametric
tree['spns'] # get all the spans of the tree IDs
tree['prids'] # get all the IDs of preceding nodes
tree['ptids'] # get all the IDs of following nodes
tree['txnyms'] # get all the taxonyms of all nodes
# In addition [] can be used for any user-defined slot
# Because all nodes are lists with metadata we can readily
# get specific information on nodes of interest
nd <- tree[['n2']]
summary(nd)
# And then use the same syntax for the tree
nd['nkids'] # .... nkids, pd, etc.
# Convert to phylo and plot
library(ape)
tree <- as(tree, 'phylo')
plot(tree)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.