% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/amp_export_long.R
\name{amp_export_long}
\alias{amp_export_long}
\title{Transform ampvis2 objects into a long-format data frame}
\usage{
amp_export_long(
  data,
  metadata_vars = colnames(data$metadata),
  tax_levels = colnames(data$tax)
)
}
\arguments{
\item{data}{(\emph{required}) Data list as loaded with \code{\link{amp_load}}.}

\item{metadata_vars}{A character vector of sample metadata variables to include from \code{data$metadata}, or \code{NULL}. The first column (sample IDs) will always be included. Default includes all.}

\item{tax_levels}{A character vector of taxonomic levels to include from \code{data$tax}, or \code{NULL}. The OTU column will always be included. Default includes all.}
}
\value{
A \code{data.table} in long format.
}
\description{
Transforms any ampvis2 object into a long data frame (\code{data.table}) to facilitate custom data analysis. Only the elements OTU counts (\code{data$abund}), taxonomy (\code{data$tax}), and metadata (\code{data$metadata}) are used, not phylogenetic tree or DNA sequences.
}
\examples{
# load minimal example data
d <- amp_load(example_otutable, example_metadata)

# transform d into a long-format data frame
d_long <- amp_export_long(d, metadata_vars = "Date", tax_levels = c("OTU", "Genus"))

# print the data frame (data.table)
d_long
}
\author{
Kasper Skytte Andersen \email{ksa@bio.aau.dk}

Thomas Yssing Michaelsen \email{tym@bio.aau.dk}
}
