# Constructing phylogenetic tree

**URL:** <https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642>\
**Category:** MetaPhlAn\
**Created:** [July 13, 2023, 7:16am UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642 "2023-07-13T07:16:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jilim97](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jilim97/32/2294_2.png) [@Jilim97](https://forum.biobakery.org/u/Jilim97)\
**Post date:** [July 13, 2023, 7:16am UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642/1 "2023-07-13T07:16:17Z")

</div>

I am now trying to construct phylogenetic tree with the output of MetaPhlAn.  
I extract mapped SGB id then i could successfully take sequences coresonding SGB id.  
At this point, I am wondering whether it is ok to make phylogenetic tree with these sequences since I found that there are a lot of differences of length among sequences.  
So I think that sequences would not be well aligned.  
Is it fine? or should I find other way to make it.

---

<div class="post-metadata">

**Author:** ![alexhbnr](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/alexhbnr/32/570_2.png) [@alexhbnr](https://forum.biobakery.org/u/alexhbnr)\
**Post date:** [July 18, 2023, 11:00am UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642/2 "2023-07-18T11:00:19Z")

</div>

I am not sure if I understand your question completely. What would you like to achieve with such a phylogenetic tree? Depending on your goal, you could try different strategies. However, in almost every case using the clade-specific marker genes used by MetaPhlAn to profile the taxa in a sample won’t work for building a tree.

If you would like to have a tree of life of all taxa identified in your sample, e.g. for visualisation or UniFrac analyses, you could build such a tree using PhyloPhlAn3 using 400 universal marker genes. With this you would guarantee that there is sufficient overlap in the multi-sequence alignment across taxa that you can build a tree with high confidence.

---

<div class="post-metadata">

**Author:** ![Jilim97](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jilim97/32/2294_2.png) [@Jilim97](https://forum.biobakery.org/u/Jilim97)\
**Post date:** [July 19, 2023, 12:57am UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642/3 "2023-07-19T00:57:58Z")

</div>

I just want to make an input of Phyloseq in R for further analysis, not for the special purpose,  
and I understand why it is not reliable to build a tree using SGB information.

So I tried another way. I used a phylogenetic tree generated by PhyloPhlAn, provided by MetaPhlAn as a reference tree.  
Then, I extract mapped SGB ids by my result (using MetaPhlAn) using Biopython.

For my aspect, I think it is not wrong way to build a tree because I just remove branches and nodes that are not included to my result. But I am not sure this is right way.

---

<div class="post-metadata">

**Author:** ![alexhbnr](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/alexhbnr/32/570_2.png) [@alexhbnr](https://forum.biobakery.org/u/alexhbnr)\
**Post date:** [July 19, 2023, 6:59am UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642/4 "2023-07-19T06:59:36Z")

</div>

If you want a tree for generating PhyloSeq objects, that’s the way to go. In case you are running MetaPhlAn3, there is such a readily available tree in the R package curatedMetagenomicData that contains the vast majority of the taxa that you can detect in human-associated microbiome samples.

For MetaPhlAn4, there is no such tree available, yet.

---

<div class="post-metadata">

**Author:** ![Jilim97](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jilim97/32/2294_2.png) [@Jilim97](https://forum.biobakery.org/u/Jilim97)\
**Post date:** [July 19, 2023, 7:03am UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642/5 "2023-07-19T07:03:43Z")

</div>

Thank you:)  
It was enough to solve my current issue.

---

<div class="post-metadata">

**Author:** ![Sourdoc](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/sourdoc/32/2927_2.png) [@Sourdoc](https://forum.biobakery.org/u/Sourdoc)\
**Post date:** [September 24, 2024, 3:31am UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642/6 "2024-09-24T03:31:54Z")

</div>

Hi @Jilim97,  
I was wondering how did you generate phylogenetic tree using PhyloPhlAn using MetaPhlAn as a reference tree. I am using metaphlan 4.1 which already has phylophlan installed with it.

Thanks!

---

<div class="post-metadata">

**Author:** ![Jilim97](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jilim97/32/2294_2.png) [@Jilim97](https://forum.biobakery.org/u/Jilim97)\
**Post date:** [September 24, 2024, 1:18pm UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642/7 "2024-09-24T13:18:58Z")

</div>

hello, I used the the tree that Metaphlan team already made.  
You can find this tree, which contains all of the SGB id, on their Github.  
And I just remove SGB Ids that are not found in my sample. In other word, I keep the original tree and eliminating ids not present in my samples using python code.

---

<div class="post-metadata">

**Author:** ![Sourdoc](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/sourdoc/32/2927_2.png) [@Sourdoc](https://forum.biobakery.org/u/Sourdoc)\
**Post date:** [September 25, 2024, 2:10pm UTC](https://forum.biobakery.org/t/constructing-phylogenetic-tree/5642/8 "2024-09-25T14:10:49Z")

</div>

Hello,  
Thanks @Jilim97!  
I guess you are talking about this one -

> <https://github.com/biobakery/MetaPhlAn/blob/master/metaphlan/utils/mpa_vJan21_CHOCOPhlAnSGB_202103.nwk>

I guess you have used ete3 python package to remove SGB Ids that are not found in your sample. And for my dataset, I have also found some SGB ids in my sample that are not present in the metaphlan nwk tree. Did this happen in your case?
