Allows for the computation of differential analyses using prolfqua (J Proteome Research, 2023). Includes means, Fold Changes, and p-values.

# S3 method for class 'analyses.prolfqua'
diff(
  DEprot.object,
  contrast.list,
  replicate.column = NULL,
  linear.FC.th = 2,
  linear.FC.unresp.range = c(1/1.1, 1.1),
  FDR.th = 0.05,
  strategy = "lm",
  moderate.variance = FALSE,
  robust.scaling = TRUE,
  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.

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 by the strategies that include the replicate in the model ("lmer" and "logistf"). 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).

FDR.th

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

strategy

String indicating the method that prolfqua should use to fit the model. One among: "lm" (linear model, default), "lmer" (linear mixed-effects model), "logistf" (Firth's bias-reduced logistic regression), "rlm" (robust lm). Default: "lm" (linear model).

moderate.variance

String indicating whether the variance should be moderated in the evaluation of the contrast. Default: FALSE.

robust.scaling

Logical value indicating whether the robust scaling of prolfqua (median centering and MAD scaling of each sample) should be applied to the intensities before the fit. Default: TRUE.

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 standard error of the log2(FoldChange). When moderate.variance = FALSE, lfcSE is the standard error of the contrast estimate computed by prolfqua; when moderate.variance = TRUE it is the moderated standard error, consistent with the moderated t-statistic reported in the statistic column. In both cases statistic = log2(FoldChange) / lfcSE. Note that, when imputed counts are used, the imputation compresses the variance and sd, sem and lfcSE are consequently under-estimated.

Before fitting the model, prolfqua re-normalizes the intensities of each sample: the median of the sample is subtracted and the values are divided by the median absolute deviation (MAD) of the sample, expressed relatively to the average MAD of the samples. The dispersion of the samples is equalized in this way, but the log2(FoldChange) is estimated on this rescaled space while basemean.log2, log2.mean.<group>, sd.<group> and sem.<group> are computed directly on the counts stored in the object: the difference between the two group means is therefore close to the reported fold change, without coinciding with it exactly. On counts that have already been normalized within DEprot this is a second normalization that has not been asked for, and it can be skipped with robust.scaling = FALSE. The effect is stronger on imputed counts, since the imputation shrinks the MAD of a sample proportionally to the number of values that were replaced, which makes the rescaling follow the pattern of the missing values.

The scaling factor applied to each sample is stored, for every contrast, in the scaling.factors element of prolfqua.out. A factor of 1 indicates a sample whose dispersion corresponds to the average of the samples of the contrast, while values above or below 1 indicate a sample whose fold changes are respectively compressed or expanded by the scaling. A warning is raised when the factors deviate more than 15% from unity.

Author

Sebastian Gregoricchio

Examples

dpo <- diff.analyses.prolfqua(DEprot.object = DEprot::test.toolbox$dpo.imp,
                              contrast.list = list(c("condition", "FBS", "6h.DMSO"),
                                                   c("condition", "6h.10nM.E2", "6h.DMSO")),
                              strategy = "lm",
                              linear.FC.th = 1.2)


# Counts already normalized: the re-normalization of prolfqua can be skipped
dpo <- diff.analyses.prolfqua(DEprot.object = DEprot::test.toolbox$dpo.norm,
                              contrast.list = list(c("condition", "FBS", "6h.DMSO")),
                              strategy = "lm",
                              robust.scaling = FALSE,
                              which.data = "normalized",
                              linear.FC.th = 1.2)
#> Warning: There was 1 warning in `dplyr::mutate()`.
#>  In argument: `linear_model = purrr::map(data, model_strategy$model_fun, pb =
#>   pb)`.
#>  In group 41: `protein_Id = "protein.47"`.
#> Caused by warning in `value[[3L]]()`:
#> ! WARN :Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]): contrasts can be applied only to factors with 2 or more levels
#> Warning: Removed 1 row containing non-finite outside the scale range
#> (`stat_density2d()`).