Skip to contents

Estimates observation-level precision weights from a mean-variance trend (vooma) and fits a weighted least squares model via lmFit. For proteomics data that is already log2-transformed.

Usage

build_model_limma_voom(
  lfqdata,
  strategy,
  model_name = strategy$model_name,
  span = 0.5,
  plot = FALSE
)

Arguments

lfqdata

an LFQData object (aggregated to protein level)

strategy

output of strategy_limma

model_name

name of model (default from strategy)

span

lowess smoother span for mean-variance trend (default 0.5)

plot

logical; if TRUE, plot the mean-variance trend

Value

a ModelLimma object

Details

The weights follow vooma (Law et al. 2014, doi:10.1186/gb-2014-15-2-r29 ):

  1. a preliminary lmFit() gives the residual standard deviation \(s_g\) of each protein;

  2. a lowess trend \(f\) (span span) of \(\sqrt{s_g}\) against the mean log2 intensity is evaluated at each fitted value \(\hat{y}_{gj}\);

  3. since \(f^4\) estimates the variance, the precision weight is \(w_{gj} = 1 / f(\hat{y}_{gj})^4\), and the final fit is weighted least squares followed by eBayes().

The data are already on the log2 scale, so there is no library-size term. With weights = NULL and complete data the fit equals limma::vooma() followed by limma::lmFit(). In designs with group factors only, all samples of a group share one weight: fold changes equal those of unweighted limma, while standard errors and p-values change.

External weights \(n_{gj}\) (strategy$weights, e.g. the nr_children column, the number of peptides per protein and sample) go beyond vooma(), which takes none. If a protein intensity averages \(n_{gj}\) peptide measurements with independent errors, its variance is \(\sigma^2_g / n_{gj}\). The preliminary fit therefore uses \(n_{gj}\) as weights, so the trend is estimated from weighted residuals, and the final fit uses \(n_{gj} w_{gj}\). Only the relative size of \(n_{gj}\) matters: a constant weight gives the same result as none. deqms_voom uses no external weights, because DEqMS already moderates by the peptide count.

See also

Other modelling: AnovaExtractor, Contrasts, ContrastsComparison, ContrastsDEqMSFacade, ContrastsDEqMSVoomFacade, ContrastsFacadeBase, ContrastsFirth, ContrastsFirthFacade, ContrastsHurdleFacade, ContrastsHurdleNestedFacade, ContrastsLMFacade, ContrastsLMImputeFacade, ContrastsLimma, ContrastsLimmaFacade, ContrastsLimmaImputeFacade, ContrastsLimmaVoomFacade, ContrastsLimmaVoomImputeFacade, ContrastsLimpaFacade, ContrastsLimpaNestedFacade, ContrastsLmerNestedFacade, ContrastsModerated, ContrastsModeratedDEqMS, ContrastsPlotter, ContrastsRLMFacade, ContrastsROPECA, ContrastsROPECANestedFacade, ContrastsROPECAV2, ContrastsROPECAV2NestedFacade, ContrastsRfitFacade, ContrastsRfitImputeFacade, ContrastsTable, INTERNAL_FUNCTIONS_BY_FAMILY, Model, ModelFirth, ModelLimma, StrategyLM, StrategyLimma, StrategyLimpa, StrategyLmer, StrategyLogistf, StrategyRLM, StrategyRfit, build_contrast_analysis(), build_model(), build_model_glm_protein(), build_model_impute(), build_model_limma(), build_model_limma_impute(), build_model_limma_voom_impute(), build_model_limpa(), compute_borrowed_variance(), compute_borrowed_variance_limma(), df.residual.rfit_prolfqua(), group_label(), impute_from_model(), impute_refit_singular(), list_facades(), lookup_facade(), lr_test(), merge_contrasts_results(), new_imputed_model(), nobs.rfit_prolfqua(), pivot_model_contrasts_to_wide(), prolfqua_analysis_methods, register_facade(), sigma.rfit_prolfqua(), strategy_limma(), strategy_limpa(), strategy_logistf(), vcov.rfit_prolfqua()

Examples


istar <- sim_lfq_data_protein_config(n_proteins = 50)
#> `protein_Id`: columns `proteinID`, `idtype2` united with separator '~'.
#> creating sampleName from file_name column
#> setup_analysis: dropped 5 unconfigured columns: average_prot_abundance, sd, mean, N, Replicate.
#> setup_analysis: added 82 rows with NA response for feature and sample combinations absent from the input.
lProt <- LFQData$new(istar$data, istar$config)
lProt$rename_response("transformedIntensity")

strat <- strategy_limma("transformedIntensity ~ group_")
mod <- build_model_limma_voom(lProt, strat)
#> fit (limma): 1 singular fits (e.g. VUnZ6o~1614): coefficients not estimable (Partial NA coefficients)
#> fit (limma): 82 missing responses dropped (e.g. 0EfVhX~7161, 0m5WN4~3543, 7QuTub~5556, 7cbcrd~0495, 9VUkAq~8655, ...): NA response (missing observation) left out of the fit
#> See $provenance().
mod$get_coefficients()
#> # A tibble: 150 × 6
#>    protein_Id  factor      Estimate Std..Error t.value  Pr...t..
#>    <chr>       <chr>          <dbl>      <dbl>   <dbl>     <dbl>
#>  1 0EfVhX~7161 (Intercept)     20.3      0.467    43.5 3.22e-147
#>  2 0m5WN4~3543 (Intercept)     20.5      0.453    45.4 4.75e-153
#>  3 76k03k~9735 (Intercept)     20.2      0.473    42.6 1.16e-144
#>  4 7QuTub~5556 (Intercept)     22.8      0.517    44.1 3.26e-149
#>  5 7cbcrd~0495 (Intercept)     17.2      0.671    25.6 1.25e- 83
#>  6 7soopj~3451 (Intercept)     26.3      0.491    53.7 1.92e-176
#>  7 9VUkAq~8655 (Intercept)     22.2      0.500    44.4 3.10e-150
#>  8 At886V~0359 (Intercept)     17.1      0.667    25.7 4.81e- 84
#>  9 BEJI92~5483 (Intercept)     15.8      0.371    42.6 1.28e-144
#> 10 CGzoYe~1248 (Intercept)     18.2      0.539    33.9 2.55e-115
#> # ℹ 140 more rows