Each contrast is a Wald test of a linear function of the model coefficients; $get_linfct() returns
these coefficient weights.
See also
Other modelling:
AnovaExtractor,
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(),
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()
Super class
ContrastsInterface -> Contrast
Public fields
modelsModel
contrastscharacter with contrasts
contrastfunfunction to compute contrasts
model_namemodel name
subject_idname of column containing e.g., protein Id's
p.adjustfunction to adjust p-values (default prolfqua::adjust_p_values)
contrast_resultdata frame containing results of contrast computation
globaluse a global linear function (determined by get_linfct)
Methods
Inherited methods
ContrastsInterface$column_description()ContrastsInterface$contrast_summary_table()ContrastsInterface$extra_artifacts()ContrastsInterface$filter_significant()ContrastsInterface$get_Plotter()ContrastsInterface$get_config()ContrastsInterface$get_missing()ContrastsInterface$get_ora()ContrastsInterface$get_rank()ContrastsInterface$to_wide()
Contrast$new()
initialize create Contrast
Usage
Contrast$new(
model,
contrasts,
p.adjust = prolfqua::adjust_p_values,
global = FALSE,
model_name = "WaldTest"
)Arguments
modela dataframe with a structure similar to that generated by
build_modelcontrastsa character vector with contrast specification
p.adjustfunction to adjust the p-values
globaldevelopment/internal argument (if FALSE determine linfct for each model.)
model_namename of contrast method, default WaldTest
Examples
# Fitting mixed effects model to peptide data
istar <- prolfqua::sim_lfq_data_peptide_config()
#> `protein_Id`: columns `proteinID`, `idtype2` united with separator '~'.
#> creating sampleName from file_name column
#> setup_analysis: dropped 6 unconfigured columns: average_prot_abundance, sd, mean, N, avg_peptide_abd, Replicate.
#> setup_analysis: added 36 rows with NA response for feature and sample combinations absent from the input.
modelFunction <-
strategy_lmer("abundance ~ group_ + (1 | peptide_Id) + (1 | sample)")
config <- istar$config
config$hierarchy_keys_depth()
#> [1] "protein_Id"
mod <- build_model(
istar$data,
modelFunction,
subject_id = config$hierarchy_keys_depth()
)
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
#> Warning: fit (Model): 4 fits failed (e.g. 7cbcrd~5725, 9VUkAq~4703, CGzoYe~2147, DoWup2~5896): Error: grouping factors must have > 1 sampled level
#> See $provenance().
#> fit (Model): 5 singular fits (e.g. 0EfVhX~0087, Fl4JiV~8625, HvIpHG~9079, JcKVfU~9653, SGIVBl~5782): coefficients not estimable or fewer than 2 residual df
#> fit (Model): 32 missing responses dropped (e.g. 0EfVhX~0087, BEJI92~5282, Fl4JiV~8625, HvIpHG~9079, SGIVBl~5782): NA response (missing observation) left out of the fit
#> See $provenance().
ref_lfc <- data.frame(
`(Intercept)` = c(0, 0, 0),
group_B = c(0, 1, 0),
group_Ctrl = c(-1, -1, 1),
row.names = c("groupA_vs_Ctrl", "dil.e_vs_b", "dil.ctrl_vs_b")
)
Contr <- c(
"groupA_vs_Ctrl" = "group_A - group_Ctrl",
"dil.e_vs_b" = "group_B - group_Ctrl",
"dil.ctrl_vs_b" = "group_Ctrl - group_A"
)
contrastX <- prolfqua::Contrasts$new(mod, Contr)
y <- contrastX$get_linfct(avg = FALSE)
stopifnot(all(ref_lfc == y))
t <- contrastX$get_linfct(global = FALSE)
x <- contrastX$get_contrasts()
stopifnot(all(x$p.value < 1 & x$p.value > 0))
stopifnot(all(x$avgAbd > 0))
stopifnot(all(x$FDR > 0 & x$FDR < 1))
x <- contrastX$get_contrast_sides()
xd <- contrastX$column_description()
modelFunction <-
strategy_lm("abundance ~ group_")
mod <- build_model(
istar$data,
modelFunction,
subject_id = config$hierarchy_keys_depth()
)
#> fit (Model): 36 missing responses dropped (e.g. 0EfVhX~0087, 7cbcrd~5725, 9VUkAq~4703, BEJI92~5282, CGzoYe~2147, ...): NA response (missing observation) left out of the fit
#> See $provenance().
contrastX <- prolfqua::Contrasts$new(mod, Contr)
y <- contrastX$get_linfct(avg = FALSE)
stopifnot(all(ref_lfc == y))