# 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.aedge.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<-read.alignment("abhi_seq/final_abhi_tempa1.fas", format="fasta") a.phydat<-as.phyDat(a) dist.a.phydat<-dist.dna(as.DNAbin(a.phydat)) upgma.a<-upgma(dist.a.phydat) parsimony(upgma.a,a.phydat) pars.a <- optim.parsimony(upgma.a, a.phydat) pars.a<-acctran(pars.a, a.phydat) pars.a$$tip.label[pars.a$$edge[which.max(pars.aedge.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 <- optim.parsimony(upgma.a, a.phydat)
pars.a<-acctran(pars.a, a.phydat)
plot(midpoint(pars.a))

• let me try it out and how do we decide which rooting to use? based on observation after plotting
– kcm
Jun 15 '20 at 8:33
• yes visual inspection seems relevant. It totally depends of your input data, whether your sequences are strongly conserved (without evident outgroup) or more divergent. I think you may write a control loop after constructing the upgma tree, by checking if the ouptput of getRoot(upgma.a) returns a node or a tip. If it is a node, then it might proceed with the midpoint() version. Jun 15 '20 at 8:39
• yes, probably! it is probably a more universal solution, but not the necessarily the best one! Jun 15 '20 at 8:52
• It won't work because you have only 45 tip labels, if I remember well. I think you may run: pars.a.rooted.dd<-as.dendrogram(force.ultrametric(midpoint(pars.a))) Jun 15 '20 at 9:15
• seems ok. It is true that in the previous code, we used root(midpoint(fit\$tree), outgroup="AAA64460", resolve.root=T) to force using a given tip as root. Using force.ultrametric(midpoint(pars.a)) should work too indeed. Jun 15 '20 at 9:26