Skip to contents

Estimate contrasts using Wald Test

Estimate contrasts using Wald Test

Value

An R6 class generator.

See also

Other modelling: AnovaExtractor, Contrasts, ContrastsDEqMSFacade, ContrastsDEqMSVoomFacade, ContrastsFacadeBase, ContrastsFirthFacade, ContrastsFirthNestedFacade, ContrastsLMFacade, ContrastsLMImputeFacade, ContrastsLMMissingFacade, ContrastsLimma, ContrastsLimmaFacade, ContrastsLimmaImputeFacade, ContrastsLimmaVoomFacade, ContrastsLimmaVoomImputeFacade, ContrastsLimpaFacade, ContrastsLimpaNestedFacade, ContrastsLmerNestedFacade, ContrastsMissing, ContrastsModerated, ContrastsModeratedDEqMS, ContrastsPlotter, ContrastsRLMFacade, ContrastsROPECA, ContrastsROPECANestedFacade, ContrastsRfitFacade, ContrastsRfitImputeFacade, ContrastsTable, INTERNAL_FUNCTIONS_BY_FAMILY, LR_test(), Model, ModelFirth, ModelLimma, StrategyLM, StrategyLimma, StrategyLimpa, StrategyLmer, StrategyLogistf, StrategyRLM, StrategyRfit, build_contrast_analysis(), build_model(), build_model_glm_peptide(), 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(), build_model_logistf(), compute_borrowed_variance(), compute_borrowed_variance_limma(), compute_contrast(), compute_lmer_contrast(), contrasts_fisher_exact(), df.residual.rfit_prolfqua(), get_anova_df(), get_complete_model_fit(), get_p_values_pbeta(), group_label(), impute_refit_singular(), is_singular_lm(), linfct_all_possible_contrasts(), linfct_factors_contrasts(), linfct_from_model(), linfct_matrix_contrasts(), list_facades(), lookup_facade(), merge_contrasts_results(), model_analyse(), model_summary(), moderated_p_deqms(), moderated_p_deqms_long(), moderated_p_limma(), moderated_p_limma_long(), new_imputed_model(), pivot_model_contrasts_to_wide(), plot_lmer_peptide_predictions(), register_facade(), sigma.rfit_prolfqua(), sim_build_models_lm(), sim_build_models_lmer(), sim_build_models_logistf(), sim_make_model_lm(), sim_make_model_lmer(), strategy_limma(), strategy_limpa(), strategy_logistf(), summary_ROPECA_median_p.scaled(), unregister_facade(), vcov.rfit_prolfqua()

Super class

prolfqua::ContrastsInterface -> ContrastsFirth

Public fields

models

Model

contrasts

character with contrasts

model_name

name of model

subject_id

name of column containing e.g., protein Id's

p.adjust

function to adjust p-values (default prolfqua::adjust_p_values)

contrast_result

data frame containing results of contrast computation

Methods

Inherited methods


Method new()

initialize create Contrast

Usage

ContrastsFirth$new(
  model,
  contrasts,
  p.adjust = prolfqua::adjust_p_values,
  model_name = "firth"
)

Arguments

model

a dataframe with a structure similar to that generated by build_model

contrasts

a character vector with contrast specificiation

p.adjust

function to adjust the p-values

model_name

name of contrast method, default firth


Method get_contrast_sides()

get both sides of contrasts

Usage

ContrastsFirth$get_contrast_sides()


Method get_linfct()

get linear functions from contrasts

Usage

ContrastsFirth$get_linfct(avg = TRUE)

Arguments

avg

logical TRUE - get also linfct for averages

Returns

a list with the linfct-annotated model containers (models1 / models2); the shared input model is left untouched.


Method get_contrasts()

get table with contrast estimates

Usage

ContrastsFirth$get_contrasts(all = FALSE)

Arguments

all

should all columns be returned (default FALSE)

Returns

data.frame with contrasts


Method get_Plotter()

return ContrastsPlotter creates Contrast_Plotter

Usage

ContrastsFirth$get_Plotter(fc_threshold = 1, fdr_threshold = 0.1)

Arguments

fc_threshold

fold change threshold to show in plots

fdr_threshold

FDR threshold to show in plots


Method to_wide()

convert to wide format

Usage

