Skip to content

Midpoint_root versus midpoint.root: newer version roots incorrectly? #169

@NikoHensley

Description

@NikoHensley

I am not sure if my issue is a true error (and maybe not just user error), although I seem to have caught a discrepancy in the midpoint rooting function? I am reading in a rooted gene tree and re-rooting it at the midpoint. When I performed this using midpoint_root, the branch supports for the nodes seemed to be swapped or pushed up one node position relative to when I tried other midpoint functions like phangorn::midpoint or even midpoint.root() . I noticed this discrepancy when comparing midpoint rootings on visualizations created by FigTree and iTOL versus in R using ggtree. Here are images produced using ggtree in R that show the difference between the rooting functions:

Created with midpoint_root()

Image

Code used

mid_rooted_bs <- midpoint_root(unrooted_bs)  ## <- baaaadddd
mid_rooted_bs  %>% ggtree(layout = "roundrect",branch.length = "none") + 
  geom_nodelab(geom = "text",aes(label=label),size=3) + geom_rootedge(rootedge = 1)

Created with midpoint.root()

Image

Code used

mid.rooted_bs <- midpoint.root(unrooted_bs)
mid.rooted_bs  %>% ggtree(layout = "roundrect",branch.length = "none") + 
  geom_nodelab(geom = "text",aes(label=label),size=3) + geom_rootedge(rootedge = 1)

The latter is consistent with visualizations in FigTree (see below) and iTOL, but not the former, suggesting to me that the midpoint_root() function is not placing the bootstrap values at the correct nodes during re-rooting? For reference, note the position of the root is the same but the relative position of the bootstraps on the subsequent nodes along the backbones are shifted one down.

Visualization in FigTree for comparison
Image

I'm using

              _                           
platform       x86_64-apple-darwin20       
arch           x86_64                      
os             darwin20                    
system         x86_64, darwin20            
status                                     
major          4                           
minor          4.0                         
year           2024                        
month          04                          
day            24                          
svn rev        86474                       
language       R                           
version.string R version 4.4.0 (2024-04-24)
nickname       Puppy Cup  

And phytools v. 2.5-2
Image

Maybe I'm doing something wrong though or using a conflict? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions