View source: R/predict_paramedic.R
predict_paramedic | R Documentation |
Predict concentrations (and efficiencies, if applicable), absolute abundances, and relative abundances based on the posterior distributions from a previously fitted model resulting from a call to run_paramedic
.
predict_paramedic(
W,
V,
X = V[, 1, drop = FALSE],
beta_0,
beta_1 = array(0, dim = c(nrow(beta_0), ncol(X) - 1, ncol(W) - 1)),
Sigma,
sigma_e = matrix(0, nrow = nrow(Sigma), ncol = ncol(Sigma)),
phi = matrix(1, nrow = nrow(Sigma), ncol = nrow(X)),
k = 0,
n_iter = 10500,
n_burnin = 10000,
n_chains = 4,
stan_seed = 4747,
alpha_sigma = 2,
kappa_sigma = 1,
alpha_phi = 0,
beta_phi = 0,
sigma_xi = 1,
...
)
W |
The new relative abundance data, e.g., from broad range 16S sequencing with "universal" primers. Expects data (e.g., matrix, data.frame, tibble) with sample identifiers in the first column. Sample identifiers must be the same between W and V, and the column must have the same name in W and V. |
V |
The new absolute abundance data, e.g., from taxon-specific absolute primers. Expects data (e.g., matrix, data.frame, tibble) with sample identifiers in the first column. Sample identifiers must be the same between W and V, and the column must have the same name in W and V. |
X |
The new covariate data. Expects data (e.g., matrix, data.frame, tibble) with sample identifiers in the first column. Sample identifiers must be the same between W, V, and X, and the column must have the same name in W, V, and X. If X only consists of the subject identifiers, then no covariates are used. |
beta_0 |
The posterior distribution on |
beta_1 |
The posterior distribution on |
Sigma |
The posterior distribution on |
sigma_e |
The posterior distribution on |
phi |
The posterior distribution on |
k |
the number of batches that the relative abundance data W were analyzed in. If k = 0 (the default), then batch effects are not considered. (currently not used) |
n_iter |
The total number of iterations per chain to be run by the Stan algorithm. Defaults to 10500. |
n_burnin |
The total number of warmups per chain to be run by the Stan algorithm. Defaults to 10000. |
n_chains |
The total number of chains to be run by the Stan algorithm. Defaults to 4. |
stan_seed |
The random number seed to initialize. |
alpha_sigma |
Hyperparameter specifying the shape parameter of the prior distribution on |
kappa_sigma |
Hyperparameter specifying the scale parameter of the prior distribution on |
alpha_phi |
Hyperparameter specifying the shape parameter of the prior distribution on |
beta_phi |
Hyperparameter specifying the rate parameter of the prior distribution on |
sigma_xi |
Hyperparameters specifying the variance of efficiencies over batches. Only used if |
... |
other arguments to pass to |
Using the posterior distributions from a call to run_paramedic
, generate predicted values.
An object of class stanfit
.
stan
and sampling
for specific usage of the stan
and sampling
functions; run_paramedic
for usage of the run_paramedic
function.
# load the package, read in example data
library("paramedic")
data(example_16S_data)
data(example_qPCR_data)
# generate a train/test split
set.seed(1234)
folds <- sample(1:2, size = nrow(example_16S_data), replace = TRUE)
# run paramedic (with an extremely small number of iterations, for illustration only)
# on only the first 10 taxa, and on a subset of the data
mod <- run_paramedic(W = example_16S_data[folds == 1, 1:10],
V = example_qPCR_data[folds == 1, ], n_iter = 30, n_burnin = 25,
n_chains = 1, stan_seed = 4747)
# generate predictions on test data
ext_mod <- rstan::extract(mod)
beta0_post <- ext_mod$beta_0
sigma_post <- ext_mod$Sigma
sigmae_post <- ext_mod$sigma_e
pred_mod <- predict_paramedic(W = example_16S_data[folds == 2, 1:10],
V = example_qPCR_data[folds == 2, ], n_iter = 75, n_burnin = 25,
beta_0 = beta0_post, Sigma = sigma_post, sigma_e = sigmae_post,
n_chains = 1, stan_seed = 1234)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.