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/
579 stars 188 forks source link

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

Open caroo-13 opened 4 years ago

caroo-13 commented 4 years ago

Hi everyone

I have an R code to load files from QIIME2 onto R using the phyloseq package. the code goes this way:

biom <- "D://otu_table_json.biom"
taxa <- "D:/table_w_tax.txt"
refseqfile <- "D/dna-sequences2fasta"
meta <- "/map.txt"
Tree <- /tree.nwk")

project1 = import_biom(biom, refseqfile)
bmsd <- import_qiime_sample_data(meta)
class(bmsd)
project2 <- merge_phyloseq(biom, Tree, meta)

colnames(tax_table(project2))
colnames(tax_table(project2)) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species")
colnames(taxa)
data.frame(tax_table(project2))

When I run colnames(tax_table(project2) I get the error:

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

and I can't continue running the rest of the code, because the taxonomic levels are not being assigned. Any idea why this would be?

I know that the code works, because I've used this exact same code for another project, and the input files (biom, fasta, tree, table_w_taxa) were obtained from QIIME2 in the exact same manner.

I've also noticed that in the other project that I've used this code "project1" and "project2" are described by R as "Large Phyloseq 1.8 MB" and in this code "project1" are described as "Formal classotu_table" and "project2" as "List of 5"

Sorry if this kinda of an obvious error, but I've Google it and I just can't make sense of it. any help would be greatly appreciated

Thanks, Carolina

mikemc commented 4 years ago

First step is to look at the tutorials (on the phyloseq website) and vignettes (run browseVignettes("phyloseq") from within R) regarding importing data.

The error is indicating that the phyloseq object project2 does not have a taxonomy table. Does your biom file "D://otu_table_json.biom" include the taxonomy information, or is that in the file "D:/table_w_tax.txt"? If it is in the file "D:/table_w_tax.txt", then you'll need to import that file into R and get it as a tax_table() object, and then merge it with the phyloseq object. Right now you aren't importing that file, you're just saving the name of it to the variable taxa. See the tutorials for more info.

caroo-13 commented 4 years ago

Hi @mikemc

Thanks for your answer and recommendations.

I've tried converting the biom file to .tsv file, add the taxa from the table_w_taxa.txt document, and then run the code again. the result is now a matrix with only 1 Rank, rather than 7. Any idea of how to indicate the 7 Ranks?

Thanks again