% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/estimates_dynamics.R
\name{estimates_dynamics}
\alias{estimates_dynamics}
\title{Extracts parameter estimates from numeric fit of Bayesian model of dynamics}
\usage{
estimates_dynamics(
  data,
  assay = "scaled_log",
  kegg = "KEGG",
  condition = "condition",
  time = "time",
  metabolite = "metabolite",
  fits = metadata(data)[["dynamic_fits"]],
  iter = 2000,
  warmup = iter/4,
  chains = 4,
  samples = 1
)
}
\arguments{
\item{data}{data frame or colData of a \link[SummarizedExperiment]{SummarizedExperiment}  used used to fit dynamics model, must contain a column specifying KEGG IDs, column named "condition" specifiyng the experimental condition and a column named "time" specifying the timepoints.
If it is a SummarizedExperiment object the dynamic fits must be stores in metadata(data)
under "dynamic_fits"}

\item{assay}{of the SummarizedExperiment object that was used to fit the dynamics
model}

\item{kegg}{column in "data" that contains the KEGG IDs or other identifier of metabolites}

\item{condition}{name of column in dataframe data that specifies the experimental condition}

\item{time}{column in "data" that contains the time point identifiers}

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

\item{fits}{list of model fits for which estimates should be extracted}

\item{iter}{how many iterations were used to fit the dynamics model}

\item{warmup}{how many warm-up iterations were used to fit the dynamics model}

\item{chains}{how many chains were used to fit the dynamics model}

\item{samples}{how many posterior samples should be drawn (p.e. for check of clustering precision)}
}
\value{
a list of dataframes (one per experimental condition) that contains
the estimates at the timepoints and samples from the posterior
(number as specified in samples), delta_mu specifies the difference between
time point specified in column "time.ID" and subsequent time point (delta_mu
in row time.ID=1: mu(time point 2)- mu(time point 1)) if number of time points
in dataset is >1
If data is a summarizedExperiment object the estimates are stored in
metadata(data) under "estimates_dynamics"
}
\description{
Extracts the mean concentrations (mu) at every time point from the dynamics model fit, the 95\% highest density interval (HDI), the estimated standard deviation of metabolite concentrations at every time point (sigma), and the pooled standard deviation of every metabolite over all timepoints (lambda).
Additionally samples from the posterior of mu can be drawn. This can be helpful if p.e. one wants to estimate the clustering precision. Lambda can be used for clustering algorithms such as VSClust that also take the variance into account.
}
\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
)
data <- estimates_dynamics(
  data = data, iter = 2000,
  chains = 1, condition = "condition"
)

}
\seealso{
Fit the dynamic model \code{\link[=fit_dynamics_model]{fit_dynamics_model()}}.
Diagnostics of the dynamic model \code{\link[=diagnostics_dynamics]{diagnostics_dynamics()}}
Visualization of estimates with \code{\link[=plot_estimates]{plot_estimates()}}
}
