% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/internals.R
\name{aggregate_abund}
\alias{aggregate_abund}
\title{Aggregate OTUs to a specific taxonomic level}
\usage{
aggregate_abund(
  abund,
  tax,
  tax_aggregate = "OTU",
  tax_add = NULL,
  calcSums = TRUE,
  format = "long"
)
}
\arguments{
\item{abund}{The OTU abundance table from an ampvis2 object (\code{ampvis2obj$abund})}

\item{tax}{The OTU abundance table from an ampvis2 object (\code{ampvis2obj$tax})}

\item{tax_aggregate}{Aggregate (sum) OTU's to a specific taxonomic level. (\emph{default:} \code{"OTU"})}

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

\item{calcSums}{Whether to include the sums of read counts for each sample and taxonomic group. (\emph{default:} \code{TRUE})}

\item{format}{Output format, \code{"long"} or \code{"abund"}. \code{"abund"} corresponds to that of a read counts table with samples as columns and the aggregated taxa as rows.}
}
\value{
A data.table.
}
\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.
}
\examples{
data("AalborgWWTPs")
aggregated <- aggregate_abund(
  AalborgWWTPs$abund,
  AalborgWWTPs$tax,
  tax_aggregate = "Genus",
  tax_add = "Phylum",
  format = "long",
  calcSums = TRUE
)
aggregated
}
\author{
Kasper Skytte Andersen \email{ksa@bio.aau.dk}
}
