Skip to contents

Encapsulates the pipeline: strategy_lmer -> build_model -> Contrasts -> ContrastsModerated.

Takes child-hierarchy LFQData (e.g. peptide-level measurements nested within proteins) and returns protein-level fold-change estimates.

modelstr may be either a fixed-effects-only formula (e.g. "~ group_") - in which case the facade appends (1 | <deepest child hierarchy key>) + (1 | <sample name>) derived from the LFQData - or a full mixed-model formula already containing random effects, which is passed through unchanged.

Value

An R6 class generator.

See also

Other modelling: AnovaExtractor, Contrasts, ContrastsComparison, ContrastsDEqMSFacade, ContrastsDEqMSVoomFacade, ContrastsFacadeBase, ContrastsFirth, ContrastsFirthFacade, ContrastsHurdleFacade, ContrastsHurdleNestedFacade, ContrastsLMFacade, ContrastsLMImputeFacade, ContrastsLimma, ContrastsLimmaFacade, ContrastsLimmaImputeFacade, ContrastsLimmaVoomFacade, ContrastsLimmaVoomImputeFacade, ContrastsLimpaFacade, ContrastsLimpaNestedFacade, 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 classes

ContrastsInterface -> ContrastsFacadeBase -> ContrastsLmerNestedFacade

Methods

Inherited methods


ContrastsLmerNestedFacade$new()

initialize

Usage

ContrastsLmerNestedFacade$new(lfqdata, modelstr, contrasts, control = list())

Arguments

lfqdata

nested LFQData (subject_id strict subset of hierarchy_keys)

modelstr

model formula RHS as string. Fixed effects only (e.g. "~ group_") - random effects are derived from lfqdata as (1 | <deepest child key>) + (1 | <sample name>). A formula already containing random-effect bars is passed through unchanged.

contrasts

named character vector of contrasts

control

named list of convergence controls, see strategy_lmer


ContrastsLmerNestedFacade$clone()

The objects of this class are cloneable with this method.

Usage

ContrastsLmerNestedFacade$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

istar <- 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.
lfqdata <- LFQData$new(istar$data, istar$config)
lfqdata <- lfqdata$get_Transformer()$log2()$lfq
#> Transformed response column added: log2_abundance
contrasts <- c("A_vs_Ctrl" = "group_A - group_Ctrl")
# Random effects derived from lfqdata; equivalent to passing the full
# mixed-model formula explicitly.
fa <- ContrastsLmerNestedFacade$new(lfqdata, "~ group_", contrasts)
#> 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().
head(fa$get_contrasts())
#> # A tibble: 6 × 16
#>   modelName   estimate_type protein_Id  contrast       diff avgAbd
#>   <chr>       <chr>         <chr>       <chr>         <dbl>  <dbl>
#> 1 lmer_nested observed      0EfVhX~0087 A_vs_Ctrl -0.000832   4.34
#> 2 lmer_nested observed      BEJI92~5282 A_vs_Ctrl  0.322      4.22
#> 3 lmer_nested observed      Fl4JiV~8625 A_vs_Ctrl -0.0413     4.38
#> 4 lmer_nested observed      HvIpHG~9079 A_vs_Ctrl -0.372      4.40
#> 5 lmer_nested observed      JcKVfU~9653 A_vs_Ctrl -0.107      5.05
#> 6 lmer_nested observed      SGIVBl~5782 A_vs_Ctrl  0.0307     4.68
#> # ℹ 10 more variables: std.error.unmoderated <dbl>, df.unmoderated <dbl>,
#> #   std.error <dbl>, statistic <dbl>, df <dbl>, p.value <dbl>, conf.low <dbl>,
#> #   conf.high <dbl>, sigma <dbl>, FDR <dbl>
fa$to_wide()
#> # A tibble: 6 × 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~0087      -0.000832         0.991          0.991                -0.0108
#> 2 BEJI92~5282       0.322            0.0511         0.129                 2.12  
#> 3 Fl4JiV~8625      -0.0413           0.621          0.785                -0.498 
#> 4 HvIpHG~9079      -0.372            0.0000570      0.000342             -4.82  
#> 5 JcKVfU~9653      -0.107            0.0643         0.129                -1.87  
#> 6 SGIVBl~5782       0.0307           0.654          0.785                 0.450