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

Estimate_richness for all phyla #1658

Open R-novice opened 1 year ago

R-novice commented 1 year ago

Hi everyone,

Is there a way to get ASV richness for each e.g. phylum/Division for each Station? So far I have just been subsetting Phyla of interest using for example:

ps.cocco <- subset_taxa(ps, Phylum == "Prymnesiophyceae")
alpha_diversity<-estimate_richness(ps.cocco,measure=c("Shannon","Observed"))
H<-alpha_diversity$Shannon
S1<-alpha_diversity$Observed
S<-log(S1)
evenness<-H/S
alpha<-cbind(Shannon=H,Richness=S1,Evenness=evenness,sample_data(ps.cocco))

But this is rather a pain when having to do it for e.g. the top 20 phyla. Any help would be appreciated!

Thanks, Daniela