emmanuelparadis / ape

analysis of phylogenetics and evolution

Home Page:http://ape-package.ird.fr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v5.8 drop.tip unexpected behavior

colejensen opened this issue · comments

Hello,

I was checking some functions with the new update and noticed that drop.tip was producing some interesting results. Specifically when trim.internal = FALSE and subtree = FALSE.

I've attached a small example tree to highlight the problem. In this example, all the tips other than the "Germline" are supposed to be dropped. I would expect this to produce a tree with the germline and another branch that highlights that the others were dropped, not a number of branches as I currently get.

Best,
Cole
forApe.zip

Hello,

The effect of trim.internal = FALSE affects only the internal branches; the terminal ones are always deleted (if they are targeted by the other options). I think these commands can help to see more clearly what's going on there:

layout(matrix(1:2, 2))
plot(phy, show.node.label = TRUE, tip.color = "green")
plot(tphy, show.node.label = TRUE, tip.color = "green")

Best,
Emmanuel

Hello,

I see, thank you. I was hoping to find something that did trim the tree to the node that connected the dropped tips to the remaining tree. I found that the options trim.internal = FALSE coupled with subtree = TRUE did something along those lines. Does this seem like an appropriate way to do this?

For example:

target_node <- 16
tphy <- ape::drop.tip(phy, collapse.singles = TRUE, trim.internal = FALSE, tip =
ape::extract.clade(phy, node = target_node)$tip.label, subtree = TRUE)

Best,
Cole

I'm not 100% sure to see what you want to do, but what about calling drop.tip() several times playing with its options? If you use it first with trim.internal = FALSE, then some (previously) internal branches become terminal and you can delete them selectively calling drop.tip() again but keeping trim.internal = TRUE.

As a side note, you can see ?identify.phylo and the options described: this could help you select the tip(s) you want to delete (unless you want to run this one many trees...)

Best,
Emmanuel