ERROR: merge_metaphlan_tables.py

Hi friends!!! I’m reaching out to you as facing an ERROR while merging MetaPhlAn3.0 output profile.txt files. I have given the command as:

merge_metaphlan_tables.py *.txt >merge_abundance.txt

And got the following output:

Traceback (most recent call last):
File “/home/dc7/anaconda3/envs/biobakery3/bin/merge_metaphlan_tables.py”, line 10, in
sys.exit(main())
File “/home/dc7/anaconda3/envs/biobakery3/lib/python3.7/site-packages/metaphlan/utils/merge_metaphlan_tables.py”, line 78, in main
merge(args.aistms, sys.stdout)
File “/home/dc7/anaconda3/envs/biobakery3/lib/python3.7/site-packages/metaphlan/utils/merge_metaphlan_tables.py”, line 48, in merge
index_col=index_col
File “/home/dc7/anaconda3/envs/biobakery3/lib/python3.7/site-packages/pandas/io/parsers.py”, line 676, in parser_f
return _read(filepath_or_buffer, kwds)
File “/home/dc7/anaconda3/envs/biobakery3/lib/python3.7/site-packages/pandas/io/parsers.py”, line 448, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File “/home/dc7/anaconda3/envs/biobakery3/lib/python3.7/site-packages/pandas/io/parsers.py”, line 880, in init
self._make_engine(self.engine)
File “/home/dc7/anaconda3/envs/biobakery3/lib/python3.7/site-packages/pandas/io/parsers.py”, line 1114, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File “/home/dc7/anaconda3/envs/biobakery3/lib/python3.7/site-packages/pandas/io/parsers.py”, line 1947, in init
_validate_usecols_names(usecols, self.names)
File “/home/dc7/anaconda3/envs/biobakery3/lib/python3.7/site-packages/pandas/io/parsers.py”, line 1233, in _validate_usecols_names
"Usecols do not match columns, "
ValueError: Usecols do not match columns, columns expected but not found: [0, 1, 2]

  • Why I’m receiving this error? How to fix it?
  • The command is working fine with MetaPhlAn2.7.7. Is there any problem if I merge MetaPhlAn3.0 profile outputs with merge_metaphlan_tables.py from MetaPhlAn2.7.7?

Thanks and Regards,
DC7

Can you put the head of the profiles you’re trying to merge?

It should be better to use the correct version of merge_metaphlan_tables, the latest one is able to handle the new 4-column format

@fbeghini
Hi, I am facing a similar issue. I have used Humann3 and metaphlan3. Merging occured fine for files from the same run, while merging files from different runs throws the following error:
Traceback (most recent call last):
File “/install/software/mincondas/3.7/instance2/bin/merge_metaphlan_tables.py”, line 10, in
sys.exit(main())
File “/install/software/mincondas/3.7/instance2/lib/python3.7/site-packages/metaphlan/utils/merge_metaphlan_tables.py”, line 81, in main
merge(args.aistms, fout)
File “/install/software/mincondas/3.7/instance2/lib/python3.7/site-packages/metaphlan/utils/merge_metaphlan_tables.py”, line 48, in merge
index_col=index_col
File “/install/software/mincondas/3.7/instance2/lib/python3.7/site-packages/pandas/io/parsers.py”, line 676, in parser_f
return _read(filepath_or_buffer, kwds)
File “/install/software/mincondas/3.7/instance2/lib/python3.7/site-packages/pandas/io/parsers.py”, line 448, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File “/install/software/mincondas/3.7/instance2/lib/python3.7/site-packages/pandas/io/parsers.py”, line 880, in init
self._make_engine(self.engine)
File “/install/software/mincondas/3.7/instance2/lib/python3.7/site-packages/pandas/io/parsers.py”, line 1114, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File “/install/software/mincondas/3.7/instance2/lib/python3.7/site-packages/pandas/io/parsers.py”, line 1891, in init
self._reader = parsers.TextReader(src, **kwds)
File “pandas/_libs/parsers.pyx”, line 529, in pandas._libs.parsers.TextReader.cinit
File “pandas/_libs/parsers.pyx”, line 843, in pandas._libs.parsers.TextReader._get_header
ValueError: Passed header names mismatches usecols

Looking at the files I realized that two of my files have an additional row called UNKNOWN but one file is missing that. Apart from this there is no difference in the file type.

Can you help me with the same.

Thank you
DP

1 Like

Hi @Dhrati_Patangia - Has it been solved?