% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update_otu_table.R
\name{update_otu_table}
\alias{update_otu_table}
\title{Add a rarefied otu_table to a phyloseq object}
\usage{
update_otu_table(physeq_obj, rarefied_otus, iteration = NULL)
}
\arguments{
\item{physeq_obj}{A \code{phyloseq} object in which you want to add the rarefied
OTU/ASV table.}

\item{rarefied_otus}{A data frame, list of data frames, or 3D array output from
\code{multi_rarefy()} containing the rarefied OTU/ASV tables.}

\item{iteration}{Integer specifying which iteration to extract from a list
or array. Required when \code{rarefied_otus} is a list or array. Ignored when
\code{rarefied_otus} is a data frame.}
}
\value{
A \code{phyloseq} object.
}
\description{
This function updates a \code{phyloseq} object by replacing its OTU/ASV table
with a rarefied version produced by \code{multi_rarefy()}. The rarefied table can
be a data frame, a list of data frames (\code{.as = "list"}), or a 3D array
(\code{.as = "array"}). When providing a list or array, specify which iteration
to use via the \code{iteration} parameter.
}
\examples{
library(phyloseq)
library(BRCore)
data(GlobalPatterns, package = "phyloseq")

# List output
otu_list <-
  multi_rarefy(
    physeq_obj = GlobalPatterns,
    depth_level = 200,
    num_iter = 3,
    .as = "list",
    set_seed = 123
  )

# Extract iteration 2
rarefied_gp <- update_otu_table(GlobalPatterns, otu_list, iteration = 2)

# Array output
otu_array <-
  multi_rarefy(
    physeq_obj = GlobalPatterns,
    depth_level = 200,
    num_iter = 3,
    .as = "array",
    set_seed = 123
  )

# Extract iteration 1
rarefied_gp2 <- update_otu_table(GlobalPatterns, otu_array, iteration = 1)

}
\seealso{
\code{\link[=multi_rarefy]{multi_rarefy()}}
}
