Open sarakn97 opened 1 year ago
I believe that I figured it out with tax_glom?
# Merges ASVs that have the same taxonomy rank (Genus)
psga = tax_glom(asthma, taxrank = "Genus")
# Calculate taxa sum of the selected samples
ps.tA<- transform_sample_counts(psga, function(OTU) OTU/sum(OTU))
top10A_counts<- sort(taxa_sums(ps.tA), decreasing = TRUE)[1:10]
top10_A <- names(sort(taxa_sums(ps.tA), decreasing = TRUE))[1:10]
taxA <- tax_table(asthma)[top10_A,]
Yes, tax_glom
is the right function. However, you should set NArm = F
to avoid discarding ASVs without a genus annotation - if not, your relative abundances will not be correct.
Hello, I need to identify the top 10 most abundant Genus for the Asthma Samples and the Control Samples that I have.
I have the following phyloseq object:
phyloseq-class experiment-level object otu_table() OTU Table: [ 546 taxa and 37 samples ] sample_data() Sample Data: [ 37 samples by 12 sample variables ] tax_table() Taxonomy Table: [ 546 taxa by 7 taxonomic ranks ] refseq() DNAStringSet: [ 546 reference sequences ]
14 of the Samples have Asthma and 23 Do not. I subset the phyloseq object into two groups: those with asthma and control. I used the following command to get the top taxa for the Asthma group and Control:
Get most abundant taxa for asthma group
top10_A <- names(sort(taxa_sums(asthma), decreasing = TRUE)[1:10])
get most abundant for control
top10_C <- names(sort(taxa_sums(no_asthma), decreasing = TRUE)[1:10])
tax_table(asthma)[top10_A,] tax)tables(no_asthma)[top10_C,]
So the above returned the top 10 most abundant ASVs and the respective taxonomy of those ASVs. However, I was asked to find the most abundant Genera, how do I perform this only based on Genus and the respective relative abundance at the genus level? For example, in the results below, ASV1 and ASV38 have the same Genus..
Results::::
Thank You.