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

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", "statistic"))

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.

Examples

Nprot <- 120
istar <- prolfqua::sim_lfq_data_protein_config(Nprot = Nprot,weight_missing = .4)
#> creating sampleName from fileName column
#> completing cases
istar$data$abundance |> is.na() |> sum()
#> [1] 283
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()
#> # A tibble: 1 × 3
#>   contrast   group_1 group_2   
#>   <chr>      <chr>   <chr>     
#> 1 dil.b_vs_a group_A group_Ctrl

res <- csi$get_contrasts()
#> [1] "group_"
#> 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

stopifnot(nrow(res) ==  (protIntensity$protein_Id |> unique() |> length()))
res$contrast |> table()
#> 
#> dil.b_vs_a 
#>        120 
stopifnot((res$p.value |> is.na() |> sum()) == 0)
plot(res$diff, -log10(res$p.value), pch = ".")

csi$column_description()
#>           column_name
#> modelName   modelName
#> contrast     contrast
#> avgAbd         avgAbd
#> diff             diff
#> FDR               FDR
#> statistic   statistic
#> std.error   std.error
#> df                 df
#> p.value       p.value
#> conf.low     conf.low
#> conf.high   conf.high
#> sigma           sigma
#>                                                                                            description
#> modelName                                                                                type of model
#> contrast                                                      name of difference e.g. group1_vs_group2
#> avgAbd                                                  mean abundance value of protein in all samples
#> diff                                                                       difference among conditions
#> FDR                                                                               false discovery rate
#> statistic                                                                                 t-statistics
#> std.error                                                                               standard error
#> df                                                                                  degrees of freedom
#> p.value                                                                                        p-value
#> conf.low                                                         lower value of 95 confidence interval
#> conf.high                                                         high value of 95 confidence interval
#> sigma     residual standard deviation of linear model (needed for empirical Bayes variance shrinkage).
x<- csi$get_Plotter()
p <- x$volcano()
pdf(file = NULL)
print(p)
#> $p.value
#> 
#> $FDR
#> 
dev.off()
#> pdf 
#>   2 

dd <- prolfqua::sim_lfq_data_2Factor_config(Nprot = 100,weight_missing = 0.1)
#> creating sampleName from fileName column
#> completing cases

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()
#> [1] "Treatment"  "Background"
#> completing cases
#> [1] "Treatment"
#> completing cases
#> [1] "Background"
#> completing cases
#> c1=TreatmentA - TreatmentB
#> C2=BackgroundX- BackgroundZ
#> c3=`TreatmentA:BackgroundX` - `TreatmentA:BackgroundZ`
#> c4=`TreatmentB:BackgroundX` - `TreatmentB:BackgroundZ`
#> c1=TreatmentA - TreatmentB
#> C2=BackgroundX- BackgroundZ
#> c3=`TreatmentA:BackgroundX` - `TreatmentA:BackgroundZ`
#> c4=`TreatmentB:BackgroundX` - `TreatmentB:BackgroundZ`
#> c1=TreatmentA - TreatmentB
#> C2=BackgroundX- BackgroundZ
#> c3=`TreatmentA:BackgroundX` - `TreatmentA:BackgroundZ`
#> c4=`TreatmentB:BackgroundX` - `TreatmentB:BackgroundZ`
pl <- csi$get_Plotter()
pdf(file = NULL)
pl$volcano()
#> $p.value
#> 
#> $FDR
#> 
dev.off()
#> pdf 
#>   2