prunning posterior distribution of trees in R
I have a posterior distribution of trees from a Bayesian analysis in nexus format. Is there a function in R to prune these trees to match my trait dataset? Something like the treedata function in the R package geiger seems to do what I want, but it does not handle multiple trees.
• 1,556 views
•
link
1 answer
keep.tip from ape and lapply should do the job:
library(ape)
trees <- .uncompressTipLabel(trees)
trees <- lapply(trees, keep.tip, trait_names)
trees
class(trees) <- "multiPhylo"
trees <- .compressTipLabel(trees)
Here trees is a multiPhylo object (you can read them in with read.nexus) and trait_names is a vector with the tip labels you want to keep.
• 0 views
•
link
Log in to answer this question.