ContrastsFirth$to_wide(columns = c("p.value", "FDR", "statistic"))

Arguments

columns

value column default p.value

Returns

data.frame


Method clone()

The objects of this class are cloneable with this method.

Usage

ContrastsFirth$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


modi <- sim_build_models_logistf(model = "parallel3", weight_missing = 1)
#> creating sampleName from file_name column
#> completing cases
#> completing cases done
#> setup done
#> Joining with `by = join_by(protein_Id)`
contrasts <- c(Avs = "group_A - group_B", AvsCtrl = "group_A - group_Ctrl")

ctr <- ContrastsFirth$new(modi,contrasts)
ctr$get_contrast_sides()
#> # A tibble: 2 × 3
#>   contrast group_1 group_2   
#>   <chr>    <chr>   <chr>     
#> 1 Avs      group_A group_B   
#> 2 AvsCtrl  group_A group_Ctrl
ctr$get_linfct()
#> $models1
#> $models1$model_df
#> # A tibble: 10 × 10
#> # Groups:   protein_Id [10]
#>    protein_Id  data     linear_model has_model_fit isSingular df.residual sigma
#>    <chr>       <list>   <list>       <lgl>         <lgl>            <dbl> <dbl>
#>  1 0EfVhX~0087 <tibble> <logistf>    TRUE          FALSE                9     1
#>  2 7cbcrd~5725 <tibble> <logistf>    TRUE          FALSE                9     1
#>  3 9VUkAq~4703 <tibble> <logistf>    TRUE          FALSE                9     1
#>  4 BEJI92~5282 <tibble> <logistf>    TRUE          FALSE                9     1
#>  5 CGzoYe~2147 <tibble> <logistf>    TRUE          FALSE                9     1
#>  6 DoWup2~5896 <tibble> <logistf>    TRUE          FALSE                9     1
#>  7 Fl4JiV~8625 <tibble> <logistf>    TRUE          FALSE                9     1
#>  8 HvIpHG~9079 <tibble> <logistf>    TRUE          FALSE                9     1
#>  9 JcKVfU~9653 <tibble> <logistf>    TRUE          FALSE                9     1
#> 10 SGIVBl~5782 <tibble> <logistf>    TRUE          FALSE                9     1
#> # ℹ 3 more variables: nr_coef <int>, nr_coef_not_NA <int>, linfct <list>
#> 
#> $models1$model_name
#> [1] "logistf_1"
#> 
#> $models1$strategy
#> <StrategyLogistf>
#>   Public:
#>     anova_df: AnovaExtractor, R6
#>     clone: function (deep = FALSE) 
#>     contrast_fun: function (...) 
#>     df_residual: function (model) 
#>     formula: formula
#>     initialize: function (modelstr, model_name = "logistf", report_columns = c("statistic", 
#>     isSingular: function (model) 
#>     is_mixed: FALSE
#>     model_fun: function (x, pb, get_formula = FALSE) 
#>     model_name: logistf
#>     report_columns: statistic p.value p.value.adjusted moderated.p.value mod ...
#>     sigma: function (model) 
#> 
#> 
ctr$get_contrasts()
#> determine linear functions:
#> get_contrasts -> contrasts_linfct
#> contrasts_linfct_firth
#> Joining with `by = join_by(protein_Id, contrast)`
#> # A tibble: 20 × 14
#> # Groups:   contrast [2]
#>    modelName estimate_type protein_Id  contrast sigma    df      diff   FDR
#>    <chr>     <chr>         <chr>       <chr>    <dbl> <int>     <dbl> <dbl>
#>  1 firth     observed      0EfVhX~0087 Avs          1     9 -8.47e- 1 0.769
#>  2 firth     observed      0EfVhX~0087 AvsCtrl      1     9 -8.47e- 1 0.769
#>  3 firth     observed      7cbcrd~5725 Avs          1     9  6.90e-16 1    
#>  4 firth     observed      7cbcrd~5725 AvsCtrl      1     9  8.47e- 1 0.769
#>  5 firth     observed      9VUkAq~4703 Avs          1     9 -8.47e- 1 0.769
#>  6 firth     observed      9VUkAq~4703 AvsCtrl      1     9  8.47e- 1 0.769
#>  7 firth     observed      BEJI92~5282 Avs          1     9  8.47e- 1 0.769
#>  8 firth     observed      BEJI92~5282 AvsCtrl      1     9  2.20e+ 0 0.769
#>  9 firth     observed      CGzoYe~2147 Avs          1     9  1.52e-15 1    
#> 10 firth     observed      CGzoYe~2147 AvsCtrl      1     9  1.07e-15 1    
#> 11 firth     observed      DoWup2~5896 Avs          1     9 -1.35e+ 0 0.769
#> 12 firth     observed      DoWup2~5896 AvsCtrl      1     9 -3.04e+ 0 0.769
#> 13 firth     observed      Fl4JiV~8625 Avs          1     9  8.47e- 1 0.769
#> 14 firth     observed      Fl4JiV~8625 AvsCtrl      1     9  8.47e- 1 0.769
#> 15 firth     observed      HvIpHG~9079 Avs          1     9 -1.69e+ 0 0.769
#> 16 firth     observed      HvIpHG~9079 AvsCtrl      1     9 -1.69e+ 0 0.769
#> 17 firth     observed      JcKVfU~9653 Avs          1     9  1.52e-15 1    
#> 18 firth     observed      JcKVfU~9653 AvsCtrl      1     9  1.07e-15 1    
#> 19 firth     observed      SGIVBl~5782 Avs          1     9  1.35e+ 0 0.769
#> 20 firth     observed      SGIVBl~5782 AvsCtrl      1     9 -4.13e-16 1    
#> # ℹ 6 more variables: std.error <dbl>, statistic <dbl>, p.value <dbl>,
#> #   conf.low <dbl>, conf.high <dbl>, avgAbd <dbl>

