liamrevell / phytools

GNU General Public License v3.0
198 stars 56 forks source link

Tip numbers / labels #133

Closed theo-allnutt-bioinformatics closed 12 months ago

theo-allnutt-bioinformatics commented 1 year ago

Hi,

I want to reroot a tree using a tip label (species name) but 'reroot' requires the tip number, not label. Is there a way to get the tip number of a tip label?

Thanks,

Theo

theo-allnutt-bioinformatics commented 1 year ago

Worked it out:

outg<-'outgroup_spp_name'

c<-0
for (x in tree1$tip.label){
  c=c+1
  if (x==outg){rootnum1<-c}
}

print(rootnum1)

tree1<-reroot(tree1, rootnum1,position=0.5*tree1$edge.length[which(tree1$edge[,2]==rootnum1)])

rootedge.to.singleton(tree1)
liamrevell commented 12 months ago

Terrific.