aggregateTaxa: Aggregate a taxon abundance matrix

View source: R/aggregateTaxa.R

aggregateTaxaR Documentation

Aggregate a taxon abundance matrix

Description

Given a taxon and a lineage matrix, aggregate taxa belonging to the same higher-level taxon at the specified taxonomic level by summing their abundance.

Usage

aggregateTaxa(
  x,
  lineages,
  taxon.level = "class",
  unknown = c(NA, "unclassified"),
  keepUnknown = FALSE,
  keepSumUnknown = FALSE,
  returnLineages = FALSE
)

Arguments

x

an abundance matrix with taxa as rows and samples as columns

lineages

a lineage matrix where row names match row names of taxa; taxa must be provided in the same order as in x; first column gives kingdom, following columns give phylum, class, order, family, genus and species

taxon.level

taxonomic level to which data set is aggregated (kingdom, phylum, class, order, family, genus or species)

unknown

descriptors for unclassified taxa

keepUnknown

keep taxa without higher-level taxon classification; cannot be used together with keepSumUnknown

keepSumUnknown

keep the sum of taxa without higher-level taxon classification on the desired level as last row (row name: sumUnknown)

returnLineages

return lineage matrix for higher-level taxon matrix; if true a list is returned with two elements: abundances and lineages

Value

the aggregated abundance matrix; if returnLineages is true, a list with aggregated abundances and matching lineages

Examples

data("ibd_taxa")
data("ibd_lineages")
ibd_class=aggregateTaxa(x=ibd_taxa,lineages=ibd_lineages)

hallucigenia-sparsa/seqgroup documentation built on July 6, 2022, 1:11 p.m.