Skip to contents

DEqMS count-dependent moderated contrasts

DEqMS count-dependent moderated contrasts

Details

Decorator that wraps any Contrasts object and applies count-dependent empirical Bayes variance shrinkage. Similar to ContrastsModerated but the prior variance depends on the number of quantified peptides/PSMs per protein: proteins with many peptides get less shrinkage, proteins with few peptides get more.

Super class

prolfqua::ContrastsInterface -> ContrastsModeratedDEqMS

Public fields

Contrast

Class implementing the Contrast interface

count_df

data.frame with subject_Id + count column

count_column

name of the count column in count_df

loess_span

span parameter for LOESS fit

modelName

name of model

subject_Id

columns with subject_Id (proteinID)

p.adjust

function to adjust p-values

Methods

Inherited methods


Method new()

initialize

Usage

ContrastsModeratedDEqMS$new(
  Contrast,
  count_df,
  count_column,
  loess_span = 0.75,
  modelName = paste0(Contrast$modelName, "_DEqMS"),
  p.adjust = prolfqua::adjust_p_values
)

Arguments

Contrast

class implementing the ContrastInterface

count_df

data.frame with subject_Id columns and a count column

count_column

name of the count column in count_df

loess_span

span for LOESS variance fit (default 0.75)

modelName

name of the model

p.adjust

function to adjust p-values - default BH


Method get_contrast_sides()

get both sides of contrasts

Usage

ContrastsModeratedDEqMS$get_contrast_sides()


Method get_linfct()

get linear functions from contrasts

Usage

ContrastsModeratedDEqMS$get_linfct(global = TRUE)

Arguments

global

logical TRUE - get linear functions for all models


Method get_contrasts()

applies DEqMS-style count-dependent moderation

Usage

ContrastsModeratedDEqMS$get_contrasts(all = FALSE)

Arguments

all

should all columns be returned (default FALSE)


Method get_Plotter()

get ContrastsPlotter

Usage

ContrastsModeratedDEqMS$get_Plotter(FCthreshold = 1, FDRthreshold = 0.1)

Arguments

FCthreshold

fold change threshold to show in plots

FDRthreshold

FDR threshold to show in plots


Method to_wide()

convert to wide format

Usage

ContrastsModeratedDEqMS$to_wide(columns = c("p.value", "FDR", "statistic"))

Arguments

columns

value column default p.value, FDR, statistic

Returns

data.frame


Method clone()

The objects of this class are cloneable with this method.

Usage

ContrastsModeratedDEqMS$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


istar <- sim_lfq_data_protein_config(Nprot = 50)
#> creating sampleName from fileName column
#> completing cases
#> completing cases done
#> setup done
protIntensity <- istar$data
config <- istar$config

lProt <- LFQData$new(protIntensity, config)
lProt$rename_response("transformedIntensity")
modelFunction <-
  strategy_lm("transformedIntensity ~ group_")
mod <- build_model(
 lProt,
 modelFunction)
#> Joining with `by = join_by(protein_Id)`

Contr <- c("dil.b_vs_a" = "group_A - group_Ctrl")
contrast <- prolfqua::Contrasts$new(mod, Contr)

# Build count_df from config
count_df <- dplyr::select(protIntensity,
  dplyr::all_of(c(config$hierarchy_keys_depth(), "nr_peptides"))) |>
  dplyr::distinct()

deqms <- ContrastsModeratedDEqMS$new(contrast,
  count_df = count_df,
  count_column = "nr_peptides")

bb <- deqms$get_contrasts()
#> determine linear functions:
#> Warning: Warn 'linfct_matrix_contrasts':In argument: `dil.b_vs_a = group_A - group_Ctrl`.
#> Warning: Warn 'linfct_matrix_contrasts':In argument: `avg_dil.b_vs_a = (group_A + group_Ctrl)/2`.
#> get_contrasts -> contrasts_linfct
#> contrasts_linfct
#> Joining with `by = join_by(protein_Id, contrast)`
#> Warning: pseudoinverse used at 1
#> Warning: neighborhood radius 1
#> Warning: reciprocal condition number  2.362e-17
stopifnot(all(c("diff", "p.value", "FDR", "sigma") %in% colnames(bb)))

# Merge with ContrastsMissing
csi <- ContrastsMissing$new(lProt, contrasts = Contr)
merged <- merge_contrasts_results(deqms, csi)
#> Warning: pseudoinverse used at 1
#> Warning: neighborhood radius 1
#> Warning: reciprocal condition number  2.362e-17
#> completing cases
#> dil.b_vs_a=group_A - group_Ctrl
#> dil.b_vs_a=group_A - group_Ctrl
#> dil.b_vs_a=group_A - group_Ctrl
#> Joining with `by = join_by(protein_Id, contrast)`
#> Joining with `by = join_by(protein_Id, contrast)`

cs <- deqms$get_contrast_sides()
cslf <- deqms$get_linfct()
ctrwide <- deqms$to_wide()
#> Warning: pseudoinverse used at 1
#> Warning: neighborhood radius 1
#> Warning: reciprocal condition number  2.362e-17
cp <- deqms$get_Plotter()
#> Warning: pseudoinverse used at 1
#> Warning: neighborhood radius 1
#> Warning: reciprocal condition number  2.362e-17
cp$volcano()
#> $FDR

#>