% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/amp_timeseries.R
\name{amp_timeseries}
\alias{amp_timeseries}
\alias{amp_time_series}
\title{Abundance timeseries}
\usage{
amp_timeseries(
  data,
  time_variable = NULL,
  group_by = NULL,
  tax_aggregate = "OTU",
  tax_add = NULL,
  tax_show = 5,
  tax_class = NULL,
  tax_empty = "best",
  split = FALSE,
  scales = "free_y",
  normalise = TRUE,
  plotly = FALSE,
  ...
)

amp_time_series(
  data,
  time_variable = NULL,
  group_by = NULL,
  tax_aggregate = "OTU",
  tax_add = NULL,
  tax_show = 5,
  tax_class = NULL,
  tax_empty = "best",
  split = FALSE,
  scales = "free_y",
  normalise = TRUE,
  plotly = FALSE,
  ...
)
}
\arguments{
\item{data}{(\emph{required}) Data list as loaded with \code{\link{amp_load}}.}

\item{time_variable}{(required) The name of the column in the metadata containing the time variables, e.g. \code{"Date"}. Must be directly compatible with \code{\link[lubridate]{as_date}} and preferably of the form \code{"yyyy-mm-dd"} or \code{"\%Y-\%m-\%d"}.}

\item{group_by}{Group the samples by a variable in the metadata.}

\item{tax_aggregate}{The taxonomic level to aggregate the OTUs. (\emph{default:} \code{"OTU"})}

\item{tax_add}{Additional taxonomic level(s) to display, e.g. \code{"Phylum"}. (\emph{default:} \code{"none"})}

\item{tax_show}{The number of taxa to show, or a vector of taxa names. (\emph{default:} \code{6})}

\item{tax_class}{Converts a specific phylum to class level instead, e.g. \code{"p__Proteobacteria"}.}

\item{tax_empty}{How to show OTUs without taxonomic information. One of the following:
\itemize{
   \item \code{"remove"}: Remove OTUs without taxonomic information.
   \item \code{"best"}: (\emph{default}) Use the best classification possible.
   \item \code{"OTU"}: Display the OTU name.
   }}

\item{split}{Split the plot into subplots of each taxa. (\emph{default:} \code{FALSE})}

\item{scales}{If \code{split = TRUE}, should the axis scales of each subplot be fixed (\code{fixed}), free (\code{"free"}), or free in one dimension (\code{"free_x"} or \code{"free_y"})? (\emph{default:} \code{"fixed"})}

\item{normalise}{(\emph{logical}) Transform the OTU read counts to be in percent per sample. (\emph{default:} \code{TRUE})}

\item{plotly}{(\emph{logical}) Returns an interactive plot instead. (\emph{default:} \code{FALSE})}

\item{...}{Additional arguments passed to \code{\link[lubridate]{as_date}} to make the time_variable compatible with the timeseries plot, fx the \code{format} or \code{tz} arguments, see \code{?as_date}.}
}
\value{
A ggplot2 object.
}
\description{
Generates a timeseries plot showing relative read abundances over time.
}
\section{Preserving relative abundances in a subset of larger data}{

See \code{?\link{amp_filter_samples}} or the \href{https://kasperskytte.github.io/ampvis2/articles/faq.html#preserving-relative-abundances-in-a-subset-of-larger-data}{ampvis2 FAQ}.
}

\examples{

# Load example data
data("AalborgWWTPs")

# Timeseries of the 5 most abundant OTUs based on the "Date" column
amp_timeseries(AalborgWWTPs,
  time_variable = "Date",
  tax_aggregate = "OTU"
)

# As the above warning suggests, there are more than one sample per date in the data,
# in this case one from Aalborg East and one from Aalborg West. The average of the
# two samples is then shown per date. In such case it is then recommended to either
# subset the data, or group the samples by setting group_by = "" and split by tax_aggregate
# by setting split = TRUE:
amp_timeseries(AalborgWWTPs,
  time_variable = "Date",
  group_by = "Plant",
  split = TRUE,
  scales = "free_y",
  tax_show = 9,
  tax_aggregate = "Genus",
  tax_add = "Phylum"
)
}
\seealso{
\code{\link{amp_load}}
}
\author{
Julie Klessner Thun Pedersen \email{julieklessnerthun@gmail.com}

Kasper Skytte Andersen \email{ksa@bio.aau.dk}
}
\keyword{timeseries}
