Biostar Beta. Not for public use.
prunning posterior distribution of trees in R
0
Entering edit mode
21 months ago
phylofun • 10
@phylofun51674

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 • 123 views
ADD COMMENTlink
2
Entering edit mode
21 months ago
Klaus S • 100
@Klaus S23907

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 COMMENTlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
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.3