LM contrast analysis with LOD imputation facade
Source:R/ContrastsFacades.R
ContrastsLMImputeFacade.RdLM contrast analysis with LOD imputation facade
LM contrast analysis with LOD imputation facade
Details
Encapsulates the pipeline: strategy_lm ->
build_model (with impute = TRUE) ->
Contrasts -> ContrastsModerated.
Proteins whose initial lm fit fails or produces NA coefficients are re-fitted after imputing missing values with the limit of detection (LOD). The covariance matrix is borrowed from successful fits so that the variance is not underestimated by the constant imputation.
See also
Other modelling:
AnovaExtractor,
Contrasts,
ContrastsDEqMSFacade,
ContrastsFirth,
ContrastsFirthFacade,
ContrastsLMFacade,
ContrastsLMMissingFacade,
ContrastsLimma,
ContrastsLimmaFacade,
ContrastsLmerFacade,
ContrastsMissing,
ContrastsModerated,
ContrastsModeratedDEqMS,
ContrastsPlotter,
ContrastsRLMFacade,
ContrastsROPECA,
ContrastsROPECAFacade,
ContrastsTable,
INTERNAL_FUNCTIONS_BY_FAMILY,
LR_test(),
Model,
ModelFirth,
ModelLimma,
StrategyLM,
StrategyLimma,
StrategyLmer,
StrategyLogistf,
StrategyRLM,
build_contrast_analysis(),
build_model(),
build_model_glm_peptide(),
build_model_glm_protein(),
build_model_impute(),
build_model_limma(),
build_model_logistf(),
compute_borrowed_variance(),
contrasts_fisher_exact(),
get_anova_df(),
get_complete_model_fit(),
get_p_values_pbeta(),
group_label(),
impute_refit_singular(),
isSingular_lm(),
linfct_all_possible_contrasts(),
linfct_factors_contrasts(),
linfct_from_model(),
linfct_matrix_contrasts(),
merge_contrasts_results(),
model_analyse(),
model_summary(),
moderated_p_deqms(),
moderated_p_deqms_long(),
moderated_p_limma(),
moderated_p_limma_long(),
my_contest(),
my_contrast(),
my_contrast_V2(),
new_lm_imputed(),
pivot_model_contrasts_2_Wide(),
plot_lmer_peptide_predictions(),
sim_build_models_lm(),
sim_build_models_lmer(),
sim_build_models_logistf(),
sim_make_model_lm(),
sim_make_model_lmer(),
strategy_limma(),
strategy_logistf(),
summary_ROPECA_median_p.scaled()
Public fields
modelModel object (with imputed proteins)
contrastContrastsModerated object
.lfqdatastored reference to input LFQData
.contrast_namesnames of the requested contrasts
Methods
Method new()
initialize
Usage
ContrastsLMImputeFacade$new(
lfqdata,
modelstr,
contrasts,
lod = NULL,
borrow_method = c("sigma", "vcov"),
df_method = c("observed", "borrowed"),
weights = lfqdata$config$nr_children,
...
)Arguments
lfqdataLFQData object (aggregated to protein level)
modelstrmodel formula string (e.g. "~ group_")
contrastsnamed character vector of contrasts
lodnumeric limit of detection; if NULL, auto-computed from data
borrow_method"sigma" borrows scalar sigma and uses per-protein (X'X)^-1; "vcov" borrows element-wise median of full vcov matrices
df_method"observed" uses max(n_observed - p, 1); "borrowed" uses median df from successful fits
weightscolumn name for per-observation weights (default:
lfqdata$config$nr_children). PassNULLfor unweighted....passed to
strategy_lm
Examples
istar <- sim_lfq_data_protein_config(Nprot = 30, weight_missing = 0.5)
#> creating sampleName from fileName column
#> completing cases
#> completing cases done
#> setup done
lfqdata <- LFQData$new(istar$data, istar$config)
lfqdata$rename_response("transformedIntensity")
contrasts <- c("A_vs_Ctrl" = "group_A - group_Ctrl")
fa <- ContrastsLMImputeFacade$new(lfqdata, "~ group_", contrasts)
#> Joining with `by = join_by(protein_Id)`
#> completing cases
head(fa$get_contrasts())
#> determine linear functions:
#> get_contrasts -> contrasts_linfct
#> contrasts_linfct
#> Joining with `by = join_by(protein_Id, contrast)`
#> # A tibble: 6 × 14
#> facade modelName protein_Id contrast diff std.error avgAbd statistic df
#> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 lm_imp… WaldTest… 0EfVhX~29… A_vs_Ct… 1.24 0.731 22.6 1.88 15.7
#> 2 lm_imp… WaldTest… 0m5WN4~67… A_vs_Ct… -0.0361 0.614 20.8 -0.0334 13.7
#> 3 lm_imp… WaldTest… 7QuTub~61… A_vs_Ct… 0.909 0.943 16.7 0.961 8.74
#> 4 lm_imp… WaldTest… 7cbcrd~26… A_vs_Ct… 0.612 1.08 21.9 0.574 11.7
#> 5 lm_imp… WaldTest… 9VUkAq~34… A_vs_Ct… 0.768 1.42 20.0 0.710 14.7
#> 6 lm_imp… WaldTest… At886V~77… A_vs_Ct… -1.86 0.706 29.1 -2.40 15.7
#> # ℹ 5 more variables: p.value <dbl>, conf.low <dbl>, conf.high <dbl>,
#> # sigma <dbl>, FDR <dbl>
fa$to_wide()
#> # A tibble: 30 × 5
#> protein_Id diff.A_vs_Ctrl p.value.A_vs_Ctrl FDR.A_vs_Ctrl statistic.A_vs_Ctrl
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 0EfVhX~29… 1.24 0.0791 0.593 1.88
#> 2 0m5WN4~67… -0.0361 0.974 0.986 -0.0334
#> 3 7QuTub~61… 0.909 0.362 0.906 0.961
#> 4 7cbcrd~26… 0.612 0.577 0.986 0.574
#> 5 9VUkAq~34… 0.768 0.489 0.986 0.710
#> 6 At886V~77… -1.86 0.0294 0.294 -2.40
#> 7 BEJI92~27… -1.30 0.221 0.737 -1.28
#> 8 CGzoYe~08… 0.196 0.860 0.986 0.180
#> 9 CtOJ9t~91… -0.0717 0.926 0.986 -0.0938
#> 10 DoWup2~28… -1.82 0.00762 0.114 -3.06
#> # ℹ 20 more rows