Question: prunning posterior distribution of trees in R
0
gravatar for phylofun
17 months ago by
phylofun50
phylofun50 wrote:

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 • 391 views
ADD COMMENTlink modified 17 months ago by Klaus S140 • written 17 months ago by phylofun50
2
gravatar for Klaus S
17 months ago by
Klaus S140
Klaus S140 wrote:

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 written 17 months ago by Klaus S140
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1241 users visited in the last hour