fgcz / prolfqua

Differential Expression Analysis tool box R lang package for omics data
https://pubs.acs.org/doi/pdf/10.1021/acs.jproteome.2c00441
MIT License
40 stars 7 forks source link

add moderated p.values #3

Closed wolski closed 5 years ago

wolski commented 5 years ago

Based on the discussion below, I understand that you have fitted the same linear model to a few hundred separate datasets (with each subject being a separate dataset). To apply limma empirical Bayes moderation you need to have three vectors storing information from the separate fits:

A vector sigma containing the residual standard errors from the separate fits. This vector is not obtainable from your data.frame. The residual standard error is the square root of the residual mean square and is shown in the output from summary(fit) for each linear model. If you save the summary to out <- summary(fit) then the residual standard error is stored as out$sigma.

A vector df.residual containing the residual degrees of freedom for each regression, which will not all be the same some of the fits have missing values. This will be the same as df in your data.frame.

A vector tstat containing the unmoderated t-statistics from the separate linear models. This will be the same as t-value in your data.frame.

Then you can compute moderated t-statistics and p-values by

sv <- squeezeVar(sigma^2, df=df.residual) moderated.t <- tstat sigma / sqrt(sv$var.post) df.total <- df.residual + sv$df.prior p.value <- 2pt( abs(moderated.t), df=df.total, lower.tail=FALSE)

wolski commented 5 years ago

This functionality is now added. moderated_p_limma moderated_p_limma_long