# qiime taxa-collapse problem - sequence item 0: expected str instance, float found

**URL:** https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109
**Category:** User Support
**Tags:** taxonomy, collapse, ancom
**Created:** [January 2, 2023, 12:41am UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109 "2023-01-02T00:41:02Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![joaomiranda](https://forum.qiime2.org/user_avatar/forum.qiime2.org/joaomiranda/32/14795_2.png) [@joaomiranda](https://forum.qiime2.org/u/joaomiranda)
#### Post date: [January 2, 2023, 12:41am UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/1 "2023-01-02T00:41:02Z")

</div>

Hi everyone, happy new year! 😀 🍾

I had some problems when I've running `qiime taxa collapse` to obtain an ANCOM .qzv file, to visualize differential abundance taxa in mosquitoes microbiome composition.

It was sent to me a `FeatureTable[Frequency]`, containing taxonomic information, that I've converted to a .qza file. Also, to run `qiime taxa collapse`, I built a taxonomy.qza file, converting an .txt file to .qza containing "Feature ID" and "Taxon" headers.

Here is my code:

```auto
qiime tools import \
  --input-path Bacteria_Taxonomy.txt\
  --output-path Bacteria_taxonomy.qza \
  --type FeatureData[Taxonomy]
  
  qiime taxa collapse \
   --i-table ANCOM/filtered-bacteria-table-min10.qza \
   --i-taxonomy Bacteria_taxonomy.qza \
   --p-level 5 \
   --o-collapsed-table ANCOM/filtered_table_bacteria_level-5.qza

```

And here is the error after runned `qiime taxa collapse`:

```auto
sequence item 0: expected str instance, float found

```

Here are my files:  
[Bacteria\_taxonomy.qza](https://forum.qiime2.org/uploads/short-url/6XlszI4gGuUxalBQJJ19cbb6bbg.qza) (7.2 KB)  
[Bacteria\_Taxonomy.txt](https://forum.qiime2.org/uploads/short-url/7QXPglCpsBaVpLO13S6Y0byMKjl.txt) (30.3 KB)  
[Metadata.txt](https://forum.qiime2.org/uploads/short-url/4OE9Qz0ZVE5LoXD4QgntJhrHK5f.txt) (865 Bytes)  
[filtered-bacteria-table-min10.qza](https://forum.qiime2.org/uploads/short-url/ukoeBX0M86vN0TUecll7m7GbhP1.qza) (20.1 KB)

How can I solve this error? It's something wrong with my taxonomy file?  
Thanks in advance!

---

<div class="post-metadata">

### Author: ![crusher083](https://forum.qiime2.org/user_avatar/forum.qiime2.org/crusher083/32/9597_2.png) [@crusher083](https://forum.qiime2.org/u/crusher083)
#### Post date: [January 2, 2023, 8:09am UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/2 "2023-01-02T08:09:38Z")

</div>

Hello,

as in error, probably QIIME2 infers the datatype wrong, please replace numbers in Feature\_ID for some string (like `ID1`, `ID2`, etc.) and rerun the command.  
You will need to correct entries in your `FeatureTable` as well.

Cheers  
V

---

<div class="post-metadata">

### Author: ![timanix](https://forum.qiime2.org/user_avatar/forum.qiime2.org/timanix/32/17879_2.png) [@timanix](https://forum.qiime2.org/u/timanix)
#### Post date: [January 2, 2023, 9:33am UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/3 "2023-01-02T09:33:47Z")

</div>

Hello!  
In addition to @crusher083 excellent reply, I noticed that you attempted to collapse your table to the level 5, meanwhile in your taxonomy file you do not have different taxonomy levels. I am not sure if it will work, but if you want to collapse sequences with the same annotations as it is now in your taxonomy file, you can try to collapse it to level 0. Another option is to add full taxonomy information, including all available taxonomy ranks (domain, phylum, etc) and then collapse to desired level (5 or another).

Best,

---

<div class="post-metadata">

### Author: ![joaomiranda](https://forum.qiime2.org/user_avatar/forum.qiime2.org/joaomiranda/32/14795_2.png) [@joaomiranda](https://forum.qiime2.org/u/joaomiranda)
#### Post date: [January 2, 2023, 3:14pm UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/4 "2023-01-02T15:14:41Z")

</div>

Hi @crusher083 @timanix , thank you for the support!

Firstly, I followed @crusher083 recommendations and altered the Feature ID in my Taxonomy file and `FeatureTable` to strings (`ID1,ID2,ID3...ID214`). Secondly, I converted these files to .qza.

Thus, I runned `qiime taxa collapse` with `--p-level 0`, again the same error appeared:

```auto
 sequence item 0: expected str instance, float found

```

I tried to replace the taxonomy information for taxonomy ranks, until family, editing my taxonomy and feature table files.

I runned again `qiime taxa collapse`, now with `--p-level 5`. And the same error repeated.

[Bacteria\_taxonomy.txt](https://forum.qiime2.org/uploads/short-url/YQz7hs3tKlQc5TsbmCmCsGkxK3.txt) (44.9 KB)  
[Bacteria-family.txt](https://forum.qiime2.org/uploads/short-url/1qSJt6wQXEkf3e4peqiuMRW5EgH.txt) (51.0 KB)

---

<div class="post-metadata">

### Author: ![timanix](https://forum.qiime2.org/user_avatar/forum.qiime2.org/timanix/32/17879_2.png) [@timanix](https://forum.qiime2.org/u/timanix)
#### Post date: [January 2, 2023, 3:46pm UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/5 "2023-01-02T15:46:36Z")

</div>

Hi again, could you please replace "|" symbols with ";" in taxonomy file.  
Also, make sure that you do not have any "nan" values, or empty cells (in Taxon column) in the taxa file.  
BTW, in the feature table, feature ids (not taxonomies) should be provided (as in "Feature ID" column in the taxonomy file).

---

<div class="post-metadata">

### Author: ![joaomiranda](https://forum.qiime2.org/user_avatar/forum.qiime2.org/joaomiranda/32/14795_2.png) [@joaomiranda](https://forum.qiime2.org/u/joaomiranda)
#### Post date: [January 2, 2023, 4:59pm UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/6 "2023-01-02T16:59:26Z")

</div>

Hi @timanix, I've replaced "|" symbols with ";" in my taxonomy file. I've checked for empty cells in these file, and it returns to me as a table with filled cells, so it's okay to me.  
[Bacteria\_taxonomy.txt](https://forum.qiime2.org/uploads/short-url/rGmtCQxLrYG5QTyRRPZcbTHx96o.txt) (45.3 KB)

My feature table contains feature ids, also there is a "Taxon" collum but it works to use te `FeatureTable` with a taxonomy collum for other analysis in qiime2, so I think the point is specific with the taxonomy table.  
[Bacteria-family.txt](https://forum.qiime2.org/uploads/short-url/afgkPegy3BPpgPElcZBaCYkBBTa.txt) (51.4 KB)

 ![imagem que vou usar](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/d/da055049df293b6c28250e79292266119840edce.png)

I've runned the code again, and got the same error 😔

I've checked these discussions [here](https://forum.qiime2.org/t/typeerror-in-importing-silva-taxonomy/3879/13) and [here](https://forum.qiime2.org/t/gneiss-balance-taxonomy-error/4294/9). And it seems that maybe it's a formatting error in my taxonomy table.

I've runned `qiime metada tabulate` to obtain a .qzv file for my taxonomy table, and here is the result:

```auto
qiime metadata tabulate \
  --m-input-file Bacteria_taxonomy.qza \
  --o-visualization Bacteria_taxonomy.qzv

There was an issue with viewing the artifact Bacteria_taxonomy.qza as QIIME 2 Metadata:

  sequence item 0: expected str instance, float found

```

I don't know, but it looks like something is missing from the rows of my taxonomy table.

---

<div class="post-metadata">

### Author: ![timanix](https://forum.qiime2.org/user_avatar/forum.qiime2.org/timanix/32/17879_2.png) [@timanix](https://forum.qiime2.org/u/timanix)
#### Post date: [January 2, 2023, 5:29pm UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/7 "2023-01-02T17:29:06Z")

</div>

Looks like you have a lot of nans in your taxonomy file (I guess that reason is numerous tabs everywhere)

 ![Screenshot from 2023-01-02 18-17-31](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/a/a3d82ea12e516ccc700aca676a6b483e63f1e26b.png)

So I fixed it for you (if the file is not complete, just remove all extra "tab" signs from your complete file.

 ![Screenshot from 2023-01-02 18-24-45](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/0/05a3650e1595cda05c7e3fb82e9c98bf2b869062.png)

[Bacteria\_taxonomy\_nonans.txt](https://forum.qiime2.org/uploads/short-url/7LPJKVhdheOxd0MRcrVk14BmxFi.txt) (18.9 KB)

Hope that now it will work as supposed to.

---

<div class="post-metadata">

### Author: ![joaomiranda](https://forum.qiime2.org/user_avatar/forum.qiime2.org/joaomiranda/32/14795_2.png) [@joaomiranda](https://forum.qiime2.org/u/joaomiranda)
#### Post date: [January 2, 2023, 5:55pm UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/8 "2023-01-02T17:55:59Z")

</div>

It works!

Thank you so much, the issue it was the "nans" as you mentioned.

---

<div class="post-metadata">

### Author: ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)
#### Post date: [February 2, 2023, 11:56pm UTC](https://forum.qiime2.org/t/qiime-taxa-collapse-problem-sequence-item-0-expected-str-instance-float-found/25109/9 "2023-02-02T23:56:09Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
