Skip to contents

Lmer contrast analysis facade

Lmer contrast analysis facade

Details

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

This facade requires data with hierarchy below the analysis subject, for example peptide-level measurements nested within proteins.

Public fields

model

Model object

contrast

ContrastsModerated object

Methods


Method new()

initialize

Usage

ContrastsLmerFacade$new(lfqdata, modelstr, contrasts, ...)

Arguments

lfqdata

LFQData object

modelstr

model formula string (e.g. "~ group_ + (1 | peptide_Id)")

contrasts

named character vector of contrasts

...

passed to strategy_lmer


Method get_contrasts()

get contrast results

Usage

ContrastsLmerFacade$get_contrasts(...)

Arguments

...

passed to ContrastsModerated$get_contrasts


Method get_Plotter()

get ContrastsPlotter

Usage

ContrastsLmerFacade$get_Plotter(...)

Arguments

...

passed to ContrastsModerated$get_Plotter


Method to_wide()

convert results to wide format

Usage

ContrastsLmerFacade$to_wide(...)

Arguments

...

passed to ContrastsModerated$to_wide


Method clone()

The objects of this class are cloneable with this method.

Usage

ContrastsLmerFacade$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

istar <- sim_lfq_data_peptide_config()
#> creating sampleName from fileName column
#> completing cases
#> completing cases done
#> setup done
istar$config <- old2new(istar$config)
lfqdata <- LFQData$new(istar$data, istar$config)
lfqdata <- lfqdata$get_Transformer()$log2()$lfq
#> Column added : log2_abundance
contrasts <- c("A_vs_Ctrl" = "group_A - group_Ctrl")
fa <- ContrastsLmerFacade$new(
  lfqdata,
  "~ group_ + (1 | peptide_Id) + (1 | sampleName)",
  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: There were 4 warnings in `dplyr::mutate()`.
#> The first warning was:
#>  In argument: `linear_model = purrr::map(data, model_strategy$model_fun, pb =
#>   pb)`.
#>  In group 2: `protein_Id = "7cbcrd~5725"`.
#> Caused by warning in `value[[3L]]()`:
#> ! WARN :Error: grouping factors must have > 1 sampled level
#>  Run `dplyr::last_dplyr_warnings()` to see the 3 remaining warnings.
#> Joining with `by = join_by(protein_Id)`
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 lmer   WaldTest… 0EfVhX~00… A_vs_Ct… -8.32e-4    0.0730   4.34   -0.0115  28.9
#> 2 lmer   WaldTest… BEJI92~52… A_vs_Ct…  3.22e-1    0.0832   4.22    2.81    11.6
#> 3 lmer   WaldTest… Fl4JiV~86… A_vs_Ct… -4.13e-2    0.0850   4.38   -0.503   39.5
#> 4 lmer   WaldTest… HvIpHG~90… A_vs_Ct… -3.72e-1    0.0616   4.40   -5.65    21.8
#> 5 lmer   WaldTest… JcKVfU~96… A_vs_Ct… -1.07e-1    0.0577   5.05   -1.88    79.8
#> 6 lmer   WaldTest… SGIVBl~57… A_vs_Ct…  3.07e-2    0.0695   4.68    0.452   61.0
#> # ℹ 5 more variables: 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.0115
#> 2 BEJI92~5282       0.322            0.0161        0.0484                 2.81  
#> 3 Fl4JiV~8625      -0.0413           0.618         0.783                 -0.503 
#> 4 HvIpHG~9079      -0.372            0.0000113     0.0000680             -5.65  
#> 5 JcKVfU~9653      -0.107            0.0637        0.127                 -1.88  
#> 6 SGIVBl~5782       0.0307           0.653         0.783                  0.452