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/
584 stars 187 forks source link

Removing Ranks from taxa table #762

Open Biancabrown opened 7 years ago

Biancabrown commented 7 years ago

Hey Guys,

I am analyzing closed otu picking data that I acquired through qiime. However, I used a silva database. With that my OTU table consists of 16 taxonomic ranks(8-16 is basically NA)

So my question is, is there a way for me to remove ranks 8-16, and ran 1-7 as Domain, phylum etc.? I already tried ranking 1-7 with the otu table as is, but I received the following error: "Error in colnames<-(*tmp*, value = c("Domain", "Phylum", "Class", : length of 'dimnames' [2] not equal to array extent"

Thanks!

campenr commented 7 years ago

Assuming that columns 1-7 were equivalent to the taxonomic levels you want you could just do:

# assuming you have a phyloseq object called physeq
tax_table(physeq) <- tax_table(physeq)[,1:7]

However, I don't think that the first 7 columns in the SILVA classifications actually equate to the 7 major taxonomic levels of Domain through Species that you are after. In that case you will just need to subset your tax_table using a list of the columns you want to keep, but the principal of how to modify the phyloseq object remains the same.

Cheers Richard

grabear commented 6 years ago

854