top_taxa: top_taxa

View source: R/top_taxa.R

top_taxaR Documentation

top_taxa

Description

Arrange top taxa in descending order. Assessed based on cumulative sum, so only the top (80% for example) taxa are returned.

Usage

top_taxa(relab_df, cutoff)

Arguments

cutoff

numeric. between 0 and 1. Cut-off abundance for what is considered as "top taxa." Default 0.8. Taxa with abundances less than the cut-off are lumped together as "Other"

relab

dataframe or matrix. relative abundance matrix with taxa in rows (as rownames) and samples in columns

Value

dataframe of taxa, sample_id, relative abundance, and cumulative sum of relative abundance.

Examples

# put asv relative abundance features in same order as taxonomy table
# get relative abundance data
asv_mat <- dss_example$merged_abundance_id[,2:ncol(dss_example$merged_abundance_id)]
rownames(asv_mat) <- dss_example$merged_abundance_id$featureID
relab_data <- relab(asv_mat)
# match row order of relative abundance and taxonomy data
relab_data <- relab_data[match(dss_example$merged_taxonomy$featureID,
                               rownames(relab_data)),]
# prepend X to column names
colnames(relab_data) <- sprintf("X%s", colnames(relab_data))
# get genus-level relative abundance
genus_df <- aggregate_count(relab_data, dss_example$merged_taxonomy, 'Genus')$count_df

# get top taxa
top80 <- top_taxa(genus_df, cutoff=0.8)
print(top80 %>% filter(sample_id == unique(top80$sample_id)[1]))


OxfordCMS/OCMSutility documentation built on Feb. 27, 2025, 8:19 p.m.