简体   繁体   中英

Calculate top taxa per sample in a phyloseq object

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM