aggregate_abund: Aggregate OTUs to a specific taxonomic level

View source: R/internals.R

aggregate_abundR Documentation

Aggregate OTUs to a specific taxonomic level

Description

Sums up all OTU read counts at the chosen taxonomic level. Used internally in many ampvis2 functions, but can also be used separately for custom purposes.

Usage

aggregate_abund(
  abund,
  tax,
  tax_aggregate = "OTU",
  tax_add = NULL,
  calcSums = TRUE,
  format = "long"
)

Arguments

abund

The OTU abundance table from an ampvis2 object (ampvis2obj$abund)

tax

The OTU abundance table from an ampvis2 object (ampvis2obj$tax)

tax_aggregate

Aggregate (sum) OTU's to a specific taxonomic level. (default: "OTU")

tax_add

Add additional (higher) taxonomic levels to the taxonomy string. The OTU's will be aggregated to whichever level of the tax_aggregate and tax_add vectors is the lowest. (default: NULL)

calcSums

Whether to include the sums of read counts for each sample and taxonomic group. (default: TRUE)

format

Output format, "long" or "abund". "abund" corresponds to that of a read counts table with samples as columns and the aggregated taxa as rows.

Value

A data.table.

Author(s)

Kasper Skytte Andersen ksa@bio.aau.dk

Examples

data("AalborgWWTPs")
aggregated <- aggregate_abund(
  AalborgWWTPs$abund,
  AalborgWWTPs$tax,
  tax_aggregate = "Genus",
  tax_add = "Phylum",
  format = "long",
  calcSums = TRUE
)
aggregated

MadsAlbertsen/ampvis2 documentation built on Jan. 28, 2024, 7:12 a.m.