Design formula, numeric contrast, and lfcshrink in deseq2
Entering edit mode
hx ▴ 10
Last seen 25 days ago
United Kingdom

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: enter image description here

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)

    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:

  1. 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.
  2. Do the numeric contrast subtractions make sense logically?
  3. 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/

DESeq2 • 296 views
Entering edit mode
Last seen 21 hours ago
United States

For questions about how to construct the correct contrasts correspond to particular hypotheses, I recommend consulting with a local statistician or someone familiar with linear models in R. The way DESeq2 and lfcShrink work is the same for any linear model built in R.


Login before adding your answer.

Traffic: 1011 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6