Mean-Variance_Gamma_Regressions: Functions for Fitting the Mean-Variance Gamma Regression...

Mean-Variance_Gamma_RegressionsR Documentation

Functions for Fitting the Mean-Variance Gamma Regression Models

Description

fit_gamma_regressions is a wrapper function that calls both fit_gamma_imputation and fit_gamma_weights. It returns a list containing the models for imputation in $imputation and the weights in $weights. fit_gamma_imputation returns a list named according to the different conditions and fit_gamma_weights returns a glm object containing the gamma regression for the mean-variance trend.

Usage

fit_gamma_regressions(data, design, id_col = "id")

fit_gamma_imputation(data, design, id_col = "id")

fit_gamma_weights(data, design, id_col = "id")

Arguments

data

a data.frame to generate the mean-variance trends for. It should contain columns with conditions named as the column names in design (presumably with some suffix).

design

a design or model matrix as produced by model.matrix with column names corresponding to the different conditions.

id_col

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

Value

fit_gamma_imputation returns a named list where the names corresponds to the conditions. Each index contains a glm object with the gamma regression for the mean-variance trend. fit_gamma_weights returns a glm object with the gamma regression for the precision weights. fit_gamma_regressions returns a list with the results from fit_gamma_imputation in $imputation and the results from fit_gamma_weights in $weights.

Functions

  • fit_gamma_regressions: Wrapper function that runs both fit_gamma_imputation and fit_gamma_weights

  • fit_gamma_imputation: Function that generates per condition mean-variance trends used in the imputation procedure. Each id in the id_col gets one mean and variance calculated for each condition. One model is then fitted per condition.

  • fit_gamma_weights: Function to produce the mean-variance trend used to calculate the precision weights used in lmFit. Each id in the id_col gets one mean and one variance across all conditions and one model is then fitted for all mean-variance pairs.

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))

# Normalize and log-transform the data
yeast <- psrn(yeast, "identifier")

# Fit all gamma regression models for the mean-variance trends
all_gamma_models <- fit_gamma_regressions(yeast, design, "identifier")

# Fit the gamma regression models for the mean-variance trend used in the
# imputation procedure
gamma_imputation_models <- fit_gamma_imputation(yeast, design, "identifier")

# Fit the gamma regression model for the mean-variance trend used for
# estimating the precision weights used in limma
gamma_weight_model <- fit_gamma_weights(yeast, design, "identifier")

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