Lefse_plot_res.py plot error - TypeError: slice indices must be integers or None or have an __index__ method

I am trying to run lefse (v1.1.2) for metabolic pathway abundances from Humann3 which we joined all of our samples and then normalised to relative abundance. We were able to run lefse formatting and lefse run with the following commands:

lefse_format_input.py all_pathabundance_relab_mod_lefse_subcat3.tsv lefse_subcat3.in -c 2 -u 1 -o 1000000

lefse_run.py lefse_subcat3.in lefse_subcat3.res

However, when we run lefse_plot_res.py we get the following error:

lefse_plot_res.py lefse_subcat3.res lefse_subcat3.png

Traceback (most recent call last):
  File "/miniconda/envs/myenv/bin/lefse_plot_res.py", line 10, in <module>
  File "/miniconda/envs/myenv/lib/python3.7/site-packages/lefse/lefse_plot_res.py", line 177, in plot_res
    else: plot_histo_hor(params['output_file'],params,data,len(data['cls']) == 2,params['report_features'])
  File "/miniconda/envs/myenv/lib/python3.7/site-packages/lefse/lefse_plot_res.py", line 104, in plot_histo_hor
    if len(rr) > params['max_feature_len']: rr = rr[:params['max_feature_len']/2-2]+" [..]"+rr[-params['max_feature_len']/2+2:]
TypeError: slice indices must be integers or None or have an __index__ method

If we change lefse_plot_res.py script to round the data using:

if len(rr) > params['max_feature_len']: rr = rr[:params['max_feature_len']//2-2]+" [..]"+rr[-params['max_feature_len']//2+2:]

we get an image - though I’m not sure it is the correct image then because of the extra rounding.

Our lefse_subcat3.res file looks like:

head lefse_subcat3.res

UNMAPPED 5.698806339377007 MF 4.992992452183536 0.0020039311821839286
UNINTEGRATED 5.534112533646385 NM 4.691403253999157 0.0016752988184979575
UNINTEGRATED.g__Achromobacter_s__Achromobacter_denitrificans 1.8462237235380918 -
UNINTEGRATED.g__Achromobacter_s__Achromobacter_sp_ATCC31444 1.4941062290802956 -
UNINTEGRATED.g__Achromobacter_s__Achromobacter_spanius 1.8231784520362997 -
UNINTEGRATED.g__Acidovorax_s__Acidovorax_sp_OV235 1.3596936023263013 -
UNINTEGRATED.g__Acinetobacter_s__Acinetobacter_albensis 1.7961791945841161 -
UNINTEGRATED.g__Acinetobacter_s__Acinetobacter_bereziniae 0.5660156608292263 -
UNINTEGRATED.g__Acinetobacter_s__Acinetobacter_bohemicus 1.8704551846872188 -
UNINTEGRATED.g__Acinetobacter_s__Acinetobacter_calcoaceticus 1.6186752741067647 -

Can you give advice on what we might be doing incorrectly? Our samples have a single class with 3 types/disease states

Thank you!

Good morning - The plot function was working for a result with only 19 significant pathways found, but not 30. We double checked the documentation and we have adjusted the options for our lefse_plot_res.py to add --max_feature_len and now no longer have the same trouble

lefse_plot_res.py lefse_subcat3.res lefse_subcat3.png --max_feature_len 100 --width 10 --subclades -1 --dpi 300

Thank you for your question, and for posting a solution. I will ask the developers about this to see if a more informative error message can be displayed when this happens.