% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rarefy.r
\name{suggest_inflate_depths}
\alias{suggest_inflate_depths}
\title{Suggest Inflation Depths}
\usage{
suggest_inflate_depths(biom, adjust = 1.5)
}
\arguments{
\item{biom}{An \link[=rbiom_objects]{rbiom object}, or any value accepted by \code{\link[=as_rbiom]{as_rbiom()}}.}

\item{adjust}{Numeric. Bandwidth adjustment for the kernel density
estimation. Default: \code{1.5}.}
}
\value{
A named integer vector of recommended depths for each sample.
}
\description{
Estimates the optimal sequencing depth for each sample in a matrix by
leveraging the global abundance distribution structure.
}
\section{The Singleton Peak Heuristic}{


When \code{depth = NULL}, \code{\link[=biom_inflate]{biom_inflate()}} calls this function to estimate the original
sequencing depth for each sample. The underlying assumption is that in
typical microbiome datasets, the most frequent count value (the mode of the
abundance distribution) is 1 (a singleton).

The algorithm works as follows:
\enumerate{
\item \strong{Log-Transformation:} Non-zero relative abundances are log10-transformed.
\item \strong{Global Consensus:} To overcome sparsity in individual samples, distributions
are centered by their medians and aggregated across all samples.
\item \strong{Peak Detection:} Kernel Density Estimation (KDE) is used to identify the
peak (mode) of this aggregated distribution.
\item \strong{Scaling:} A scaling factor is calculated for each sample that shifts
this peak to correspond to an integer count of 1.
}

This approach effectively "shoehorns" relative abundance data into integer
formats required by diversity metrics (like rarefaction or Chao1) by
maximizing the number of singletons in the resulting matrix.
}

\examples{
    library(rbiom)
    
    depths <- suggest_inflate_depths(hmp50)
    head(depths)

}
\seealso{
\code{\link[=biom_inflate]{biom_inflate()}} which uses this heuristic when \code{depth = NULL}.
}
