% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fit_dynamics_model.R
\name{fit_dynamics_model}
\alias{fit_dynamics_model}
\title{Fits dynamics model}
\usage{
fit_dynamics_model(
  data,
  metabolite = "metabolite",
  time = "time",
  condition = "condition",
  scaled_measurement = "m_scaled",
  assay = "scaled_log",
  chains = 4,
  cores = 4,
  adapt_delta = 0.95,
  max_treedepth = 10,
  iter = 2000,
  warmup = iter/4
)
}
\arguments{
\item{data}{concentration table with at least three replicate measurements per
metabolite containing the columns "metabolite",
"condition", and "m_scaled" by default or colData of a \link[SummarizedExperiment]{SummarizedExperiment} object}

\item{metabolite}{column of "data" that contains the metabolite names or IDs}

\item{time}{column of "time" that contains time as numeric, make sure your
time column is ordered from lowest to highest for the model to work}

\item{condition}{column of "data" that contains the experimental conditions}

\item{scaled_measurement}{column of "data" that contains the concentrations per cell,
centered and normalized per metabolite and experimental condition (mean=0, sd=1)}

\item{assay}{if input is a summarizedExperiment specify the assay that should
be used for input, colData has to hold the columns, "condition" and "metabolite",
rowData the timepoint specifications}

\item{chains}{how many Markov-Chains should be used for model fitting, use at
least two, default=4}

\item{cores}{how many cores should be used for model fitting; this
parallelizes the model fitting and therefore speeds it up; default=4}

\item{adapt_delta}{target average acceptance probability, can be adapted if
divergent transitions are reported, default is 0.95}

\item{max_treedepth}{can be adapted if model throws warnings about hitting
max_treedepth, warnings are mostly efficiency not validity concerns and
treedepth can be raised, default=10}

\item{iter}{how many iterations are run, increasing might help with effective
sample size being to low, default=2000}

\item{warmup}{how many iterations the model warms up for, increasing might
facilitate efficiency, must be at least 25\% of ITER, default=iter/4}
}
\value{
returns a list of model fits. One model fit named "condition" per
experimental condition. If input is a summarizedExperiment object the dynamic
fits are stored metadata(data) under "dynamic_fits"
}
\description{
Employs a hierarchical model that assumes a normal distribution of
standardized (mean=0, sd=1) log(cpc) (cpc = normalized metabolite abundance)
values for robust estimation of mean
concentrations over time of single metabolites at single experimental
conditions.
}
\examples{
data("longitudinalMetabolomics")
data <- longitudinalMetabolomics[, longitudinalMetabolomics$condition == "A" &
  longitudinalMetabolomics$metabolite == "ATP"]
data <- fit_dynamics_model(
  data = data,
  scaled_measurement = "m_scaled", assay = "scaled_log",
  max_treedepth = 14, adapt_delta = 0.95, iter = 2000, cores = 1, chains = 1
)
S4Vectors::metadata(data)[["dynamic_fits"]]

}
\seealso{
Example data set\link{longitudinalMetabolomics}.
Get model diagnostics \code{\link[=diagnostics_dynamics]{diagnostics_dynamics()}}
Get model estimates \code{\link[=estimates_dynamics]{estimates_dynamics()}}
}
