# Merge\_metaphlan\_tables.py doesn't work after converting to GTDB taxonomy

**URL:** <https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093>\
**Category:** MetaPhlAn\
**Created:** [September 21, 2022, 8:26am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093 "2022-09-21T08:26:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sxh1136](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/sxh1136/32/1667_2.png) [@sxh1136](https://forum.biobakery.org/u/sxh1136)\
**Post date:** [September 21, 2022, 8:26am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/1 "2022-09-21T08:26:53Z")

</div>

The merge\_metaphlan\_tables.py script doesnt work if when metaphlan output has been converted using the sgb\_to\_gtdb\_profile.py utility script. I suspect this is to do with the lower number of headers and columns.

This is what an example of my converted metaphlan output looks like:

```auto
#mpa_vJan21_CHOCOPhlAnSGB_202103
#clade_name relative_abundance
d__Bacteria 100.00001
d __Bacteria;p__ Actinobacteriota 25.292869999999997
d __Bacteria;p__ Proteobacteria 12.73789
d __Bacteria;p__ Firmicutes_A 38.49073
d __Bacteria;p__ Bacteroidota 18.188679999999998
d __Bacteria;p__ Firmicutes 4.95885
d __Bacteria;p__ Firmicutes_C 0.28645
d __Bacteria;p__ Firmicutes_B 0.04454

```

The error code in the merged output is:  
merge\_metaphlan\_tables: wrong header format for “13-6929606\_metaphlan\_gtdb.txt”, please check your profiles.

Any ideas on how to fix this?

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [September 21, 2022, 12:45pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/2 "2022-09-21T12:45:40Z")

</div>

Hi @sxh1136  
Yes, currently the `merge_metaphlan_tables.py` does not work with the profiles produced by the `sgb_to_gtdb_profile.py`. However, in the following days, we are going to push version 4.0.2 that will include new utilities and, between them, the merging of gtdb-transformed profiles

---

<div class="post-metadata">

**Author:** ![sxh1136](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/sxh1136/32/1667_2.png) [@sxh1136](https://forum.biobakery.org/u/sxh1136)\
**Post date:** [September 22, 2022, 2:12am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/3 "2022-09-22T02:12:06Z")

</div>

Thanks for the quick reply. Good to hear that a fix is coming soon. Would you recommend that I even convert SGB taxonomy to GTDB if I’m just using the metaphlan data to plot relative abundance stacked bar charts?

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [September 23, 2022, 9:28am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/4 "2022-09-23T09:28:59Z")

</div>

Hi @sxh1136  
We just pushed version 4.0.2 fixing this problem (now, for GTDB profiles you will need to use the `--gtdb_profiles` parameter)

---

<div class="post-metadata">

**Author:** ![Jason](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jason/32/1373_2.png) [@Jason](https://forum.biobakery.org/u/Jason)\
**Post date:** [February 6, 2023, 7:15am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/5 "2023-02-06T07:15:06Z")

</div>

Hi, what version of GTDB database will this script use to convert the profiling results? Is it GTDB r202?

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [February 7, 2023, 8:47am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/6 "2023-02-07T08:47:27Z")

</div>

Hi @Jason  
We are using r207

---

<div class="post-metadata">

**Author:** ![Jason](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jason/32/1373_2.png) [@Jason](https://forum.biobakery.org/u/Jason)\
**Post date:** [February 16, 2023, 9:19am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/7 "2023-02-16T09:19:41Z")

</div>

Thanks for replying.  
Is there any way I can transfer the taxonomy results into a GTDB\_r202-based version?  
(Maybe the script in a specific MetaPhlAn version can achieve this goal? )

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [February 21, 2023, 1:44pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/8 "2023-02-21T13:44:42Z")

</div>

Hi @Jason  
Unfortunately, I think there is not an easy way to transfer the taxonomy to r202

---

<div class="post-metadata">

**Author:** ![cjharbort](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/cjharbort/32/2596_2.png) [@cjharbort](https://forum.biobakery.org/u/cjharbort)\
**Post date:** [February 27, 2023, 2:34pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/9 "2023-02-27T14:34:34Z")

</div>

Hi Aitor,

Is there a way to convert a merged metaphlan taxonomy file to GTDB? I tried running sgb\_to\_gtdb\_profile.py on the merged table (created by running biobakery\_workflows wmgx pipeline), but the result is only a single column, not every sample.

Thanks a ton for your help answering all the questions here, and for the great tools!

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [February 27, 2023, 3:35pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/10 "2023-02-27T15:35:29Z")

</div>

Hi @cjharbort  
Currently it is not possible, you will have to convert first the individual profiles to GTDB and after that run the merge\_metaphlan\_tables.py script

---

<div class="post-metadata">

**Author:** ![young\_doktor](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@young\_doktor](https://forum.biobakery.org/u/young_doktor)\
**Post date:** [March 27, 2024, 2:39pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/11 "2024-03-27T14:39:39Z")

</div>

Hi I am using metaphlan version 4.1.0 (23 Aug 2023) and I converted to my SGB to GTDB taxonomy.

I am getting an error when merging the tables: pandas.errors.ParserError: Defining usecols with out-of-bounds indices is not allowed. [2] are out of bounds.

I looked through each individual gtdb file and two of my samples have relative abundance of 100.00000000000001

Some of them are 99.999999 which I assume is not a problem, and several are exactly 100.0

What can I do to get my tables to merge properly?

Here are the commands I’m using:  
sgb\_to\_gtdb\_profile.py -i profiled\_SAMPLE\_metagenome.txt -o metaphlan\_output\_SAMPLE\_gtdb.txt

merge\_metaphlan\_tables.py metaphlan\_output\_\*\_gtdb.txt \> merged\_abundance\_table.txt

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![young\_doktor](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@young\_doktor](https://forum.biobakery.org/u/young_doktor)\
**Post date:** [March 30, 2024, 5:11pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-doesnt-work-after-converting-to-gtdb-taxonomy/4093/12 "2024-03-30T17:11:46Z")

</div>

Hi I’ve done more reading about this. Others have had this problem in the past, but it looks like the sbg\_to\_gtb\_profile.py has been updated?

I went to github and downloaded the newest version (edited 3 weeks ago). I tried providing the path to this file and rerunning the command: sgb\_to\_gtdb\_profile.py -i profiled\_SAMPLE\_metagenome.txt -o metaphlan\_output\_SAMPLE\_gtdb.txt with the path to the new file from github. I could not get it to work.

Any other thoughts?

Here is a link to the thread previously that described others with this problem: sgb\_to\_gtdb\_profile.py -i profiled\_SAMPLE\_metagenome.txt -o metaphlan\_output\_SAMPLE\_gtdb.txt
