Hi there,
I'm in need of rooting a tree (class phylo object
) for some analyses with ggtree
; however, despite having tried several options — e.g. root
, ape:root.phylo
etc. — I'm unable to root the tree on its origin node. I'm not sure whether this is the correct way to do so, but the sample I'm working with all belong to the same species and I wonder if there is a way to do so. Below I post a dput
of the tree in question, any help is greatly appreciated!
PHYLO dput
structure(list(edge = structure(c(22L, 22L, 21L, 21L, 20L, 20L,
19L, 19L, 18L, 18L, 17L, 17L, 16L, 16L, 15L, 15L, 14L, 14L, 13L,
13L, 13L, 5L, 7L, 6L, 12L, 10L, 11L, 3L, 4L, 8L, 9L, 2L, 21L,
1L, 20L, 19L, 22L, 16L, 18L, 14L, 17L, 15L), dim = c(21L, 2L)),
tip.label = c("INLUP00165", "INLUP00169", "INLUP00208", "INLUP00214",
"INLUP00228", "INLUP00233", "INLUP00245", "INLUP00325", "INLUP00332",
"INLUP00393", "INLUP00418", "INLUP00496"), Nnode = 10L, edge.length = c(0.706314467012421,
0.676942462826718, 1.09539346251638, 0.950531442120231, 1.33492008867954,
1.17678453611471, 1.2494034342362, 0.940871604044088, 2.09346818273513,
1.90197653708725, 1.16582596438367, 0.0754249480989515, 1.13062115914723,
0.0352713570056915, 0.0306742316503705, 0.815926955445321,
0.0049896673044284, 0.0359580898226367, 0.0119930676043047,
0.0241359746850401, 0.00378170608791852)), class = "phylo", order = "postorder")
P. S. there is actually something that seems to be working: phylo_r <- RootOnNode(phylo, rootnode(phylo), resolveRoot=TRUE)
but as a side effect prevents the tree from graphical rendering with the following
Error in $<-: ! Assigned data phylo$edge.length must be compatible with existing data. Existing data has 22 rows. Assigned data has 21 rows. Only vectors of size 1 are recycled. Caused by error in vectbl_recycle_rhs_rows(): ! Can't recycle input of size 21 to size 22
@Mark thanks, I look into this issue and tried out the suggestions you made. It is clear I need an outgroup and cannot re-root the tree simply based on its origin.
I simply wanted to test a specific plotting using clusters, which requires rooted tree as input, but at the moment we are still waiting to pick the correct species to use as outgroup. So, I guess this will need to wait for now, thanks again!