Skip to contents

Rfit rank-regression contrast analysis with LOD imputation facade

Rfit rank-regression contrast analysis with LOD imputation facade

Value

An R6 class generator.

Details

The rank-based analogue of ContrastsLMImputeFacade. Encapsulates the pipeline: strategy_rfit -> build_model_impute -> Contrasts -> ContrastsModerated, using rfit.

Proteins whose initial rfit fit fails, is singular, or has an incomplete design are re-fitted after imputing missing values with the limit of detection (LOD). Uncertainty is borrowed from successful donor fits so it is not underestimated by the constant imputation.

Differences from ContrastsLMImputeFacade:

  • Covariance borrowing is vcov-only (element-wise median of the donors' full named covariance matrices). rfit exposes no lm-style cov.unscaled, so the scalar-sigma borrowing mode is not available and is not exposed.

  • Borrowing is fail-hard (on_misalign = "fail"): if the donor covariance matrices cannot be aligned by coefficient name, the rescue is skipped and those proteins remain in get_missing() rather than carrying an lm-specific approximation.

  • No observation weights (rfit has no weights argument), matching plain rfit.

modelName is the facade key "rfit_impute"; rescued rows are flagged in the estimate_type column as "lod_imputed", the same convention used by ContrastsLMImputeFacade.

See also

ContrastsLMImputeFacade, ContrastsRfitFacade, build_model_impute

Other modelling: AnovaExtractor, Contrasts, ContrastsDEqMSFacade, ContrastsDEqMSVoomFacade, ContrastsFacadeBase, ContrastsFirth, ContrastsFirthFacade, ContrastsFirthNestedFacade, ContrastsLMFacade, ContrastsLMImputeFacade, ContrastsLMMissingFacade, ContrastsLimma, ContrastsLimmaFacade, ContrastsLimmaImputeFacade, ContrastsLimmaVoomFacade, ContrastsLimmaVoomImputeFacade, ContrastsLimpaFacade, ContrastsLimpaNestedFacade, ContrastsLmerNestedFacade, ContrastsMissing, ContrastsModerated, ContrastsModeratedDEqMS, ContrastsPlotter, ContrastsRLMFacade, ContrastsROPECA, ContrastsROPECANestedFacade, ContrastsRfitFacade, 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 classes

prolfqua::ContrastsInterface -> prolfqua::ContrastsFacadeBase -> ContrastsRfitImputeFacade

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

Inherited methods


Method new()

initialize

Usage

ContrastsRfitImputeFacade$new(
  lfqdata,
  modelstr,
  contrasts,
  lod = NULL,
  df_method = c("observed", "borrowed"),
  ...
)

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

df_method

"observed" uses max(n_observed - p, 1); "borrowed" uses median df from successful fits

...

passed to strategy_rfit


Method clone()

The objects of this class are cloneable with this method.

Usage

ContrastsRfitImputeFacade$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 file_name 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 <- ContrastsRfitImputeFacade$new(lfqdata, "~ group_", contrasts)
#> Warning: There were 2 warnings in `dplyr::mutate()`.
#> The first warning was:
#>  In argument: `linear_model = purrr::map(data, model_strategy$model_fun, pb =
#>   pb)`.
#>  In group 20: `protein_Id = "LlQY7I~3486"`.
#> Caused by warning in `sqrt()`:
#> ! NaNs produced
#>  Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning.
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
#>   modelName estimate_type protein_Id contrast    diff std.error avgAbd statistic
#>   <chr>     <chr>         <chr>      <chr>      <dbl>     <dbl>  <dbl>     <dbl>
#> 1 rfit_imp… observed      0EfVhX~29… A_vs_Ct…  1.40       0.999   22.7    1.55  
#> 2 rfit_imp… observed      0m5WN4~67… A_vs_Ct…  0.0318     0.857   20.7    0.0304
#> 3 rfit_imp… observed      7QuTub~61… A_vs_Ct…  0.909      1.15    16.7    0.580 
#> 4 rfit_imp… observed      7cbcrd~26… A_vs_Ct…  0.612      1.64    21.8    0.553 
#> 5 rfit_imp… observed      9VUkAq~34… A_vs_Ct…  0.768      2.04    19.9    0.787 
#> 6 rfit_imp… observed      At886V~77… A_vs_Ct… -1.91       1.03    29.2   -2.11  
#> # ℹ 6 more variables: df <dbl>, 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.40              0.133          0.666              1.55  
#>  2 0m5WN4~67…         0.0318            0.976          1                  0.0304
#>  3 7QuTub~61…         0.909             0.568          1                  0.580 
#>  4 7cbcrd~26…         0.612             0.586          1                  0.553 
#>  5 9VUkAq~34…         0.768             0.439          1                  0.787 
#>  6 At886V~77…        -1.91              0.0443         0.443             -2.11  
#>  7 BEJI92~27…        -1.30              0.195          0.711             -1.33  
#>  8 CGzoYe~08…         0.867             0.383          1                  0.888 
#>  9 CtOJ9t~91…         0.107             0.906          1                  0.119 
#> 10 DoWup2~28…        -1.50              0.108          0.646             -1.66  
#> # ℹ 20 more rows