mod3 <- sim_build_models_logistf(model = "parallel3", weight_missing = 1, peptide=TRUE)
#> creating sampleName from file_name column
#> completing cases
#> completing cases done
#> setup done
#> Joining with `by = join_by(protein_Id)`
#> Joining with `by = join_by(protein_Id)`

ctrpep <- ContrastsFirth$new(mod3,contrasts)
ctrpep$get_contrast_sides()
#> # A tibble: 2 × 3
#>   contrast group_1 group_2   
#>   <chr>    <chr>   <chr>     
#> 1 Avs      group_A group_B   
#> 2 AvsCtrl  group_A group_Ctrl

ctrpep$get_linfct()
#> $models1
#> $models1$model_df
#> # A tibble: 4 × 10
#> # Groups:   protein_Id [4]
#>   protein_Id  data     linear_model has_model_fit isSingular df.residual sigma
#>   <chr>       <list>   <list>       <lgl>         <lgl>            <dbl> <dbl>
#> 1 7cbcrd~5725 <tibble> <logistf>    TRUE          FALSE                9     1
#> 2 9VUkAq~4703 <tibble> <logistf>    TRUE          FALSE                9     1
#> 3 CGzoYe~2147 <tibble> <logistf>    TRUE          FALSE                9     1
#> 4 DoWup2~5896 <tibble> <logistf>    TRUE          FALSE                9     1
#> # ℹ 3 more variables: nr_coef <int>, nr_coef_not_NA <int>, linfct <list>
#> 
#> $models1$model_name
#> [1] "logistf_1"
#> 
#> $models1$strategy
#> <StrategyLogistf>
#>   Public:
#>     anova_df: AnovaExtractor, R6
#>     clone: function (deep = FALSE) 
#>     contrast_fun: function (...) 
#>     df_residual: function (model) 
#>     formula: formula
#>     initialize: function (modelstr, model_name = "logistf", report_columns = c("statistic", 
#>     isSingular: function (model) 
#>     is_mixed: FALSE
#>     model_fun: function (x, pb, get_formula = FALSE) 
#>     model_name: logistf
#>     report_columns: statistic p.value p.value.adjusted moderated.p.value mod ...
#>     sigma: function (model) 
#> 
#> 
#> $models2
#> $models2$model_df
#> # A tibble: 6 × 10
#> # Groups:   protein_Id [6]
#>   protein_Id  data     linear_model has_model_fit isSingular df.residual sigma
#>   <chr>       <list>   <list>       <lgl>         <lgl>            <dbl> <dbl>
#> 1 0EfVhX~0087 <tibble> <logistf>    TRUE          FALSE               31     1
#> 2 BEJI92~5282 <tibble> <logistf>    TRUE          FALSE               20     1
#> 3 Fl4JiV~8625 <tibble> <logistf>    TRUE          FALSE               42     1
#> 4 HvIpHG~9079 <tibble> <logistf>    TRUE          FALSE               20     1
#> 5 JcKVfU~9653 <tibble> <logistf>    TRUE          FALSE               75     1
#> 6 SGIVBl~5782 <tibble> <logistf>    TRUE          FALSE               64     1
#> # ℹ 3 more variables: nr_coef <int>, nr_coef_not_NA <int>, linfct <list>
#> 
#> $models2$model_name
#> [1] "logistf_2"
#> 
#> $models2$strategy
#> <StrategyLogistf>
#>   Public:
#>     anova_df: AnovaExtractor, R6
#>     clone: function (deep = FALSE) 
#>     contrast_fun: function (...) 
#>     df_residual: function (model) 
#>     formula: formula
#>     initialize: function (modelstr, model_name = "logistf", report_columns = c("statistic", 
#>     isSingular: function (model) 
#>     is_mixed: FALSE
#>     model_fun: function (x, pb, get_formula = FALSE) 
#>     model_name: logistf
#>     report_columns: statistic p.value p.value.adjusted moderated.p.value mod ...
#>     sigma: function (model) 
#> 
#> 
ctrpep$get_contrasts()
#> determine linear functions:
#> get_contrasts -> contrasts_linfct
#> contrasts_linfct_firth
#> contrasts_linfct_firth
#> Joining with `by = join_by(protein_Id, contrast)`
#> # A tibble: 20 × 14
#> # Groups:   contrast [2]
#>    modelName estimate_type protein_Id  contrast sigma    df      diff   FDR
#>    <chr>     <chr>         <chr>       <chr>    <dbl> <int>     <dbl> <dbl>
#>  1 firth     observed      0EfVhX~0087 Avs          1    31 -1.02e+ 0 0.463
#>  2 firth     observed      0EfVhX~0087 AvsCtrl      1    31 -6.45e-10 1    
#>  3 firth     observed      BEJI92~5282 Avs          1    20  1.41e-10 1.000
#>  4 firth     observed      BEJI92~5282 AvsCtrl      1    20 -2.99e-16 1    
#>  5 firth     observed      Fl4JiV~8625 Avs          1    42 -7.13e- 1 0.518
#>  6 firth     observed      Fl4JiV~8625 AvsCtrl      1    42  7.75e- 1 0.485
#>  7 firth     observed      HvIpHG~9079 Avs          1    20 -1.98e+ 0 0.425
#>  8 firth     observed      HvIpHG~9079 AvsCtrl      1    20 -1.35e+ 0 0.485
#>  9 firth     observed      JcKVfU~9653 Avs          1    75 -1.24e+ 0 0.463
#> 10 firth     observed      JcKVfU~9653 AvsCtrl      1    75 -6.86e- 1 0.531
#> 11 firth     observed      SGIVBl~5782 Avs          1    64 -7.95e- 1 0.463
#> 12 firth     observed      SGIVBl~5782 AvsCtrl      1    64 -7.95e- 1 0.485
#> 13 firth     observed      7cbcrd~5725 Avs          1     9  8.47e- 1 0.598
#> 14 firth     observed      7cbcrd~5725 AvsCtrl      1     9  1.69e+ 0 0.485
#> 15 firth     observed      9VUkAq~4703 Avs          1     9 -1.35e+ 0 0.585
#> 16 firth     observed      9VUkAq~4703 AvsCtrl      1     9 -4.39e+ 0 0.485
#> 17 firth     observed      CGzoYe~2147 Avs          1     9  1.35e+ 0 0.585
#> 18 firth     observed      CGzoYe~2147 AvsCtrl      1     9 -4.13e-16 1    
#> 19 firth     observed      DoWup2~5896 Avs          1     9  4.39e+ 0 0.425
#> 20 firth     observed      DoWup2~5896 AvsCtrl      1     9  3.04e+ 0 0.485
#> # ℹ 6 more variables: std.error <dbl>, statistic <dbl>, p.value <dbl>,
#> #   conf.low <dbl>, conf.high <dbl>, avgAbd <dbl>
pl <- ctrpep$get_Plotter()