Skip to contents

write.ancestral allows to export ancestral reconstructions. It writes out the tree, a tab delimited text file with the probabilities, an alignment of the the extant sequences and the most likely ancestral states. And a unaligned fasta file containg the most likely ancestral states. ancestral generates an object of class ancestral.

Usage

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

as.ancestral(tree, prob, align, ...)

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

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

# S3 method for class 'ancestral'
as.data.frame(x, ..., terminal = FALSE)

Arguments

x

an object of class ancestral

file

a file name. File endings are added.

tree

an object of class phylo.

prob

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

align

an object of class phyDat.

...

Further arguments passed to or from other methods.

terminal

logical, should terminal nodes included.

Value

write.ancestral returns the input x invisibly.

Details

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

See also

Examples

data(Laurasiatherian)
fit <- pml_bb(Laurasiatherian[,1:100], "JC", rearrangement = "none")
anc_ml <- anc_pml(fit)
write.ancestral(anc_ml)
# Can be also results from iqtree
align <- read.phyDat("ancestral_all.fasta", format="fasta")
tree <- read.tree("ancestral_tree.nwk")
df <- read.table("ancestral_state.tsv.gz", header=TRUE)
anc_ml_disc <- as.ancestral(tree, df, align)

plotAnc(anc_ml_disc, 20)


heatmapp(tree, align, nodes=TRUE)


unlink(c("ancestral_all.fasta", "ancestral_tree.nwk",
         "ancestral_state.tsv.gz", "ancestral_state.fasta"))