write.ancestral: Export and convenience functions for ancestral...

View source: R/ancestral.R

write.ancestralR Documentation

Export and convenience functions for ancestral reconstructions

Description

write.ancestral allows to export ancestral reconstructions. It writes out the tree, a tab delimited text file with the probabilities and the alignment. ancestral generates an object of class ancestral.

Usage

write.ancestral(x, file = "ancestral")

ancestral(tree, align, prob)

## S3 method for class 'ancestral'
print(x, ...)

Arguments

x

an object of class ancestral.

file

a file name. File endings are added.

tree

an object of class phylo.

align

an object of class phyDat.

prob

an data.frame containing a matrix of posterior probabilities for each state and site.

...

Further arguments passed to or from other methods.

Details

This allows also to read in reconstruction made by iqtree to use the plotting capabilities of R.

Value

write.ancestral returns the input x invisibly.

See Also

ancestral.pml, plotAnc

Examples

data(Laurasiatherian)
fit <- pml_bb(Laurasiatherian[,1:100], "JC", rearrangement = "none")
anc_ml <- ancestral.pml(fit)
write.ancestral(anc_ml)
# Can be also results from iqtree
align <- read.phyDat("ancestral_align.fasta")
tree <- read.tree("ancestral_tree.nwk")
df <- read.table("ancestral.state", header=TRUE)
anc_ml_disc <- ancestral(tree, align, df)
plotAnc(anc_ml_disc, 20)
unlink(c("ancestral_align.fasta", "ancestral_tree.nwk", "ancestral.state"))

KlausVigo/phangorn documentation built on June 23, 2024, 10:49 p.m.