# Merge\_metaphlan\_tables.py gives different header in Metaphlan4

**URL:** <https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865>\
**Category:** MetaPhlAn\
**Created:** [February 27, 2023, 2:48pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865 "2023-02-27T14:48:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjain1990](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/rjain1990/32/1999_2.png) [@rjain1990](https://forum.biobakery.org/u/rjain1990)\
**Post date:** [February 27, 2023, 2:48pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/1 "2023-02-27T14:48:20Z")

</div>

MetaPhlAn4  
Hello, I am merging abundance tables from 6 output table.txt using  
merge\_metaphlan\_tables.py profiled\_PB1.txt profiled\_PB2.txt profiled\_PB3.txt profiled\_PB4.txt profiled\_PB5.txt profiled\_PB6.txt \> output/LTS\_abundance\_table.txt  
I am getting different header without “#SampleID” but rather with “clade\_name”. See below.

 ![merged output](https://canada1.discourse-cdn.com/flex027/uploads/biobakery/original/2X/f/fe4f58bd712f309a44e93a12d18ea0be0a937d82.png)

Next, when I am trying to extract only species abundance from this table, using command grep -E “(s\_\_)|(^ID)” LTS\_abundance\_table.txt | grep -v “t\_\_” | sed ‘s/^.\*s\_\_//g’ \> LTS\_abundance\_table\_species.txt.

I am getting no header at all in the output file (output below). I see there is no ID head in the input file probably that is why this is happening.

 ![species abundance](https://canada1.discourse-cdn.com/flex027/uploads/biobakery/original/2X/3/392651bb905e51b1cdbd10f8dfe9180166b9f739.png)

can you please help?

---

<div class="post-metadata">

**Author:** ![rjain1990](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/rjain1990/32/1999_2.png) [@rjain1990](https://forum.biobakery.org/u/rjain1990)\
**Post date:** [February 27, 2023, 3:19pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/2 "2023-02-27T15:19:22Z")

</div>

I forgot to upload the output of the profiled abundance table. Similar 5 other tables I am using to merge in to a LTS\_abundance\_table. This to me looks fine.

 ![profiled abundace](https://canada1.discourse-cdn.com/flex027/uploads/biobakery/original/2X/4/43cae925113d8e1db52a7e8db529f57d57b38ccb.png)

---

<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, 4:06pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/3 "2023-02-27T16:06:54Z")

</div>

Hi @rjain1990  
Try to change the first grep command to `grep -E "s__|clade"` instead

---

<div class="post-metadata">

**Author:** ![mars](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/mars/32/1295_2.png) [@mars](https://forum.biobakery.org/u/mars)\
**Post date:** [February 28, 2023, 8:43am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/4 "2023-02-28T08:43:03Z")

</div>

I have created the table with absolute read counts but need to break them down into various taxa level.

Can someone please write the script to obtain absolute reads counts at phylum, class, family, genus, species (i can see that above) etc.

Many thanks,

---

<div class="post-metadata">

**Author:** ![rjain1990](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/rjain1990/32/1999_2.png) [@rjain1990](https://forum.biobakery.org/u/rjain1990)\
**Post date:** [February 28, 2023, 11:41am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/5 "2023-02-28T11:41:54Z")

</div>

Hi @aitor.blancomiguez Thanks for your response.

It worked now, but I have another issue in creating the heatmap. I am using the following command.  
hclust2.py   
-i LTS\_abundance\_table\_species.txt   
-o LTS\_abundance\_species.png   
–ftop 50   
–f\_dist\_f correlation   
–s\_dist\_f braycurtis   
–cell\_aspect\_ratio 9   
-s --fperc 99   
–flabel\_size 4   
–metadata\_rows 2,3,4,5,6,7  
–legend\_file LTS\_abundance\_species.legend.png   
–max\_flabel\_len 100   
–metadata\_height 0.075   
–minv 0.01   
–no\_slabels   
–dpi 300   
–slinkage complete

 ![heatmap](https://canada1.discourse-cdn.com/flex027/uploads/biobakery/original/2X/b/b2cc4554a561bb7987d2c6b1a5b2969fc74fe9a3.png)

Requesting your help! I also tried this with galaxy server but again I am unsuccessful.

---

<div class="post-metadata">

**Author:** ![rjain1990](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/rjain1990/32/1999_2.png) [@rjain1990](https://forum.biobakery.org/u/rjain1990)\
**Post date:** [February 28, 2023, 11:46am UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/6 "2023-02-28T11:46:00Z")

</div>

Hi @mars

grep -E “(s\_\_)|(^ID)” filename.txt | grep -v “t\_\_” | sed ‘s/^.\*s\_\_//g’ \> filename\_species.txt

you can replace s\_\_ (species) with p\_\_ (for phylum), c\_\_ (for class), o\_\_ (for order), f\_\_ (for family), g\_\_ (for genus) for different taxa level.

I hope this help.

---

<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 28, 2023, 1:42pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/7 "2023-02-28T13:42:36Z")

</div>

It seems a problem with the matplotlib version you are using, can you check and let me know the version you have installed?

---

<div class="post-metadata">

**Author:** ![rjain1990](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/rjain1990/32/1999_2.png) [@rjain1990](https://forum.biobakery.org/u/rjain1990)\
**Post date:** [February 28, 2023, 3:27pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/8 "2023-02-28T15:27:29Z")

</div>

The version previously I was using was matplotlib 3.6.2 but than I downgraded to 2.2.3. In both cases it didnt work.  
Currently, I can also see matplotlib-base 3.6.2 and metplotlib 2.2.3 in the conda list.

---

<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 28, 2023, 4:39pm UTC](https://forum.biobakery.org/t/merge-metaphlan-tables-py-gives-different-header-in-metaphlan4/4865/9 "2023-02-28T16:39:21Z")

</div>

You should probably downgrade `matplotlib-base` too
