test.protLMcontrast: Test a contrast

View source: R/testProtLMContrast.R

test.protLMcontrastR Documentation

Test a contrast

Description

This function can test a contrast based on a protLM object protLM and a contrast matrix L.

Usage

test.protLMcontrast(protLM, L, add.annotations = TRUE, simplify = TRUE,
  lfc = 0, anova = FALSE, anova.na.ignore = TRUE, type_dfs = "residual",
  custom_dfs = NULL, exp_unit = NULL, pars_between = NULL,
  lmerModFun = NULL, gradMethod = "simple", printProgress = FALSE,
  shiny = FALSE, message_extract = NULL, message_test = NULL)

Arguments

protLM

An object of class protLM.

L

A contrast matrix with the parameter levels as rows and a column for each contrast.

add.annotations

A logical indicating whether the annotations slot of the protLM object should be added as extra columns to each matrix in the returned list of matrices. Defaults to TRUE.

simplify

A logical indicating wheter, if there is only one contrast, a matrix should be returned instead of a list containing one matrix. Defaults to TRUE.

lfc

The minimum (log2) fold-change that is considered scientifically meaningful. Defaults to 0. Ignored when anova = TRUE.

anova

A logical indicating whether the contrasts should be tested simultaneously in one F-test (anova = TRUE) or as separate t-tests (anova = FALSE). Defaults to FALSE.

anova.na.ignore

A logical indicating whether contrasts that cannot be fitted due to missing observations should be ignored when calculating an F value (anova.na.ignore = TRUE) or NA should be returned when at least one contrast cannot be estimated (anova.na.ignore = FALSE). Defaults to TRUE. Ignored when anova = FALSE.

type_dfs

Either one of "residual", "between-within", "Satterthwaite", "exp_between" or "custom". This argument indicates how the degrees of freedom should be calculated. Defaults to "residual". More information is given under 'Details'.

custom_dfs

Only used if type_dfs="custom". A list of length equal to the number of models in protLM containing vectors of lenght ncol(L) (if anova = FALSE) representing the degrees of freedom that should be used for each contrast in L and each model in the protLM object. If anova = TRUE, each element of the list should contain a single numeric value representing the degrees of freedom to be used for the anova test. Defaults to NULL.

exp_unit

Only used if type_dfs="exp_between". The effect that in all models corresponds to the experimental unit.

pars_between

Only used if type_dfs="exp_between". Character vector indicating all parameters in the models that are between-treatment effects. If left to default (NULL), all parameters in the models will be asumed to be between-treatment effects (this is not adviced as the result will mostly be too conservative).

lmerModFun

Only used when satterthwaite=TRUE. lmerModFun indicates which deviance function should be used when calculating the Satterthwaite approximation for the degrees of freedom. The default (NULL) uses the lme4 mkLmerDevfun function to generate the deviance function. This parameter should only rarely, if ever, be changed.

gradMethod

Only used when satterthwaite=TRUE. One of "Richardson", "simple", or "complex" indicating the method to use for the gradient calculation by numerical approximation during the calculation of the Satterthwaite approximation for the degrees of freedom. Defaults to "simple".

printProgress

A logical indicating whether the R should print a message before calculating the contrasts for each accession. Defaults to FALSE.

shiny

A logical indicating whether this function is being used by a Shiny app. Setting this to TRUE only works when using this function in a Shiny app and allows for dynamic progress bars. Defaults to FALSE.

message_extract

Only used when printProgress=TRUE and shiny=TRUE. A single-element character vector: the message to be displayed to the user during the extraction of beta, vcov, df and sigma, or NULL to hide the current message (if any).

message_test

Only used when printProgress=TRUE and shiny=TRUE. A single-element character vector: the message to be displayed to the user during the testing of the contrasts, or NULL to hide the current message (if any).

Details

Calculating degrees of freedom (and hence p values) for mixed models with unbalanced designs is an unresolved issue in the field (see for example here https://stat.ethz.ch/pipermail/r-help/2006-May/094765.html and here https://stat.ethz.ch/pipermail/r-sig-mixed-models/2008q2/000904.html). We offer different approximations and leave it up to the user to select his/her preferred approach. "residual" calculates approximative degrees of freedom by subtracting the trace of the hat matrix from the number of observations. It is the default setting, but this approach might be somewhat too liberal. "Satterthwaite" calculates approximative degrees of freedom using Satterthwaite's approximation (Satterthwaite, 1946). This approximative approach is used in many applications but is rather slow to calculate and might lead to some missing values due difficulties in calculating the Hessian. "exp_between" calculates approximative degrees of freedom by defining on which level the treatments were executed and substracting all degrees of freedom lost due to between-treatement effects (pars_between) from the number of experimental units exp_unit. This allows to mimick the behaviour of type_dfs="between-within" for more complex designs. "custom" Allows the user to provide his/her own degrees of freedom for each contrast and each protein. Custom degrees of freedom should be entered in the custom_dfs field.

Value

A list of data frames, with each data frame in the list corresponding to a contrast in L. Each row of the data frame corresponds to a protein in the protLM object. The estimate column contains the size estimate of the contrast, the se column contains the estimated standard error on the contrast, the Tval column contains the T-value corresponding to the contrast and the pval column holds the p-value corresponding to the contrast. If simplify=TRUE and the protLM object contains only one element, the data frame is not present in a list.


statOmics/MSqRob documentation built on Dec. 8, 2022, 6 a.m.