Estimate contrasts using Wald Test
Estimate contrasts using Wald Test
Other modelling:
ContrastsMissing
,
ContrastsModerated
,
ContrastsPlotter
,
ContrastsProDA
,
ContrastsROPECA
,
ContrastsTable
,
INTERNAL_FUNCTIONS_BY_FAMILY
,
LR_test()
,
Model
,
build_model()
,
contrasts_fisher_exact()
,
get_anova_df()
,
get_complete_model_fit()
,
get_p_values_pbeta()
,
isSingular_lm()
,
linfct_all_possible_contrasts()
,
linfct_factors_contrasts()
,
linfct_from_model()
,
linfct_matrix_contrasts()
,
merge_contrasts_results()
,
model_analyse()
,
model_summary()
,
moderated_p_limma()
,
moderated_p_limma_long()
,
my_contest()
,
my_contrast()
,
my_contrast_V1()
,
my_contrast_V2()
,
my_glht()
,
pivot_model_contrasts_2_Wide()
,
plot_lmer_peptide_predictions()
,
sim_build_models_lm()
,
sim_build_models_lmer()
,
sim_make_model_lm()
,
sim_make_model_lmer()
,
strategy_lmer()
,
summary_ROPECA_median_p.scaled()
prolfqua::ContrastsInterface
-> Contrast
models
Model
contrasts
character with contrasts
contrastfun
function to compute contrasts
modelName
model name
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
global
use a global linear function (determined by get_linfct)
protein_annot
holds protein annotation
Inherited methods
new()
initialize create Contrast
Contrasts$new(
model,
contrasts,
p.adjust = prolfqua::adjust_p_values,
global = FALSE,
modelName = "WaldTest"
)
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
global
development/internal argument (if FALSE determine linfct for each model.)
modelName
name of contrast method, default WaldTest
get_Plotter()
return ContrastsPlotter
creates Contrast_Plotter
FCthreshold
fold change threshold to show in plots
FDRthreshold
FDR threshold to show in plots
to_wide()
convert to wide format
Contrasts$to_wide(columns = c("p.value", "FDR", "statistic"))
# Fitting mixed effects model to peptide data
istar <- prolfqua::sim_lfq_data_peptide_config()
#> creating sampleName from fileName column
#> Warning: no nr_children column specified in the data, adding column nr_children and setting to 1.
#> completing cases
modelFunction <-
strategy_lmer("abundance ~ group_ + (1 | peptide_Id) + (1 | sample)")
config <- istar$config
config$table$hierarchy_keys_depth()
#> [1] "protein_Id"
mod <- build_model(
istar$data,
modelFunction,
subject_Id = config$table$hierarchy_keys_depth()
)
#> 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)`
ref_lfc <- data.frame(
`(Intercept)` = c(0, 0, 0),
group_B = c(0, 1, 0),
group_Ctrl = c(-1, -1, 1),
row.names = c("groupA_vs_Ctrl", "dil.e_vs_b", "dil.ctrl_vs_b")
)
prolfqua::model_summary(mod)
#> $exists
#>
#> FALSE TRUE
#> 4 6
#>
#> $isSingular
#>
#> FALSE TRUE
#> 1 5
#>
Contr <- c("groupA_vs_Ctrl" = "group_A - group_Ctrl",
"dil.e_vs_b" = "group_B - group_Ctrl",
"dil.ctrl_vs_b" = "group_Ctrl - group_A"
)
#prolfqua::Contrasts$debug("get_linfct")
#debug(prolfqua:::.linfct)
contrastX <- prolfqua::Contrasts$new(mod, Contr)
y <- contrastX$get_linfct(avg = FALSE)
stopifnot(all(ref_lfc == y))
t <- contrastX$get_linfct(global=FALSE)
x <- contrastX$get_contrasts()
#> determine linear functions:
#> compute contrasts:
#> computing contrasts.
#> Joining with `by = join_by(protein_Id, contrast)`
stopifnot(all(x$p.value < 1 & x$p.value >0))
stopifnot(all(x$avgAbd >0))
stopifnot(all(x$FDR >0 & x$FDR < 1))
x <- contrastX$get_contrast_sides()
xd <- contrastX$column_description()
modelFunction <-
strategy_lm("abundance ~ group_")
mod <- build_model(
istar$data,
modelFunction,
subject_Id = config$table$hierarchy_keys_depth()
)
#> Joining with `by = join_by(protein_Id)`
contrastX <- prolfqua::Contrasts$new(mod, Contr)
y <- contrastX$get_linfct(avg = FALSE)
stopifnot(all(ref_lfc == y))