Allows for the computation of differential analyses using limma. Includes means, Fold Changes, and p-values.

# S3 method for class 'analyses.limma'
diff(
  DEprot.object,
  contrast.list,
  include.rep.model = FALSE,
  replicate.column = NULL,
  linear.FC.th = 2,
  linear.FC.unresp.range = c(1/1.1, 1.1),
  padj.th = 0.05,
  padj.method = "BH",
  fitting.method = "ls",
  up.color = "indianred",
  down.color = "steelblue",
  unresponsive.color = "purple",
  null.color = "gray",
  which.data = "imputed",
  overwrite.analyses = FALSE
)

Arguments

DEprot.object

An object of class DEprot.

contrast.list

List of 3-elements vectors indicating (in order): metadata_column, variable_1, variable_2.

include.rep.model

Logical value indicating whether the model should include the replicate information. Requires a 'replicate.column'. Default: FALSE.

replicate.column

String indicating the name of a column from the metadata table in which are stored the replicate IDs. This column is required only if include.rep.model = TRUE. Default: NULL.

linear.FC.th

Number indicating the (absolute) fold change threshold (linear scale) to use to define differential proteins. Default: 2.

linear.FC.unresp.range

A numeric 2-elements vector indicating the range (linear scale) used to define the unresponsive fold changes. Default: c(1/1.1, 1.1).

padj.th

Numeric value indicating the p.adjusted threshold to apply to the differential analyses. Default: 0.05.

padj.method

String indicating the method to use to correct the p-values. One among: "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none", "fdrtool". Default: BH.

fitting.method

String indicating the method that limma should use to fit the model. Options: "ls" for least squares or "robust" for robust regression. The robust regression cannot be combined with include.rep.model = TRUE. Default: "ls" (least squares).

up.color

String indicating the color to use for up-regulated proteins in the plots. Default: "indianred".

down.color

String indicating the color to use for up-regulated proteins in the plots. Default: "steelblue".

unresponsive.color

String indicating the color to use for unresponsive proteins in the plots. Default: "purple".

null.color

String indicating the color to use for null proteins in the plots. Default: "gray".

which.data

String indicating which type of counts should be used. One among: 'raw', 'normalized', 'norm', 'randomized', 'random', 'imputed', 'imp'. Default: "imputed".

overwrite.analyses

Logical value to indicate whether overwrite analyses already generated. Default: FALSE.

Value

An object of class DEprot.analyses

Details

The results table reports, for each group, the standard deviation (sd.<group>) and the standard error of the mean (sem.<group>) of the log2 expression values, together with lfcSE, the moderated (posterior) standard error of the contrast coefficient estimated by limma (stdev.unscaled * sqrt(s2.post)). This is the denominator of the moderated t-statistic reported in the statistic column and it is the direct equivalent of the lfcSE column returned by DESeq2::results(). The log2(FoldChange) column is the contrast coefficient estimated by limma, so that statistic = log2(FoldChange)/lfcSE holds in every case. For a least-squares fit of a ~ 0 + group design the coefficient corresponds exactly to the difference between the group means reported in the log2.mean.<group> columns; when include.rep.model = TRUE the fit becomes a generalized least squares in which the samples are weighted through the consensus correlation between replicates, and the same is true of fitting.method = "robust": in those cases the coefficient stays close to the difference of the means without coinciding with it. Note that, when imputed counts are used, the imputation compresses the variance and sd, sem and lfcSE are consequently under-estimated.

When set to "fdrtool", the moderated t-statistics returned by limma are passed to fdrtool::fdrtool (as normal deviates, statistic = "normal"), which estimates the proportion of null features and an empirical null: the resulting tail-area-based q-values are stored in the padj column, while the local false discovery rate (lfdr) is appended as an extra column at the end of the results table. If fewer than 200 proteins with a finite statistic are available for a contrast, or the fit fails, a Benjamini-Hochberg correction is applied for that contrast (a warning is raised) and no lfdr column is returned.

Author

Sebastian Gregoricchio

Examples

# Basic differential analyses including replicate model
dpo <- diff.analyses.limma(DEprot.object = DEprot::test.toolbox$dpo.imp,
                           contrast.list = list(c("condition", "FBS", "6h.DMSO"),
                                                c("condition", "6h.10nM.E2", "6h.DMSO")),
                           linear.FC.th = 1.5)


# Differential analyses including replicate model
dpo <- diff.analyses.limma(DEprot.object = DEprot::test.toolbox$dpo.imp,
                           contrast.list = list(c("condition", "FBS", "6h.DMSO"),
                                                c("condition", "6h.10nM.E2", "6h.DMSO")),
                           include.rep.model = TRUE,
                           replicate.column = "replicate",
                           linear.FC.th = 1.5)