Hi R-sig-phylo,

I am trying to extract a subtree from a larger tree by selecting the parent node and all its descendants using extract.clade() from APE (I am using the most recent version of APE available on CRAN). I want to include the edge length of the subtending node from the original, larger tree as the new root for the extracted subtree. Setting root.edge = 1, should do this; however, I have found that it does not. I traced the issue to drop.tip(), which extract.clade() depends on, and provide code that reproduces the problem below.

Thanks,
Liam Johnson

library(ape)

tr <- read.tree(text = "(A:1,(B:1,(C:1,(D:1,E:1):1):1):1):1;")

# plot(tr, root.edge=TRUE)

tr2 <- drop.tip(tr, c("A", "B"), root.edge = 1)

# dev.new(); plot(tr2, root.edge=TRUE)

tr2$root.edge
#[1] 1 #root edge length is as expected

# however, changing the length of the edge leading to 'A' results in a change to the length of the extracted edge, i.e the root edge of the subtree

tr3 <- read.tree(text = "(A:4,(B:1,(C:1,(D:1,E:1):1):1):1):1;") #length 4

# plot(tr3, root.edge=TRUE)

tr4 <- drop.tip(tr3, c("A", "B"), root.edge = 1)

# dev.new(); plot(tr4, root.edge=TRUE)

tr4$root.edge
#[1] 4 #root now has length 4 when it should have length 1...

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to