run_pipeline: Run multiple imputation and limma

View source: R/run_pipeline.R

run_pipelineR Documentation

Run multiple imputation and limma

Description

This function is an efficient wrapper that fits the needed gamma regressions, performs multiple imputation and testing with limma (see limmaUsersGuide). It is an efficient wrapper that generates need inputs for imputation and running run_limma_and_lfc with the possibility of using multidplyr-package to paralellize the computation. It also calls produces the mean-variance trends if plot_trend is TRUE.

Usage

run_pipeline(
  data,
  design,
  contrast_matrix,
  imputations,
  workers = 1,
  id_col = "id",
  .robust = TRUE,
  plot_trend = FALSE
)

Arguments

data

The data to run the pipeline on, missing values should have NA values.

design

A design matrix as produced by model.matrix.

contrast_matrix

A contrast matrix of comparisons to perfrom see makeContrasts for details.

imputations

Number of imputations to perfrome.

workers

Number of workers (processes) to run the pipeline with. Any value >1 will run the pipeline with parallel computing using the multidplyr-package.

id_col

A character for the name of the column containing the name of the features in data (e.g., peptides, proteins, etc.).

plot_trend

Should the mean-variance trend with the gamma regression be plotted?

Value

A tibble with each imputation as a row. The first column contains the imputation number, the second contains the imputed data, and the last column contains the results produced by run_limma_and_lfc.

Examples

# Generate a design matrix for the data
design <- model.matrix(~ 0 + factor(rep(1:2, each = 3)))

# Set correct colnames, this is important for fit_gamma_*
colnames(design) <- paste0("ng", c(50, 100))

# Generate the contrast matrix
contrast <- limma::makeContrasts(
  contrasts = "ng100-ng50",
  levels = design
)

# Normalize and log-transform the data
yeast <- psrn(yeast, "identifier")
## Not run: 
results <- run_pipeline(yeast, design, contrast, 1000, 5, "identifier", TRUE)

## End(Not run)

PhilipBerg/PaiR documentation built on March 18, 2022, noon