amp_export_long: Transform ampvis2 objects into a long-format data frame

View source: R/amp_export_long.R

amp_export_longR Documentation

Transform ampvis2 objects into a long-format data frame

Description

Transforms any ampvis2 object into a long data frame (data.table) to facilitate custom data analysis. Only the elements OTU counts (data$abund), taxonomy (data$tax), and metadata (data$metadata) are used, not phylogenetic tree or DNA sequences.

Usage

amp_export_long(
  data,
  metadata_vars = colnames(data$metadata),
  tax_levels = colnames(data$tax)
)

Arguments

data

(required) Data list as loaded with amp_load.

metadata_vars

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

tax_levels

A character vector of taxonomic levels to include from data$tax, or NULL. The OTU column will always be included. Default includes all.

Value

A data.table in long format.

Author(s)

Kasper Skytte Andersen ksa@bio.aau.dk

Thomas Yssing Michaelsen tym@bio.aau.dk

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

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