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

allow adding a tip whose origin is older than the root #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

josephwb
Copy link
Contributor

Allow adding an outgroup tip which diverged before the ingroup MRCA. The ape::bind.tree function which bind.tip wraps allows this, but the tree to which the tip is added ("x") must have a root.edge. The code submitted here does the necessary edits so that bind.tree does what is requested with no more arguments required from the user.

Examples

# this uses the existing example for `bind.tip`
tree<-pbtree(b=0.1, n=10);
plot(tree); axisPhylo();

# add an extant tip with known divergence time (4.5 units above root)
tree.extant <- bind.tip.alt(tree, tip.label="t_extant", position=4.5);

# plot
par(mfrow=c(1,2));
plot(tree); axisPhylo();
plot(tree.extant); axisPhylo();
par(mfrow=c(1,1));

# add an extinct tip that survived until 7.8 units before present
# 1. the root age of the original tree is RA=max(nodeHeights(tree))
# 2. we are adding position to that age (time to MRCA of all)
# so edge.length will be RA+position-7.8
RA=max(nodeHeights(tree))
EL <- RA + 4.5 - 7.8;
tree.extinct <- bind.tip.alt(tree, tip.label="t_extant", position=4.5, edge.length=EL);

# plot
par(mfrow=c(1,2));
plot(tree); axisPhylo();
plot(tree.extinct); axisPhylo();
par(mfrow=c(1,1));

Allow adding an outgroup tip which diverged before the ingroup MRCA.the `ape::bind.tree` function which `bind.tip` wraps allows this, but the tree to which the tip is added ("x") must have a `root.edge`. The code submitted here does the necessary edits so that `bind.tree` does what is requested with no more arguments required from the user.
@josephwb josephwb changed the title allow adding a tip "above" root allow adding a tip prior to root Apr 23, 2021
@josephwb josephwb changed the title allow adding a tip prior to root allow adding a tip whose origin is older than the root Apr 23, 2021
@josephwb
Copy link
Contributor Author

Anyway, this arose from a student wanting to an an extinct outgroup to her extant tree, which did not seem possible with the existing version of bind.tip.

HTH.

@josephwb
Copy link
Contributor Author

Ping.

If you are not interested in this, that is totally fine. Just please reject the PR so I can delete my fork.

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

Successfully merging this pull request may close these issues.

1 participant