ContrastsMissing: Compute contrasts with group mean imputation

ContrastsMissingR Documentation

Compute contrasts with group mean imputation

Description

Compute contrasts with group mean imputation

Compute contrasts with group mean imputation

Details

If there are no observations in one of the groups for some of the proteins, the group mean cannot be estimated. Therefore, assuming that the observation is missing because the protein abundance is below the detection limit, we substitute the unobserved group with the median of protein abundances observed only in one sample of the group. The variance of a protein is estimated using the pooled variance of all observations of all groups.

Super class

prolfqua::ContrastsInterface -> ContrastsMissing

Public fields

subject_Id

subject_id e.g. protein_ID column

contrasts

array with contrasts (see example)

modelName

model name

contrast_result

data frame with results of contrast computation

lfqdata

data frame

confint

confidence interval

p.adjust

function to adjust p-values

global

Take global or local values for imputation

present

default 1, presence in interaction to infer limit of detection.

minsd

default 1, if standard deviation can not be estimated, what is the prior minimum sd, default = 1s

Methods

Public methods

Inherited methods

Method new()

initialize

Usage
ContrastsMissing$new(
  lfqdata,
  contrasts,
  confint = 0.95,
  p.adjust = prolfqua::adjust_p_values,
  modelName = "groupAverage"
)
Arguments
lfqdata

LFQData

contrasts

array of contrasts (see example)

confint

confidence interval

p.adjust

method for p-value adjustment - default Benjamini Hochberg

modelName

default "groupAverage"


Method get_contrast_sides()

get contrasts sides

Usage
ContrastsMissing$get_contrast_sides()

Method get_contrasts()

table with results of contrast computation

Usage
ContrastsMissing$get_contrasts(all = FALSE)
Arguments
all

FALSE, do not show all columns (default)


Method get_Plotter()

get ContrastsPlotter

Usage
ContrastsMissing$get_Plotter()
Returns

Contrast_Plotter


Method to_wide()

convert contrast results to wide format

Usage
ContrastsMissing$to_wide(columns = c("p.value", "FDR"))
Arguments
columns

value column default p.value

Returns

data.frame


Method clone()

The objects of this class are cloneable with this method.

Usage
ContrastsMissing$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Other modelling: Contrasts, ContrastsModerated, ContrastsPlotter, ContrastsProDA, ContrastsROPECA, ContrastsTable, INTERNAL_FUNCTIONS_BY_FAMILY, LR_test(), Model, build_model(), build_models(), contrasts_fisher_exact(), get_anova_df(), get_complete_model_fit(), get_imputed_contrasts(), get_p_values_pbeta(), isSingular_lm(), linfct_all_possible_contrasts(), linfct_factors_contrasts(), linfct_from_model(), linfct_matrix_contrasts(), make_model(), 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_model_and_data(), plot_lmer_peptide_noRandom(), plot_lmer_peptide_predictions(), plot_lmer_predicted_interactions(), strategy_lmer(), summary_ROPECA_median_p.scaled()

Examples

Nprot <- 120
istar <- prolfqua::sim_lfq_data_protein_config(Nprot = Nprot,weight_missing = .4)
istar$data$abundance |> is.na() |> sum()
protIntensity <- istar$data
config <- istar$config


lProt <- LFQData$new(protIntensity, config)
lProt$rename_response("transformedIntensity")

Contr <- c("dil.b_vs_a" = "group_A - group_Ctrl")
csi <- ContrastsMissing$new(lProt, contrasts = Contr)
csi$get_contrast_sides()

res <- csi$get_contrasts()

stopifnot(nrow(res) ==  (protIntensity$protein_Id |> unique() |> length()))
res$contrast |> table()
stopifnot((res$p.value |> is.na() |> sum()) == 0)
plot(res$diff, -log10(res$p.value), pch = ".")
csi$column_description()
x<- csi$get_Plotter()
p <- x$volcano()
pdf(file = NULL)
print(p)
dev.off()

dd <- prolfqua::sim_lfq_data_2Factor_config(Nprot = 100,weight_missing = 0.1)

Contrasts <- c("c1" = "TreatmentA - TreatmentB",
               "C2" = "BackgroundX- BackgroundZ",
               "c3" = "`TreatmentA:BackgroundX` - `TreatmentA:BackgroundZ`",
               "c4" = "`TreatmentB:BackgroundX` - `TreatmentB:BackgroundZ`"
               )
lProt <- LFQData$new(dd$data, dd$config)
lProt$rename_response("transformedIntensity")

csi <- ContrastsMissing$new(lProt, contrasts = Contrasts)
res <- csi$get_contrasts()
pl <- csi$get_Plotter()
pdf(file = NULL)
pl$volcano()
dev.off()

wolski/prolfqua documentation built on May 2, 2024, 7:23 p.m.