Finding out-group in unrooted tree Im trying to find the out-group in the alignment my data files file a and  file b both the case i'm getting NA when i run this     pars.a$tip.label[pars.a$edge[which.max(pars.a$edge.length),2]]

I tried NJ instead of upgma i do still get NA not sure what is the issue ,but at the same time when i used other alignment file with 50 sequence  works fine.

a&lt;-read.alignment("abhi_seq/final_abhi_tempa1.fas", format="fasta")
a.phydat&lt;-as.phyDat(a)
dist.a.phydat&lt;-dist.dna(as.DNAbin(a.phydat))
upgma.a&lt;-upgma(dist.a.phydat)
parsimony(upgma.a,a.phydat)
pars.a &lt;- optim.parsimony(upgma.a, a.phydat)
pars.a&lt;-acctran(pars.a, a.phydat)
pars.a$tip.label[pars.a$edge[which.max(pars.a$edge.length),2]]
the fact is that the present upgma tree as a midpoint rooting here, corresponding to node 46.

getRoot(upgma.a)


so for this kind of tree, I recommend you to use the midpoint() rooting function.

pars.a &lt;- optim.parsimony(upgma.a, a.phydat)
pars.a&lt;-acctran(pars.a, a.phydat)
plot(midpoint(pars.a))