% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/multi_rarefy.R
\name{multi_rarefy}
\alias{multi_rarefy}
\title{Run rarefaction for microbiome count tables}
\usage{
multi_rarefy(
  physeq_obj,
  depth_level,
  num_iter = 100,
  .as = "list",
  set_seed = NULL
)
}
\arguments{
\item{physeq_obj}{A \code{phyloseq} object containing an OTU/ASV table.}

\item{depth_level}{An integer specifying the sequencing depth (number of
OTUs/ASVs) to which samples should be rarefied.}

\item{num_iter}{An integer specifying the number of iterations to perform
for rarefaction.}

\item{.as}{A character string indicating whether to return the results as a
3D array or as a list of data frames. If \code{"array"}, returns a 3D array with
dimensions (samples x taxa x iterations). If \code{"list"}, returns a list of
data frames, one for each iteration, with samples as rows and taxa as
columns. (default = "list")}

\item{set_seed}{An optional integer to set the random seed for
reproducibility (default = NULL).}
}
\value{
A data frame with taxa as rows and samples as columns. The values
represent the average sequence counts calculated across all iterations.
Samples with less than \code{depth_level} sequences are discarded.
}
\description{
This function performs rarefaction on a \code{phyloseq} object by randomly
sub-sampling OTUs/ASVs within samples without replacement for a number of
iterations specified by the user. Samples with fewer OTUs/ASVs than the
specified \code{depth_level} are discarded.
}
\examples{
library(BRCore)


# Example rarefaction (single iteration, single core to keep examples fast)
otu_table_rare <- multi_rarefy(
  physeq_obj = bcse,
  depth_level = 1000,
  num_iter = 10,
  .as = "list",
  set_seed = 7642
)

rowSums(otu_table_rare[[1]])


}
\seealso{
\code{\link[=update_otu_table]{update_otu_table()}} for updating the OTU table in a \code{phyloseq}
object and \code{\link[vegan:rarefy]{vegan::rrarefy()}} for the underlying rarefaction method used in
this function.
}
