% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fit_neutral_model.R
\name{fit_neutral_model}
\alias{fit_neutral_model}
\title{Fit a Neutral Model to Microbial Community Data}
\usage{
fit_neutral_model(otu_table, core_set, abundance_occupancy)
}
\arguments{
\item{otu_table}{A community count matrix (or OTU table) with samples as
rows and OTU/ASVs as columns..}

\item{core_set}{Character vector of core OTU/ASVs IDs (must match column
names of \code{otu_table}).}

\item{abundance_occupancy}{data.frame (or tibble) with OTU/ASVs names,
occupancy (\code{otu_occ}),
and mean relative abundance (\code{otu_rel}) as generated by
\link[=identify_core]{identify_core()}.}
}
\value{
A list with:
\itemize{
\item \code{goodness_of_fit}: one-row tibble of summary stats (plus \code{above.pred},
\code{below.pred}) - \code{model_prediction}: tibble with \code{abundance_occupancy}
joined to per-taxon predictions
}
}
\description{
The function fits the neutral distribution model developed by Sloan et al.
(2006), and implemented in R by Burns et al. (2015), to an OTU/ASV table and
returns several goodness of fit statistics alongside a data.frame
with predicted occurrence frequencies for each OTU/ASV based on their
abundance in the metacommunity for plotting the abundance-occupancy
distribution. In addition, this function identified core and not-core
OTU/ASVs that are neutral (i.e. stochastically or randomly distributed)
above (i.e. interpreted as deterministically or predictably selected) and
below (i.e. interpreted as dispersally limited) the model predictions.
}
\examples{
library(BRCore)
data("switchgrass_core", package = "BRCore")

switchgrass_core_fit <- fit_neutral_model(
  otu_table = switchgrass_core$otu_table,
  core_set = switchgrass_core$increase_core,
  abundance_occupancy = switchgrass_core$abundance_occupancy
)

str(switchgrass_core_fit)
switchgrass_core_fit$goodness_of_fit
switchgrass_core_fit$model_prediction |>
head()

}
\references{
Sloan, W. T., Lunn, M., Woodcock, S., Head, I. M., Nee, S., & Curtis, T. P.
(2006). Quantifying the roles of immigration and chance in shaping
prokaryote community structure. Environmental Microbiology, 8(4), 732–740.
\url{doi:10.1111/j.1462-2920.2005.00956.x}

Burns, A. R., Stephens, W. Z., Stagaman, K., Wong, S., Rawls, J. F.,
Guillemin, K., & Bohannan, B. J. M. (2016). Contribution of neutral
processes to the assembly of gut microbial communities in the zebrafish over
host development. The ISME Journal, 10(3), 655–664.
\url{doi:10.1038/ismej.2015.142}

Shade A, Stopnisek N (2019) Abundance-occupancy distributions to prioritize
plant core microbiome membership. Current Opinion in Microbiology, 49:50-58
\url{doi:10.1016/j.mib.2019.09.008}
}
\seealso{
\code{\link[=plot_neutral_model]{plot_neutral_model()}}
}
