Generates a timeseries plot showing relative read abundances over time.

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,
  ...
)

Arguments

data

(required) Data list as loaded with amp_load.

time_variable

(required) The name of the column in the metadata containing the time variables, e.g. "Date". Must be directly compatible with as_date and preferably of the form "yyyy-mm-dd" or "%Y-%m-%d".

group_by

Group the samples by a variable in the metadata.

tax_aggregate

The taxonomic level to aggregate the OTUs. (default: "OTU")

tax_add

Additional taxonomic level(s) to display, e.g. "Phylum". (default: "none")

tax_show

The number of taxa to show, or a vector of taxa names. (default: 6)

tax_class

Converts a specific phylum to class level instead, e.g. "p__Proteobacteria".

tax_empty

How to show OTUs without taxonomic information. One of the following:

  • "remove": Remove OTUs without taxonomic information.

  • "best": (default) Use the best classification possible.

  • "OTU": Display the OTU name.

split

Split the plot into subplots of each taxa. (default: FALSE)

scales

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

normalise

(logical) Transform the OTU read counts to be in percent per sample. (default: TRUE)

plotly

(logical) Returns an interactive plot instead. (default: FALSE)

...

Additional arguments passed to as_date to make the time_variable compatible with the timeseries plot, fx the format or tz arguments, see ?as_date.

Value

A ggplot2 object.

Preserving relative abundances in a subset of larger data

See ?amp_subset_samples or the ampvis2 FAQ.

See also

Author

Julie Klessner Thun Pedersen julieklessnerthun@gmail.com

Kasper Skytte Andersen ksa@bio.aau.dk

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" )
#> Warning: Duplicate dates in column Date, displaying the average for each date. #> Consider grouping dates using the group_by argument or subset the data using amp_subset_samples.
#> Warning: `group_by_()` is deprecated as of dplyr 0.7.0. #> Please use `group_by()` instead. #> See vignette('programming') for more help #> This warning is displayed once every 8 hours. #> Call `lifecycle::last_warnings()` to see where this warning was generated.
# 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" )