Question: Drop tip from multiPhylo object in R
2
gravatar for phylofun
11 months ago by
phylofun50
phylofun50 wrote:

I have 100s of phylogenetic trees in a multiPhylo object. There is one tip I need to drop from all of these trees. How can I do this in R?

R phylogeny • 668 views
ADD COMMENTlink modified 11 months ago by Brice Sarver3.5k • written 11 months ago by phylofun50

Provide an example input data. Make a dummy multiPhylo object with 2 or 3 trees, and post output of dput(myDummyTrees).

ADD REPLYlink modified 11 months ago • written 11 months ago by zx87549.4k
1
gravatar for Brice Sarver
11 months ago by
Brice Sarver3.5k
United States
Brice Sarver3.5k wrote:

A multiPhylo object is basically just a list of phylo objects. These can be operated on using the standard approaches for working with lists, so we use lapply to return a list for coercion back to the starting data type.

library(ape)
one <- rlineage(1, 1)
two <- rlineage(1, 1)
combined <- c(one, two)
# check: returns "multiPhylo"
class(combined)
results <- lapply(combined, drop.tip, "t2")
# explicitly convert back to an object of class multiPhylo
final <- do.call(c, results)
ADD COMMENTlink modified 11 months ago • written 11 months ago by Brice Sarver3.5k
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: 943 users visited in the last hour