Question: Drop tip from multiPhylo object in R
2
gravatar for phylofun
15 days 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 • 111 views
ADD COMMENTlink modified 13 days ago by Brice Sarver2.9k • written 15 days 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 14 days ago • written 14 days ago by zx87548.2k
1
gravatar for Brice Sarver
13 days ago by
Brice Sarver2.9k
United States
Brice Sarver2.9k 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 13 days ago • written 13 days ago by Brice Sarver2.9k
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: 2057 users visited in the last hour