I need to calculate the top 6 taxa in each individual sample of my phyloseq object. It seems like it should be a simple request...but I have not been able to find a way to do this!
Thank you
I need to calculate the top 6 taxa in each individual sample of my phyloseq object. It seems like it should be a simple request...but I have not been able to find a way to do this!
Thank you
Maybe something like:
library(phyloseq)
library(tidyverse)
library(speedyseq)
as_tibble(p) |>
rename(Sample=.sample, ASV=.otu, Abundance=.abundance) |>
select(Sample, Abundance, ASV, Phylum, Class, Order, Family, Genus) |>
group_by(Sample) |>
slice_max(Abundance, n=6) |>
ungroup()
Where p is your phyloseq object with OTU table and Taxonomy table.
For speedyseq, see https://github.com/mikemc/speedyseq