Problem with 'taxa collapse'

Hi! I’ve been trying to run this command:

qiime taxa collapse --i-table filtered_samples_otu_table.qza --i-taxonomy taxonomy.qza --p-level 6 --o-collapsed-table filtered_collapsed_otu_table_genus.qza

and an error message comes out:

Plugin error from taxa:
Please provide a DataFrame with a string-based Index

What should I do?

Thanks!

Alle

Hi @allebiotech,
Sounds like the problem may be that your sample IDs are all numbers? While this is not forbidden in QIIME 2 metadata formats, it is discouraged since it can cause cryptic bugs like this to emerge when some of the underlying packages that QIIME 2 uses cannot handle numeric sample IDs.

If I am wrong, and your sample IDs are not numbers, please ignore what I have to say below and instead do the following:

  1. please report the full error message
  2. please run qiime feature-table summarize on that feature table and share the result here.

If your sample IDs really are all numbers, I recommend changing these to "strings" (i.e., include non-numeric characters in your sample IDs). For example, if your sample IDs are 1, 2, 3, change them to something like s1, s2, s3. You will need to change these both in your feature table and in your metadata. One way to do this (instead of starting over!) is to use group to relabel your sample IDs. Do the following:

  1. Add a new column to your sample metadata file so that it looks like this:
sample-id ... new-id
1 ... s1
2 ... s2
3 ... s3
  1. Use the following command to relabel your feature table samples:
qiime feature-table group \
    --i-table filtered_samples_otu_table.qza \
    --p-axis sample \
    --m-metadata-file sample-metadata.tsv \
    --m-metadata-column new-id \
    --p-mode sum \
    --o-grouped-table new-table.qza
  1. rearrange your metadata file so that the new IDs are at the start of each row. You do not need to save the old ID if you don't want, but I recommend keeping it just in case:
sample-id ... old-id
s1 ... 1
s2 ... 2
s3 ... 3

Good luck!

2 Likes

Dear @Nicholas_Bokulich thanks a lot for your reply!

My sample-IDs are strings.

Here it is the full error message from the qiime taxa collapse command:

Traceback (most recent call last):
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/q2cli/commands.py”, line 274, in call
results = action(**arguments)
File “</home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/decorator.py:decorator-gen-136>”, line 2, in collapse
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 231, in bound_callable
output_types, provenance)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 393, in callable_executor
spec.qiime_type, output_view, spec.view_type, prov)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/sdk/result.py”, line 265, in _from_view
result = transformation(view)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/core/transform.py”, line 70, in transformation
new_view = transformer(view)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/core/transform.py”, line 220, in wrapped
file_view = transformer(view)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/q2_types/feature_table/_transformer.py”, line 152, in _10
return _table_to_v210(_dataframe_to_table(df))
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/q2_types/feature_table/_transformer.py”, line 85, in _dataframe_to_table
raise TypeError(“Please provide a DataFrame with a string-based Index”)
TypeError: Please provide a DataFrame with a string-based Index

Whereas this is the full error message from the qiime feature-table summarize command on the filtered feaure table:

Traceback (most recent call last):
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/q2cli/commands.py”, line 274, in call
results = action(**arguments)
File “</home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/decorator.py:decorator-gen-321>”, line 2, in summarize
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 231, in bound_callable
output_types, provenance)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 427, in callable_executor
ret_val = self._callable(output_dir=temp_dir, **view_args)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/q2_feature_table/_summarize/_visualizer.py”, line 155, in summarize
sample_frequencies.index)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/metadata/metadata.py”, line 727, in filter_ids
ids_to_keep)
File “/home/qiime2/miniconda/envs/qiime2-2019.1/lib/python3.6/site-packages/qiime2/metadata/metadata.py”, line 189, in _filter_ids_helper
raise ValueError("ids_to_keep must contain at least one ID.")
ValueError: ids_to_keep must contain at least one ID.

I don’t know how to proceed…

Thanks again!

Alle

could you please also share the summarize command you used?

qiime feature-table summarize --i-table filtered_otu_table.qza --o-visualization filtered_otu_table.qzv --m-sample-metadata-file mapping_file.tsv

where ‘filtered_otu_table.qza’ is the result of the ‘qiime feature-table filter-samples’ command.

Thanks again

This appears to be caused by one of two things:

  1. mapping_file.tsv contains no samples (I know, I am making a silly suggestion but just saying, that would cause this error)
  2. More likely: all samples have been filtered out from your table. Hence, none of the sample IDs in mapping_file.tsv overlap with the feature table, causing the summarize error.

Try running summarize without the metadata file. I predict you will see that no samples or no sequence are left. That will explain the collapse error.

Your second guess is right! :slight_smile:
But I don’t understand why since I filtered the otu table considering two conditions of my “Treatment” column in the metadata file…
Do you think should I change the header? (maybe it doesn’t recognize “Treatment”)

Thanks again

What did your filtering command look like? Copy and paste please.

Nope, more likely your filtering command had some kind of minor typo, but, we shall see...

I’ve found the error:
when I selected the two conditions with the option ‘–p-where’ during the filtering of the samples I typed ‘AND’ instead to just list the conditions and (correctly) it did not found any sample with both the conditions!
Sorry!

Thanks for your time, you helped me figuring out!

Alle

1 Like