# Problem with 'taxa collapse'

**URL:** https://forum.qiime2.org/t/problem-with-taxa-collapse/9081
**Category:** Technical Support
**Created:** [April 1, 2019, 12:09pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081 "2019-04-01T12:09:44Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![allebiotech](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@allebiotech](https://forum.qiime2.org/u/allebiotech)
#### Post date: [April 1, 2019, 12:09pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/1 "2019-04-01T12:09:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)
#### Post date: [April 2, 2019, 12:19pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/2 "2019-04-02T12:19:38Z")

</div>

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.

> [@allebiotech](#):
>
> What should I do?

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:

```auto
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!

---

<div class="post-metadata">

### Author: ![allebiotech](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@allebiotech](https://forum.qiime2.org/u/allebiotech)
#### Post date: [April 2, 2019, 1:20pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/3 "2019-04-02T13:20:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)
#### Post date: [April 2, 2019, 1:59pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/4 "2019-04-02T13:59:49Z")

</div>

could you please also share the `summarize` command you used?

---

<div class="post-metadata">

### Author: ![allebiotech](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@allebiotech](https://forum.qiime2.org/u/allebiotech)
#### Post date: [April 2, 2019, 2:10pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/5 "2019-04-02T14:10:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)
#### Post date: [April 2, 2019, 2:19pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/6 "2019-04-02T14:19:05Z")

</div>

> [@allebiotech](#):
>
> where ‘filtered\_otu\_table.qza’ is the result of the ‘qiime feature-table filter-samples’ command.

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.

---

<div class="post-metadata">

### Author: ![allebiotech](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@allebiotech](https://forum.qiime2.org/u/allebiotech)
#### Post date: [April 2, 2019, 3:35pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/7 "2019-04-02T15:35:05Z")

</div>

Your second guess is right! 🙂  
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

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [April 2, 2019, 3:36pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/8 "2019-04-02T15:36:23Z")

</div>

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

> [@allebiotech](#):
>
> Do you think should I change the header? (maybe it doesn’t recognize “Treatment”)

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

---

<div class="post-metadata">

### Author: ![allebiotech](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/43a26b/32.png) [@allebiotech](https://forum.qiime2.org/u/allebiotech)
#### Post date: [April 2, 2019, 3:56pm UTC](https://forum.qiime2.org/t/problem-with-taxa-collapse/9081/9 "2019-04-02T15:56:16Z")

</div>

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
