Multiple features with same taxon


I am using the feature-classifier classifier-sklearn to match Taxa to myfeatures, then taxa barplot to match them to my table.
The problem is several features have identicaltaxon names. When i look at the .csv file output from the batplots.qzv, it shows taxa names but not features. That is a problem if I want to get the exact feature ID (and, eventually, dna sequence) associated with that feature.
What can I do?

I think what you want to do is pretty straightforward with the artifact API.

With qiime active run this as a python script, or in an interactive python session. It should produce four csv files which hopefully give what you’re looking for. You may need to change the filenames to match your own.

from qiime2 import Artifact
import pandas as pd
# load the Artifacts
table = Artifact.load("table.qza").view(pd.DataFrame)
taxonomy = Artifact.load("taxonomy.qza").view(pd.DataFrame)
rep_seqs = Artifact.load("rep-seqs.qza").view(pd.Series)
# save the normal table as a csv
# annotate and save the table with the taxonomy assignments
# not combined unlike the barplots
table.rename(columns = taxonomy.Taxon).to_csv("taxa_table.csv")
# you can do the same with the sequences
table.rename(columns = rep_seqs).to_csv("seq_table.csv")
# reindex the taxonomy to use the sequences rather than the hash
taxonomy.index = rep_seqs[taxonomy.index].apply(str).values
# and save it

Thanks. This is a start, but i still have to manually match the results to my .csv file from the barplots. That would be a pain for a file with hundreds of features, and would still be impossible if two features have the same taxon and same distribution in the samples.
Is there a way to edit the .qza files so they use features instead of taxonomy, or so i can manually edit the taxa to be unique?

Hi @mshelomi,
The taxa barplots always collapses features by taxonomy — otherwise the barplots would be unreadable! You may want to try feature-table heatmap to instead make a heatmap of each individual feature. You can make a heatmap of ASVs, or collapse your table on taxonomy and then make a heatmap of taxonomic abundances.