joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
586 stars 186 forks source link

trouble with using the output from idtaxa with phyloseq #1678

Open MCK-sketch opened 1 year ago

MCK-sketch commented 1 year ago

Hi, I used IdTaxa to create a taxonomy table, but I am having trouble using it to create a phyloseq object. I get the error

Error in access(object, "tax_table", errorIfNULL) : tax_table slot is empty.

The output from idtaxa looks good in that it seems to have taxonomy assigned to sequences. Can someone let me know how I can fix this?

Thanks,

MCK-sketch commented 1 year ago

Hi again,

I am opening this thread as a have a similar issue when following this part of the tutorial but using my own data.

I used IdTaxa taxonomic classification method classifying against the silva v138 database and then with Pr2 v5 and then with pr2 v14. I checked the output taxa object from DECIPHER and there is taxonomy assigned for the ASVs.

When I use the code block in the tutorial that allows you to use IdTaxa as a drop-in replacement for assignTaxonomy, I have a problem with the pr2 taxonomy when converting the idtaxa output taxa class object to a matrix analogous to the output from assignTaxonomy (silva worked fine). One thing i notices is that IdTaxa output when using silva has as a list with three elements (taxon, confidence, rank) but the IdTaxa output when using pr2 only had two elements (taxon, confidence).

The problem I have is that every element in the matrix ends up as NA.

This is what I tried:

attempt with idtaxa output and pr2 database

ids <- ids_pr2v5 # rename file ranks <- c("domain", "supergroup","division","subdivision","class","order","family","genus","species") # ranks of interest

Convert the output object of class "Taxa" to a matrix analogous to the output from assignTaxonomy

taxid <- t(sapply(ids, function(x) { m <- match(ranks, x$rank) taxa <- x$taxon[m] taxa[startsWith(taxa, "unclassified_")] <- NA taxa }))

colnames(taxid) <- ranks; rownames(taxid) <- getSequences(seqtab.nochim)

image