Closed kunstner closed 3 years ago
Hi Axel @kunstner
The phylotype table has a different structure from OTU table because each OTU is now a taxonomic classification unlike in OTU tables where you had OTU IDs AND taxonomic classifications. This might be the reason causing the issue (I don't use phyloseq by the way).
One way to resolve this is by not using the phylotype file at all but importing the OTU table and then phylotyping it by yourself in R. And, this is how I would do it:
otu = read.csv("otu_table.txt", row.names = 1, sep = "\t", skip = 1)
otu = otu %>% select(-taxonomy)
tax = read.csv("assigned_taxonomy_reformatted_filtered.txt", sep = "\t", header = FALSE)
colnames(tax) = c("OTU", "taxonomy", "threshold")
tax = tax %>% separate(taxonomy, into = c("Kingdom","Phylum", "Class", "Order", "Family", "Genus", "Species"), sep = "; ")
And now you can aggregate into phylotypes at different levels by:
otu_k = aggregate(otu, tax[1:1], FUN = sum)
otu_p = aggregate(otu, tax[1:2], FUN = sum)
otu_c = aggregate(otu, tax[1:3], FUN = sum)
otu_o = aggregate(otu, tax[1:4], FUN = sum)
otu_f = aggregate(otu, tax[1:5], FUN = sum)
otu_g = aggregate(otu, tax[1:6], FUN = sum)
otu_s = aggregate(otu, tax[1:7], FUN = sum)
Let me know if this works?
Hi @hsgweon,
thanks for the quick reply! It works!
Best, Axel
Perfect!
Hi,
I have an issue importing the phylotype table using the phyloseq package. I tried phylotype table from different pipits runs. All show the same behavior (see below).
The normal biom file (otu_tabke.biom) just works fine.
Any suggestings to get rid off this error?
Thanks a lot!
Best, Axel