bioconductor v3.9.0 Treeio
Base classes and functions for parsing and exporting phylogenetic trees. 'treeio' supports parsing analysis findings from commonly used software packages, allows linking external data to phylogeny and merging tree data obtained from different sources. It also supports exporting phylogenetic tree with heterogeneous associated data to a single tree file.
Link to this section Summary
Functions
Nnode
as.treedata
read.beast
drop.tip method
getNodeNum
get.placements
get.tree
get.treetext method
isTip
is.ggtree
Class "jplace" This class stores phylogenetic placements
label_branch_paml
mask
merge_tree
treeAnno.pml
raxml2nwk
read.jtree
read.astral
read.codeml
read.codeml_mlc
read.fasta
read.hyphy
read.hyphy.seq
read.iqtree
read.jplace
read.newick
read.nhx
read.paml_rst
read.phylip
read.phylip.seq
read.phylip.tree
read.phyloT
read.r8s
read.raxml
Objects exported from other packages
rename_taxa
rescale_tree
root
taxa_rename
Subset tree objects by related nodes
write.jtree
write.beast
write.jplace
Link to this section Functions
Nnodetreedata()
Nnode
Description
number of nodes
Usage
list(list("Nnode"), list("treedata"))(phy, internal.only = TRUE, ...)
Arguments
Argument | Description |
---|---|
phy | treedata object |
internal.only | whether only count internal nodes |
... | additional parameters |
Value
number of nodes
Author
guangchuang yu
Examples
Nnode(rtree(30))
astreedata()
as.treedata
Description
convert phylo to treedata
Usage
list(list("as.treedata"), list("phylo"))(tree, boot = NULL, ...)
Arguments
Argument | Description |
---|---|
tree | input tree, a phylo object |
boot | optional, can be bootstrap value from ape::boot.phylo |
... | additional parameters |
Details
converting phylo object to treedata object
Author
guangchuang yu
beast_mrbayes_parser()
read.beast
Description
read beast output
Usage
read.beast(file)
read.mrbayes(file)
Arguments
Argument | Description |
---|---|
file | beast file |
Value
beast
object
Author
Guangchuang Yu https://guangchuangyu.github.io
Examples
file <- system.file("extdata/BEAST", "beast_mcc.tree", package="treeio")
read.beast(file)
droptip_methods()
drop.tip method
Description
drop.tip method
drop.tip method
Usage
drop.tip(object, tip, ...)
drop.tip(object, tip, ...)
list(list("drop.tip"), list("phylo"))(object, tip, ...)
Arguments
Argument | Description |
---|---|
object | A treedata or phylo object |
tip | a vector of mode numeric or character specifying the tips to delete |
... | additional parameters |
Value
updated object
Seealso
Author
Casey Dunn http://dunnlab.org and Guangchuang Yu https://guangchuangyu.github.io
Examples
nhxfile <- system.file("extdata/NHX", "ADH.nhx", package="treeio")
nhx <- read.nhx(nhxfile)
drop.tip(nhx, c("ADH2", "ADH1"))
getNodeNum()
getNodeNum
Description
calculate total number of nodes
Usage
getNodeNum(tree)
Nnode2(tree)
Arguments
Argument | Description |
---|---|
tree | tree object |
Value
number
Author
Guangchuang Yu
Examples
getNodeNum(rtree(30))
Nnode2(rtree(30))
get_placements()
get.placements
Description
access placement information
Usage
get.placements(tree, ...)
list(list("get.placements"), list("jplace"))(tree, by = "best", ...)
Arguments
Argument | Description |
---|---|
tree | tree object |
... | additional parameters |
by | one of 'best' and 'all' |
Value
placement tibble
gettree()
get.tree
Description
access phylo slot
Usage
get.tree(x, ...)
Arguments
Argument | Description |
---|---|
x | tree object |
... | additional parameters |
Value
phylo object
Author
guangchuang yu
gettreetext_methods()
get.treetext method
Description
access tree text (newick text) from tree object
Usage
get.treetext(object, ...)
list(list("get.treetext"), list("treedata"))(object)
Arguments
Argument | Description |
---|---|
object | treedata object |
... | additional parameter |
Value
phylo object
isTip()
isTip
Description
whether the node is a tip
Usage
isTip(.data, .node, ...)
list(list("isTip"), list("tbl_tree"))(.data, .node, ...)
list(list("isTip"), list("phylo"))(.data, .node, ...)
list(list("isTip"), list("treedata"))(.data, .node, ...)
Arguments
Argument | Description |
---|---|
.data | phylo, treedata or tbl_tree object |
.node | node number |
... | additional parameters |
Value
logical value
Author
Guangchuang Yu
isggtree()
is.ggtree
Description
test whether input object is produced by ggtree function
Usage
is.ggtree(x)
Arguments
Argument | Description |
---|---|
x | object |
Value
TRUE or FALSE
Author
guangchuang yu
jplace_class()
Class "jplace" This class stores phylogenetic placements
Description
Class "jplace" This class stores phylogenetic placements
Author
guangchuang yu https://guangchuangyu.github.io
label_branch_paml()
label_branch_paml
Description
label branch for PAML to infer selection pressure using branch model
Usage
label_branch_paml(tree, node, label)
Arguments
Argument | Description |
---|---|
tree | phylo object |
node | node number |
label | label of branch, e.g. #1 |
Value
updated phylo object
Author
guangchuang yu
mask()
mask
Description
site mask
Usage
mask(tree_object, field, site, mask_site = FALSE)
Arguments
Argument | Description |
---|---|
tree_object | tree object |
field | selected field |
site | site |
mask_site | if TRUE, site will be masked. if FALSE, selected site will not be masked, while other sites will be masked. |
Value
updated tree object
Author
Guangchuang Yu
merge_tree()
merge_tree
Description
merge two tree object
Usage
merge_tree(obj1, obj2)
Arguments
Argument | Description |
---|---|
obj1 | tree object 1 |
obj2 | tree object 2 |
Value
tree object
Author
Guangchuang Yu
phyPML()
treeAnno.pml
Description
tree annotation of sequence substitution by comparing to parent node
Usage
phyPML(pmlTree, type = "ml")
Arguments
Argument | Description |
---|---|
pmlTree | tree in pml object, output of phangorn::optim.pml |
type | one of 'ml' and 'bayes' for inferring ancestral sequences |
Value
phangorn object
Author
Yu Guangchuang
printbeastList()
Description
print information of a list of beast trees
Usage
list(list("print"), list("beastList"))(x, ...)
Arguments
Argument | Description |
---|---|
x | a list of beast object |
... | no used |
Value
message
raxml2nwk()
raxml2nwk
Description
convert raxml bootstrap tree to newick format
Usage
raxml2nwk(infile, outfile = "raxml.tree")
Arguments
Argument | Description |
---|---|
infile | input file |
outfile | output file |
Value
newick file
Author
Guangchuang Yu
read_jtree()
read.jtree
Description
Import tree data from jtree file, which is JSON-based text and probably output by write.jtree
Usage
read.jtree(file)
Arguments
Argument | Description |
---|---|
file | tree file |
Value
treedata object
Author
guangchuang yu
readastral()
read.astral
Description
parse ASTRAL output newick text
Usage
read.astral(file)
Arguments
Argument | Description |
---|---|
file | ASTRAL Newick file |
Value
treedata object
Author
Guangchuang Yu
Examples
tt <- paste0(
"((species1,(species2,species3)'[pp1=0.75;pp2=0.24;pp3=0.01]':",
"1.2003685744180805)'[pp1=0.98;pp2=0.02;pp3=0]':0.9679599282730038,",
"((species4,species5)'[pp1=0.88;pp2=0.11;pp3=0.01]':1.2454851536484994))"
)
read.astral(textConnection(tt))
readcodeml()
read.codeml
Description
read baseml output
Usage
read.codeml(rstfile, mlcfile, tree = "mlc", type = "Joint")
Arguments
Argument | Description |
---|---|
rstfile | rst file |
mlcfile | mlc file |
tree | one of 'mlc' or 'rst' |
type | one of 'Marginal' or 'Joint' |
Value
A treedata
object
Author
Guangchuang Yu
Examples
rstfile <- system.file("extdata/PAML_Codeml", "rst", package="treeio")
mlcfile <- system.file("extdata/PAML_Codeml", "mlc", package="treeio")
read.codeml(rstfile, mlcfile)
readcodeml_mlc()
read.codeml_mlc
Description
read mlc file of codeml output
Usage
read.codeml_mlc(mlcfile)
Arguments
Argument | Description |
---|---|
mlcfile | mlc file |
Value
A codeml_mlc
object
Author
ygc
Examples
mlcfile <- system.file("extdata/PAML_Codeml", "mlc", package="treeio")
read.codeml_mlc(mlcfile)
readfasta()
read.fasta
Description
read FASTA file
Usage
read.fasta(fasta)
Arguments
Argument | Description |
---|---|
fasta | fasta file |
Details
This function supports both DNA or AA sequences
Value
DNAbin or AAbin object
Author
guangchuang yu
readhyphy()
read.hyphy
Description
read HYPHY output
Usage
read.hyphy(nwk, ancseq, tip.fasfile = NULL)
Arguments
Argument | Description |
---|---|
nwk | tree file in nwk format, one of hyphy output |
ancseq | ancestral sequence file in nexus format, one of hyphy output |
tip.fasfile | tip sequence file |
Value
A hyphy object
Author
Guangchuang Yu https://guangchuangyu.github.io
Examples
nwk <- system.file("extdata/HYPHY", "labelledtree.tree", package="treeio")
ancseq <- system.file("extdata/HYPHY", "ancseq.nex", package="treeio")
read.hyphy(nwk, ancseq)
readhyphyseq()
read.hyphy.seq
Description
parse sequences from hyphy output
Usage
read.hyphy.seq(file)
Arguments
Argument | Description |
---|---|
file | output of hyphy ancestral sequence inference; nexus format |
Value
DNAbin object
Author
guangchuang yu
Examples
ancseq <- system.file("extdata/HYPHY", "ancseq.nex", package="treeio")
read.hyphy.seq(ancseq)
readiqtree()
read.iqtree
Description
parse IQ-TREE output
Usage
read.iqtree(file)
Arguments
Argument | Description |
---|---|
file | IQ-TREE Newick text |
Value
treedata object
Author
Guangchuang Yu
readjplace()
read.jplace
Description
read jplace file
Usage
read.jplace(file)
Arguments
Argument | Description |
---|---|
file | jplace file |
Value
jplace
instance
Author
Guangchuang Yu
Examples
jp <- system.file("extdata", "sample.jplace", package="treeio")
read.jplace(jp)
readnewick()
read.newick
Description
read newick tree
Usage
read.newick(file, node.label = "label", ...)
Arguments
Argument | Description |
---|---|
file | newick file |
node.label | parse node label as 'label' or 'support' value |
... | additional parameter, passed to 'read.tree' |
Value
phylo or treedata object
Author
guangchuang yu
readnhx()
read.nhx
Description
read nhx tree file
Usage
read.nhx(file)
Arguments
Argument | Description |
---|---|
file | nhx file |
Value
nhx object
Author
Guangchuang Yu https://guangchuangyu.github.io
Examples
nhxfile <- system.file("extdata/NHX", "ADH.nhx", package="treeio")
read.nhx(nhxfile)
readpaml_rst()
read.paml_rst
Description
read rst file from paml (both baseml and codeml) output
Usage
read.paml_rst(rstfile, type = "Joint")
Arguments
Argument | Description |
---|---|
rstfile | rst file |
type | one of 'Marginal' or 'Joint' |
Value
A treedata
object
Author
Guangchuang Yu https://guangchuangyu.github.io
Examples
rstfile <- system.file("extdata/PAML_Baseml", "rst", package="treeio")
read.paml_rst(rstfile)
readphylip()
read.phylip
Description
parsing phylip tree format
Usage
read.phylip(file)
Arguments
Argument | Description |
---|---|
file | phylip file |
Value
an instance of 'phylip'
Author
Guangchuang Yu
Examples
phyfile <- system.file("extdata", "sample.phy", package="treeio")
read.phylip(phyfile)
readphylipseq()
read.phylip.seq
Description
read aligned sequences from phylip format
Usage
read.phylip.seq(file)
Arguments
Argument | Description |
---|---|
file | phylip file, currently only sequential format is supported |
Value
DNAbin object
Author
guangchuang yu
References
http://evolution.genetics.washington.edu/phylip/doc/sequence.html
readphyliptree()
read.phylip.tree
Description
parse tree from phylip file
Usage
read.phylip.tree(file)
Arguments
Argument | Description |
---|---|
file | phylip file |
Value
phylo or multiPhylo object
Author
guangchuang yu
readphyloT()
read.phyloT
Description
parse output from phyloT
Usage
read.phyloT(file, ...)
Arguments
Argument | Description |
---|---|
file | newick tree file |
... | additional parameters to read.tree |
Value
phylo object
Author
guangchuang yu
References
readr8s()
read.r8s
Description
parse output from r8s
Usage
read.r8s(file)
Arguments
Argument | Description |
---|---|
file | r8s output log file |
Value
multiPhylo object
Author
Guangchuang Yu
Examples
read.r8s(system.file("extdata/r8s", "H3_r8s_output.log", package="treeio"))
readraxml()
read.raxml
Description
parse RAxML bootstrapping analysis output
Usage
read.raxml(file)
Arguments
Argument | Description |
---|---|
file | RAxML bootstrapping analysis output |
Value
treedata object
Author
Guangchuang Yu
Examples
raxml_file <- system.file("extdata/RAxML", "RAxML_bipartitionsBranchLabels.H3", package="treeio")
read.raxml(raxml_file)
reexports()
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
list(" ", " ", list(list("ape"), list(list(list("read.tree")), ", ", list(list("read.nexus")), ", ", list(list("rtree")), ", ", list(list("write.tree")), ", ", list(list("write.nexus")), ", ", list(list("Nnode")), ", ", list(list("Ntip")), ", ", list(list("is.rooted")), ", ", list(list("as.phylo")))), " ", " ", " ", list(list("dplyr"), list(list(list("full_join")))), " ", " ", " ", list(list("magrittr"), list(list(list("%>%")))), " ", " ", " ", list(list("tibble"), list(list(list("data_frame")))),
"
", " ", " ", list(list("tidytree"), list(list(list("treedata")), ", ", list(list("get.fields")), ", ", list(list("get.data")), ", ", list(list("as.treedata")), ", ", list(list("ancestor")), ", ", list(list("parent")), ", ", list(list("child")), ", ", list(list("offspring")), ", ", list(list("rootnode")))), " ")
rename_taxa()
rename_taxa
Description
rename tip label of phylogenetic tree
Usage
rename_taxa(tree, data, key, value)
Arguments
Argument | Description |
---|---|
tree | tree object, either treedata or phylo |
data | data frame |
key | column in data that match tip label |
value | column in data for rename tip label |
Value
tree object
Author
Guangchuang Yu
rescale_tree()
rescale_tree
Description
rescale branch length of tree object
Usage
rescale_tree(tree_object, branch.length)
Arguments
Argument | Description |
---|---|
tree_object | tree object |
branch.length | numerical features (e.g. dN/dS) |
Value
update tree object
Author
Guangchuang Yu
root_method()
root
Description
re-root a tree
Usage
list(list("root"), list("phylo"))(object, node, ...)
list(list("root"), list("treedata"))(object, node, ...)
Arguments
Argument | Description |
---|---|
object | tree object |
node | node to reroot |
... | additional parameters |
Value
rerooted tree
Author
Guangchuang Yu
taxa_rename()
taxa_rename
Description
rename taxa
Usage
taxa_rename(tree, name)
Arguments
Argument | Description |
---|---|
tree | tree object |
name | a two column data.frame contains original name in 1st column and new name in 2nd column |
Value
updated tree object with new taxa name
Author
guangchuang yu
tree_subset()
Subset tree objects by related nodes
Description
This function allows for a tree object to be subset by specifying a node and returns all related nodes within a selected number of levels
Usage
tree_subset(tree, node, levels_back = 5, group_node = TRUE)
list(list("tree_subset"), list("phylo"))(tree, node, levels_back = 5,
group_node = TRUE)
list(list("tree_subset"), list("treedata"))(tree, node, levels_back = 5,
group_node = TRUE)
Arguments
Argument | Description |
---|---|
tree | a tree object of class phylo |
node | either a tip label or a node number for the given tree that will be the focus of the subsetted tree |
levels_back | a number specifying how many nodes back from the selected node the subsetted tree should include |
group_node | whether add grouping information of selected node |
Details
This function will take a tree and a specified node from
that tree and subset the tree showing all relatives back to a specified
number of nodes. This function allows for a combination of
ancestor
and offspring
to return a subsetted
tree that is of class phylo. This allows for easy graphing of the tree
with ggtree
Examples
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)
sub_tree <- tree_subset(tree, node = "A", levels_back = 3)
ggtree(sub_tree) + geom_tiplab() + geom_nodelab()
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)
sub_tree <- tree_subset(tree, node = "A", levels_back = 3)
ggtree(sub_tree) + geom_tiplab() + geom_nodelab()
write_jtree()
write.jtree
Description
Export treedata
object to json tree file
Usage
write.jtree(treedata, file = "")
Arguments
Argument | Description |
---|---|
treedata | treedata object |
file | output file. If file = "", print the output content on screen |
Value
output file or file content on screen
Author
guangchuang yu
writebeast()
write.beast
Description
Export treedata
object to BEAST NEXUS file. This function was adopted and modified from ape::write.nexus
Usage
write.beast(treedata, file = "", translate = TRUE,
tree.name = "UNTITLED")
Arguments
Argument | Description |
---|---|
treedata | treedata object |
file | output file. If file = "", print the output content on screen |
translate | whether translate taxa labels |
tree.name | name of the tree |
Value
output file or file content on screen
Author
guangchuang yu
Examples
nhxfile <- system.file("extdata/NHX", "phyldog.nhx", package="treeio")
nhx <- read.nhx(nhxfile)
write.beast(nhx)
writejplace()
write.jplace
Description
generate jplace file
Usage
write.jplace(nwk, data, outfile)
Arguments
Argument | Description |
---|---|
nwk | tree in newick format |
data | annotation data |
outfile | jplace output file |
Value
jplace file
Author
ygc