prunning posterior distribution of trees in R
1
0
Entering edit mode
5.5 years ago
phylofun ▴ 50

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.

R phylogeny • 1.2k views
ADD COMMENT
2
Entering edit mode
5.5 years ago
Klaus S ▴ 160

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.

ADD COMMENT

Login before adding your answer.

Traffic: 1375 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6