I have questions about the use of numeric contrast and lfcshrink.
I set up the dds object using:
dds <- DESeqDataSetFromMatrix(countData = counts, colData = metadata, ~ Sex + genotype * treatment)
Model matrix was calculated using:
mod_mat <- model.matrix(design(dds, data = colData(dds))
Model matrix first line and last line show:
I defined my numeric contrasts and comparison as follows:
define_contrasts <- function() {
wt_igg <- c(1, 0, 0, 0, 0)
ko_igg <- c(1, 0, 1, 0, 0)
wt_pltd <- c(1, 0, 0, 1, 0)
ko_pltd <- c(1, 0, 1, 1, 1)
list(
contrast_igg = ko_igg - wt_igg,
contrast_pltd = ko_pltd - wt_pltd,
contrast_wt = wt_pltd - wt_igg,
contrast_ko = ko_pltd - ko_igg,
twoway_treatment = (ko_pltd - wt_pltd) - (ko_igg - wt_igg),
twoway_genotype = (ko_pltd - ko_igg) - (wt_pltd - wt_igg)
)
}; all_contrasts <- define_contrasts()
I extracted the results (using specific numeric contrast comparison) and performed lfcshrink using ashr method as it allows for the use of numeric contrasts.
for (contrast_name in names(all_contrasts)) {
contrast_vector <- all_contrasts[[contrast_name]]
res <- results(dds, contrast = contrast_vector, alpha = 0.05)
res <- lfcShrink(dds, contrast = contrast_vector, res = res, type = "ashr")}
My questions are:
- Based on my design formula, shall I set the coef for Sex at 0 if my goal is to remove the effect of sex/gender on my datasets? I'm asking cause I realize that F was ref level and I wasn't sure if setting coef for Sex at 0 is the right way to remove effect of sex/gender.
- Do the numeric contrast subtractions make sense logically?
- I choose ashr method for lfcshrink because it allows for the use of numeric contrasts and also because in some comparisons there are >1 coef 'in use' and apeglm only allows for the use of a single coef for lfcshrink. Did I understand these correctly?
Apologies in advance if many questions seem very naive as I am learning these on my own using online resources to try to analyse my scrna-seq data and I don't have much experiences/