Problem with metaphlan2krona.py

Hi,

I fed the Metaphlan output to metaphlan2krona.py but I got the following error. Is there anything I need to do with the output file from metaphlan?

Thanks!

Error:

Traceback (most recent call last):
  File "/pub59/jingk/miniconda3/envs/metaphlan4/bin/metaphlan2krona.py", line 10, in <module>
    sys.exit(main())
  File "/pub59/jingk/miniconda3/envs/metaphlan4/lib/python3.10/site-packages/metaphlan/utils/metaphlan2krona.py", line 42, in main
    abundance = float(x_cells[-2].rstrip('\n')) 
ValueError: could not convert string to float: 'Bradyrhizobium'
(metaphlan4) jingk@ada18:/pub59/jingk/04_chigger_mito01/07_metaphlan$ metaphlan2krona.py -p metaphlan4_out.txt -k R9P_metaphlan4_krona.out 
Traceback (most recent call last):
  File "/pub59/jingk/miniconda3/envs/metaphlan4/bin/metaphlan2krona.py", line 10, in <module>
    sys.exit(main())
  File "/pub59/jingk/miniconda3/envs/metaphlan4/lib/python3.10/site-packages/metaphlan/utils/metaphlan2krona.py", line 42, in main
    abundance = float(x_cells[-2].rstrip('\n')) 
ValueError: could not convert string to float: 'Bradyrhizobium'
(metaphlan4) jingk@ada18:/pub59/jingk/04_chigger_mito01/07_metaphlan$ metaphlan2krona.py -p metaphlan4_out.txt -k R9P_metaphlan4_krona.out 
Traceback (most recent call last):
  File "/pub59/jingk/miniconda3/envs/metaphlan4/bin/metaphlan2krona.py", line 10, in <module>
    sys.exit(main())
  File "/pub59/jingk/miniconda3/envs/metaphlan4/lib/python3.10/site-packages/metaphlan/utils/metaphlan2krona.py", line 42, in main
    abundance = float(x_cells[-2].rstrip('\n')) 
ValueError: could not convert string to float: 'Bradyrhizobium'

More info if it helps:

$ metaphlan --version
MetaPhlAn version 4.0.3 (24 Oct 2022)

Command used to run Metaphlan:

metaphlan R1.fastq.gz,R2.fastq.gz --bowtie2out R1.bowtie2.bz2,R2.bowtie2.bz2 --nproc 5 --input_type fastq --unclassified_estimation -o metaphlan4_out.txt &

Command used to run metaphlan2krona.py:

metaphlan2krona.py -p metaphlan4_out.txt -k R9P_metaphlan4_krona.out 

Hi @khoojj
I will have a look into the problem (it seems some changes in the code when moving to version 4 had affected the konda exporter script) I will keep you updated when the new version fixing this issue is available

That will be great! Thanks!

Hi, I was wondering if this was fixed, as I am having the same problem when I apply metaphlan2krona.py to my Metaphlan4 outputs.

Hi Samuel, it should be fixed in the latest version, which version are you using?

I used Metaphlan v4.0.3 for the analysis and downloaded the most latest version of metaphlan2krona.py from Github. metaphlan2krona.py seems to have worked, but I still get the error:

ValueError: could not convert string to float: ‘Bacillus’
Traceback (most recent call last):
File “metaphlan2krona.py”, line 49, in
main()
File “metaphlan2krona.py”, line 42, in main
abundance = float(x_cells[-2].rstrip(‘\n’))
ValueError: could not convert string to float: ‘Bacillus’

Hi @SamuelBloomfield
Are you using the default/standard MetaPhlAn output?

I am having the same error (below) using MetaPhlAn version 4.0.6. The command was metaphlan2krona.py -p IBD1.txt -k IBD1.krona.txt , using the standard MetaPhlAn output text file attached
IBD1.txt (6.3 KB)
.

Traceback (most recent call last):
File “/scratch/maringa/ENV/bin/metaphlan2krona.py”, line 8, in
sys.exit(main())
^^^^^^
File “/scratch/maringa/ENV/lib/python3.11/site-packages/metaphlan/utils/metaphlan2krona.py”, line 42, in main
abundance = float(x_cells[-2].rstrip(‘\n’))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: ‘Burkholderiales_unclassified’