Skip to contents

LM 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.

Public fields

model

Model object (with imputed proteins)

contrast

ContrastsModerated object

.lfqdata

stored reference to input LFQData

.contrast_names

names 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

lfqdata

LFQData object (aggregated to protein level)

modelstr

model formula string (e.g. "~ group_")

contrasts

named character vector of contrasts

lod

numeric 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

weights

column name for per-observation weights (default: lfqdata$config$nr_children). Pass NULL for unweighted.

...

passed to strategy_lm


Method get_contrasts()

get contrast results

Usage

ContrastsLMImputeFacade$get_contrasts(...)

Arguments

...

passed to ContrastsModerated$get_contrasts


Method get_missing()

get protein x contrast pairs that could not be estimated

Usage

ContrastsLMImputeFacade$get_missing()


Method get_Plotter()

get ContrastsPlotter

Usage

ContrastsLMImputeFacade$get_Plotter(...)

Arguments

...

passed to ContrastsModerated$get_Plotter


Method to_wide()

convert results to wide format

Usage

ContrastsLMImputeFacade$to_wide(...)

Arguments

...

passed to ContrastsModerated$to_wide


Method clone()

The objects of this class are cloneable with this method.

Usage

ContrastsLMImputeFacade$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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