<p>the fact is that the present upgma tree as a midpoint rooting here, corresponding to node 46.</p>

<pre><code>getRoot(upgma.a)
</code></pre>

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

<pre><code>pars.a &lt;- optim.parsimony(upgma.a, a.phydat)
pars.a&lt;-acctran(pars.a, a.phydat)
plot(midpoint(pars.a))
</code></pre>

CC BY-SA 4.0
2020-06-15T08:33:22.153Z
let me try it out and how do we decide which rooting to use? based on observation after plotting
kcm
CC BY-SA 4.0
2020-06-15T08:39:08.570Z
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.
thomas duge de bernonville
CC BY-SA 4.0
2020-06-15T08:45:26.850Z
I haven't tried with ML but this mid point should work with ML as well?
kcm
CC BY-SA 4.0
2020-06-15T08:52:01.183Z
yes, probably! it is probably a more universal solution, but not the necessarily the best one!
thomas duge de bernonville
CC BY-SA 4.0
2020-06-15T09:13:13.440Z
last time i was looking to compare tress which you had suggested turn them into dedrogram and then for comparison you suggested something this '
pars.a.rooted<-root(pars.a, outgroup="ABN10911", resolve.root=T)
pars.a.rooted.dd<-as.dendrogram(force.ultrametric(pars.a.rooted))' how to do the same  here shall i put node 46 as the outgroup?
kcm
CC BY-SA 4.0
2020-06-15T09:15:05.607Z
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)))`
thomas duge de bernonville
CC BY-SA 4.0
2020-06-15T09:22:51.953Z
works perfectly fine for parsimony and...for pars for ML i m doing this rectify me if im wrong "ml.a.rooted.dd<-as.dendrogram(force.ultrametric(midpoint(fit$tree)))
"
kcm
CC BY-SA 4.0
2020-06-15T09:26:52.343Z
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.
thomas duge de bernonville
CC BY-SA 4.0
2020-06-15T10:53:50.837Z
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/109380/discussion-between-krushnach-chandra-and-thomas-duge-de-bernonville).
kcm
CC BY-SA 4.0
2020-06-15T08:22:06.550Z
2020-06-15T08:22:06.550Z
thomas duge de bernonville
<p>Im trying to find the out-group in the alignment my data files <a href="https://drive.google.com/file/d/1N60Va-smHbsmCePOnkVL_jjAaxCagZWf/view?usp=sharing" rel="nofollow noreferrer">file a</a> and  <a href="https://drive.google.com/file/d/1_E0Ozgv_7Wtxr9AKPrvW606IWH99hIPb/view?usp=sharing" rel="nofollow noreferrer">file b</a> both the case i'm getting NA when i run this     <code>pars.a$tip.label[pars.a$edge[which.max(pars.a$edge.length),2]]</code></p>

<p>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 <a href="https://drive.google.com/file/d/10P6qF3nrXlnm-tUONK5bTAPqR4wapX-q/view?usp=sharing" rel="nofollow noreferrer">with 50 sequence </a> works fine.</p>

<pre><code>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<span class="math-container">$tip.label[pars.a$</span>edge[which.max(pars.a$edge.length),2]]
</code></pre>

<r><phylogenetics>
Finding out-group in unrooted tree
# Finding out-group in unrooted tree

(Asked by: username_0 on 2020-06-15)

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<-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.a$edge.length),2]]

**Tags:** r, phylogenetics

---

## 1 answers

### Answer by username_1 on 2020-06-15. Score: 1 | Accepted answer

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))

> **Comments:**
> **username_0**: let me try it out and how do we decide which rooting to use? based on observation after plotting  
> **username_1**: 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.  
> **username_0**: I haven't tried with ML but this mid point should work with ML as well?  
> **username_1**: yes, probably! it is probably a more universal solution, but not the necessarily the best one!  
> **username_0**: last time i was looking to compare tress which you had suggested turn them into dedrogram and then for comparison you suggested something this ' pars.a.rooted<-root(pars.a, outgroup="ABN10911", resolve.root=T) pars.a.rooted.dd<-as.dendrogram(force.ultrametric(pars.a.rooted))' how to do the same  here shall i put node 46 as the outgroup?  
> **username_1**: 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)))`  
> **username_0**: works perfectly fine for parsimony and...for pars for ML i m doing this rectify me if im wrong "ml.a.rooted.dd<-as.dendrogram(force.ultrametric(midpoint(fit$tree))) "  
> **username_1**: 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.  
> **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/109380/discussion-between-krushnach-chandra-and-thomas-duge-de-bernonville).  

---

