Learn R Programming

eDNAfuns (version 0.1.0)

tidy2phyloseq: Convert a tidy ASV table to a phyloseq object

Description

This function converts a tidy ASV table, along with optional taxonomy and metadata, into a `phyloseq` object.

Extracts ASV counts, taxonomy, and metadata from a `phyloseq` object into tidy data frames.

Usage

tidy2phyloseq(
  ASV_table,
  OTU_taxonomy = NULL,
  metadata = NULL,
  Taxa = "sseqid",
  Sample = "sample_name",
  Reads = "nr",
  tree = NULL
)

phyloseq2tidy(phylo_obj, Taxa = "sseqid", Sample = "sample_name", Reads = "nr")

Value

A `phyloseq` object combining OTU table, taxonomy, metadata, and optionally a tree.

A list with three tibbles:

ASV_table

Long-format tibble of counts: Sample, Taxa, Reads.

taxonomy

Taxonomy table as tibble (NULL if none in phyloseq).

metadata

Sample metadata as tibble (NULL if none in phyloseq).

Arguments

ASV_table

A tidy data.frame/tibble of ASV counts.

OTU_taxonomy

A data.frame with OTU taxonomy. Optional.

metadata

A data.frame with sample metadata. Optional.

Taxa

Column name for OTU IDs in the output (default: "sseqid").

Sample

Column name for sample IDs in the output (default: "sample_name").

Reads

Column name for read counts in the output (default: "nr").

tree

A phylogenetic tree of class `phylo`. Optional.

phylo_obj

A phyloseq object.

Examples

Run this code
data("ASV_table")
data("metadata")
data("OTU_taxonomy")
ps <- tidy2phyloseq(ASV_table = ASV_table,
                    OTU_taxonomy = OTU_taxonomy,
                    metadata = metadata,
                    Taxa = "Hash",
                    Reads = "nReads")


data("ps")
tidy_list <- phyloseq2tidy(ps)


Run the code above in your browser using DataLab