Build limma model with LOD imputation for failed proteins
Source:R/ContrastsLimma.R
build_model_limma_impute.RdAnalogous to build_model_impute but for limma's matrix-based
pipeline. Fits all proteins with lmFit, identifies
proteins with NA coefficients (typically from entire missing groups), imputes
their missing values with the limit of detection (LOD), refits, and replaces
the variance with a borrowed estimate from successful proteins.
Arguments
- lfqdata
an
LFQDataobject (aggregated to protein level)- strategy
output of
strategy_limma- model_name
name of model (default: strategy name + "Imputed")
- lod
numeric limit of detection; if NULL, auto-computed from data via
MissingHelpers- df_method
how to set degrees of freedom for imputed proteins:
"observed"(default) usesmax(n_observed - p, 1)wheren_observedcounts only non-missing values;"borrowed"uses the median df from successful fits
Value
a ModelLimma object with a hybrid fit
Details
The LOD imputation gives plausible coefficients (fold change direction), while the borrowed sigma and corrected degrees of freedom ensure that inference is not artificially precise from the constant imputation.
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_voom(),
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, weight_missing = 0.5)
#> `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 137 rows with NA response for feature and sample combinations absent from the input.
lfqdata <- LFQData$new(istar$data, istar$config)
lfqdata$rename_response("transformedIntensity")
strat <- strategy_limma("transformedIntensity ~ group_")
mod <- build_model_limma_impute(lfqdata, strat)
#> fit (limmaImputed): 2 refit at the limit of detection (e.g. 7cbcrd~0495, nKkahQ~2435): fit failed, singular or missing a group; missing responses imputed at the LOD
#> fit (limmaImputed): 118 missing responses dropped (e.g. 0EfVhX~7161, 0m5WN4~3543, 7QuTub~5556, 9VUkAq~8655, At886V~0359, ...): NA response (missing observation) left out of the fit
#> See $provenance().
mod$get_coefficients()
#> # A tibble: 147 × 6
#> protein_Id factor Estimate Std..Error t.value Pr...t..
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 0EfVhX~7161 (Intercept) 20.6 0.570 36.1 1.22e-112
#> 2 0m5WN4~3543 (Intercept) 20.8 0.570 36.6 6.27e-114
#> 3 76k03k~9735 (Intercept) 20.2 0.493 40.9 3.48e-126
#> 4 7QuTub~5556 (Intercept) 22.8 0.493 46.2 2.51e-140
#> 5 7cbcrd~0495 (Intercept) 16.7 0.493 33.8 1.93e-105
#> 6 7soopj~3451 (Intercept) 26.3 0.493 53.4 1.83e-157
#> 7 9VUkAq~8655 (Intercept) 22.2 0.494 45.0 2.59e-137
#> 8 At886V~0359 (Intercept) 17.1 0.698 24.5 2.33e- 74
#> 9 BEJI92~5483 (Intercept) 15.9 0.698 22.7 1.03e- 67
#> 10 CGzoYe~1248 (Intercept) 18.2 0.493 37.0 3.72e-115
#> # ℹ 137 more rows