# Importing Taxonomy Tables from dada2

**URL:** https://forum.qiime2.org/t/importing-taxonomy-tables-from-dada2/3609
**Category:** User Support
**Tags:** taxonomy, dada2, pending-development, import
**Created:** [March 29, 2018, 11:16pm UTC](https://forum.qiime2.org/t/importing-taxonomy-tables-from-dada2/3609 "2018-03-29T23:16:27Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![ChristianEdwardson](https://forum.qiime2.org/user_avatar/forum.qiime2.org/christianedwardson/32/4215_2.png) [@ChristianEdwardson](https://forum.qiime2.org/u/ChristianEdwardson)
#### Post date: [April 17, 2018, 11:56pm UTC](https://forum.qiime2.org/t/importing-taxonomy-tables-from-dada2/3609/10 "2018-04-17T23:56:35Z")

</div>

Thanks @colinbrislawn and @thermokarst for the suggestions, as well as [this post](https://forum.qiime2.org/t/exporting-dada2-r-package-results-to-work-with-qiime2/2573/5).

I have figured out how to get the taxonomy from dada2/phyloseq in the correct format to be added to both biom files correctly and qiime2. Posting the code here for anyone else that might be having troubles.  
One note: I needed to install the latest github version of [biomformat](https://github.com/joey711/biomformat) for R (version 1.7.0)

Starting in R with a phyloseq object (ps):

Format the taxonomy table:

> tax\<-as(tax\_table(ps),"matrix")  
> tax\_cols \<- c("Kingdom", "Phylum", "Class","Order","Family","Genus")  
> tax\<-as.data.frame(tax)  
> tax$taxonomy\<-do.call(paste, c(tax[tax\_cols], sep=";"))  
> for(co in tax\_cols) tax[co]\<-NULL  
> write.table(tax, "tax.txt", quote=FALSE, col.names=FALSE, sep="\t")

Make an biomformat OTU table:

> otu\<-t(as(otu\_table(ps),"matrix"))  
> otu\_biom\<-make\_biom(data=otu)  
> write\_biom(otu\_biom,"otu\_biom.biom")

Optional: In qiime2 to make a biom OTU table with taxonomy:  
(this step is not necessary for qiime2, as the taxonomy table is not imported from the biom file)

> biom convert -i otu\_biom.biom -o otu\_biom\_HDF5.biom --to-hdf5  
> biom add-metadata -i otu\_biom\_HDF5.biom -o otu\_wTax.biom --observation-metadata-fp tax.txt --observation-header OTUID,taxonomy --sc-separated taxonomy

Import the OTU table (feature table) to qiime2:

> qiime tools import \  
> --input-path otu\_wTax.biom \  
> --type 'FeatureTable[Frequency]' \  
> --source-format BIOMV210Format \  
> --output-path feature-table.qza

Finally, import the taxonomy table:

> qiime tools import \  
> --type 'FeatureData[Taxonomy]' \  
> --source-format HeaderlessTSVTaxonomyFormat \  
> --input-path tax.txt \  
> --output-path taxonomy.qza

---

_[View the full topic](https://forum.qiime2.org/t/importing-taxonomy-tables-from-dada2/3609)._
