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:
Hi @marwa38 You can do this without using functions from the `microbiome` package.
library(phyloseq)
library(ggplot2)
data(GlobalPatterns)
GP <- GlobalPatterns
# Agglomerate taxa at genus level
GP.genus <- tax_glom(GP, taxrank = "Genus")
# Top N taxa
N <- 20
top <- names(sort(taxa_sums(GP.genus), decreasing = TRUE))[1:N]
# Calculate relative abundance
GP.genus.prop <- transform_sample_counts(GP.genus, function(x) x / sum(x) )
# Subset object to top N taxa
GP.genus.prop.top <- prune_taxa(top, GP.genus.prop)
If you wish to use
psmelt
:Originally posted by @ycl6 in https://github.com/joey711/phyloseq/issues/1516#issuecomment-975938425