Drop tip from multiPhylo object in R
1
2
Entering edit mode
4.7 years ago
phylofun ▴ 50

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 • 2.5k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
2
Entering edit mode
4.7 years ago
Brice Sarver ★ 3.8k

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 COMMENT

Login before adding your answer.

Traffic: 1411 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