Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5.8 drop.tip unexpected behavior #118

Open
colejensen opened this issue May 20, 2024 · 3 comments
Open

v5.8 drop.tip unexpected behavior #118

colejensen opened this issue May 20, 2024 · 3 comments

Comments

@colejensen
Copy link

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

@emmanuelparadis
Copy link
Owner

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

@colejensen
Copy link
Author

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

@emmanuelparadis
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants