# Filtering chimeras with Python API

**URL:** <https://forum.qiime2.org/t/filtering-chimeras-with-python-api/9264>\
**Category:** User Support\
**Tags:** python-api\
**Created:** [April 16, 2019, 8:36am UTC](https://forum.qiime2.org/t/filtering-chimeras-with-python-api/9264 "2019-04-16T08:36:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruben\_Gomez-Gordo](https://forum.qiime2.org/user_avatar/forum.qiime2.org/ruben_gomez-gordo/32/4354_2.png) [@Ruben\_Gomez-Gordo](https://forum.qiime2.org/u/Ruben_Gomez-Gordo)\
**Post date:** [April 16, 2019, 8:36am UTC](https://forum.qiime2.org/t/filtering-chimeras-with-python-api/9264/1 "2019-04-16T08:36:25Z")

</div>

Hi there, I had the following issue after using uchime\_ref in Python API:  
· I have my OTU table: OTU\_table.qza (OTU\_table variable).  
· I have my nonchimeric sequences returned by uchime\_ref: nonchim\_seqs.qza (nonchim\_seqs variable).  
I have succesfully filtered my OTU table using Linux commands:

> qiime feature-table filter-features --i-table OTU\_table.qza --m-metadata-file nonchim\_seqs.qza ...

The problem appears when I try to do this using Python API, when I try to use the nonchimeric sequences as metadata for the function:

> from qiime2.plugins.feature\_table.methods import filter\_features  
> filter\_features(OTU\_table, metadata = nonchim\_seqs)

This gives me the following error:  
Parameter 'metadata' received an argument of type FeatureData[Sequence]. An argument of subtype Metadata is required.

---

<div class="post-metadata">

**Author:** ![jwdebelius](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jwdebelius/32/9655_2.png) [@jwdebelius](https://forum.qiime2.org/u/jwdebelius)\
**Post date:** [April 16, 2019, 11:40am UTC](https://forum.qiime2.org/t/filtering-chimeras-with-python-api/9264/2 "2019-04-16T11:40:44Z")

</div>

Hi @Ruben_Gomez-Gordo,

Another API user! Hi 👋 !

The error is relatively descriptive: your `nonchim_seqs` object needs to be the `Metadata` class, rather than the `Artifact` class you currently have. My hack-tastic solution would be to export the `FeatureData[Sequence]` to a pandas DataFrame and then pass it into the `qiime2.Metadata` object. There may be a slicker solution, but I think it should solve your problem? (If not, maybe try passing it as a `MetadataCategory` object out of the `Metadata` object.)

Best,  
Justine

---

<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 16, 2019, 12:04pm UTC](https://forum.qiime2.org/t/filtering-chimeras-with-python-api/9264/3 "2019-04-16T12:04:15Z")

</div>

> [@jwdebelius](#):
>
> There may be a slicker solution

```auto
filter_features(OTU_table, metadata = nonchim_seqs.view(qiime2.Metadata))

```

---

<div class="post-metadata">

**Author:** ![Ruben\_Gomez-Gordo](https://forum.qiime2.org/user_avatar/forum.qiime2.org/ruben_gomez-gordo/32/4354_2.png) [@Ruben\_Gomez-Gordo](https://forum.qiime2.org/u/Ruben_Gomez-Gordo)\
**Post date:** [April 16, 2019, 12:06pm UTC](https://forum.qiime2.org/t/filtering-chimeras-with-python-api/9264/4 "2019-04-16T12:06:25Z")

</div>

Hi Justine, thanks for your response. You were right, using the qiime2. Metadata object was the way to do this.  
I've transformed the FeatureData[Sequence] artifact into Metadata using this method:  
`FeatureData[Sequence].view(qiime2.Metadata)`

Now it works 😄

---

<div class="post-metadata">

**Author:** ![jwdebelius](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jwdebelius/32/9655_2.png) [@jwdebelius](https://forum.qiime2.org/u/jwdebelius)\
**Post date:** [April 16, 2019, 1:00pm UTC](https://forum.qiime2.org/t/filtering-chimeras-with-python-api/9264/5 "2019-04-16T13:00:53Z")

</div>

@Nicholas_Bokulich, @Ruben_Gomez-Gordo,

Thank you! I learned something new today!

---

<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:** [May 17, 2019, 7:00pm UTC](https://forum.qiime2.org/t/filtering-chimeras-with-python-api/9264/6 "2019-05-17T19:00:56Z")

</div>

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