q2-metnet plugin error

Hi @tblasco,

I am also testing this tool and I obtain the same error output. I am running this via qiime2-amplicon-2024.5.

This issue is that the code is written to process an ASV/OTU table that is already transposed. That is, a standard QIIME 2 table should have the samples as rows and ASVs as columns. Whereas the example test file and code expects the samples as columns and ASVs as rows. For example compare the outputs of any table from the QIIME 2 tutorials to your example test table by running the following command on your asv_table.qza example table from here and the dada2_table.qza from here:

qiime metadata tabulate \
    --m-input-file asv_table.qza \
   --o-visualization asv_table_tab.qzv

qiime metadata tabulate \
    --m-input-file dada2_table.qza \
   --o-visualization dada2_table_tab.qzv

That is the .transpose command is not necessary for a standard table. Otherwise the user must run the following prior to running the analysis:

 qiime feature-table transpose \
    --i-table ./dada2_table.qz  \
    --o-transposed-feature-table ./dada2_table_transposed.qza

Upon running this command I was able to get past the error that @annalex observed, and moved on to a new error:

Traceback (most recent call last):
  File "/home/SE/BMIG-6202-MSR/qiime2-amplicon-2024.5/lib/python3.9/site-packages/q2cli/commands.py", line 520, in __call__
    results = self._execute_action(
  File "/home/SE/BMIG-6202-MSR/qiime2-amplicon-2024.5/lib/python3.9/site-packages/q2cli/commands.py", line 581, in _execute_action
    results = action(**arguments)
  File "<decorator-gen-908>", line 2, in generateFeatures
  File "/home/SE/BMIG-6202-MSR/qiime2-amplicon-2024.5/lib/python3.9/site-packages/qiime2/sdk/action.py", line 342, in bound_callable
    outputs = self._callable_executor_(
  File "/home/SE/BMIG-6202-MSR/qiime2-amplicon-2024.5/lib/python3.9/site-packages/qiime2/sdk/action.py", line 576, in _callable_executor_
    output_views = self._callable(**view_args)
  File "/home/SE/BMIG-6202-MSR/qiime2-amplicon-2024.5/lib/python3.9/site-packages/metnet-2023.0.1-py3.9.egg/q2_metnet/_generateFeatures.py", line 82, in generateFeatures
    PresentTaxa, newFrequency, Samples = _extractTaxaPresentAGREDA(frequency, taxa, stream, level)
  File "/home/SE/BMIG-6202-MSR/qiime2-amplicon-2024.5/lib/python3.9/site-packages/metnet-2023.0.1-py3.9.egg/q2_metnet/_inputFiles.py", line 132, in _extractTaxaPresentAGREDA
    return _contextTaxa(frequency, taxa, reference, level)
  File "/home/SE/BMIG-6202-MSR/qiime2-amplicon-2024.5/lib/python3.9/site-packages/metnet-2023.0.1-py3.9.egg/q2_metnet/_inputFiles.py", line 46, in _contextTaxa
    if not "" == tmp[depth_level[level]]:
IndexError: list index out of range

Plugin error from metnet:

  list index out of range

See above for debug info.

I think this has to do with the fact that most users will have input taxonomy files that do not have a full taxonomy as does your test file. You can use RESCRIPt's edit-taxonomy command to help with this, see below. Or add code to q2-metnet to handle these cases.

I suggest that the q2-metnet test cases use files similar to those of the QIIME 2 tutorials for code testing, as this will be the typical format of most users. Or be very explicit, with detailed instructions, on how to format the input files for use in q2-metnet.

Also, looking at the q2-metnet code, I noticed that correspondent_level and depth_level dictionaries do not allow domain. This will be problematic for those that use GTDB, and SILVA. These databases use domain and not kingdom, so you might want to allow d as a possible entry, or convert d to k behind the scenes. Or suggest that the users use RESCRIPt to change d__ to k__ like so:

qiime rescript edit-taxonomy \
    --i-taxonomy ./taxonomy.qza \
    --p-search-strings 'd__' \
    --p-replacement-strings 'k__' \
    --o-edited-taxonomy ./taxonomy-edit.qza

You can apply --p-use-regex (and/or use an input file) for more complicated edits, see here.

I hope this helps @tblasco . :slight_smile:

2 Likes