Comparing one group against multiple groups in DESeq2
2
0
Entering edit mode
tamivico • 0
@423e3e30
Last seen 7 months ago
Germany

Hi! I am running a DESeq2 analysis in where I have 24 groups (A-W). In order to get the "unique" DEG from each group, I would like to compare a specific group against all the rest (e.g. A vs B-W). I tried to use the contrast tools but I kept getting this error.

dds <-DESeqDataSetFromMatrix(countData = counts, colData = coldata, design = ~ group_time) res <- results(dds, contrast = list (c("A"), c("B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X")), listValues = c(1,-1/23) )

Error in checkContrast(contrast, resNames) : all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)'

Which are: "group_time_B_vs_A" "group_time_C_vs_A" "group_time_D_vs_A" "group_time_E_vs_A" "group_time_F_vs_A" [7] "group_time_G_vs_A" "group_time_H_vs_A" "group_time_I_vs_A" "group_time_J_vs_A" "group_time_K_vs_A" "group_time_L_vs_A" [13] "group_time_M_vs_A" "group_time_N_vs_A" "group_time_O_vs_A" "group_time_P_vs_A" "group_time_Q_vs_A" "group_time_R_vs_A" [19] "group_time_S_vs_A" "group_time_T_vs_A" "group_time_U_vs_A" "group_time_V_vs_A" "group_time_W_vs_A" "group_time_X_vs_A"

And then I don't know how to proceed. Thank you in advance for your help!

DESeq2 • 660 views
ADD COMMENT
2
Entering edit mode
swbarnes2 ★ 1.4k
@swbarnes2-14086
Last seen 7 hours ago
San Diego

Another way you could do this is to make a new column in colData, with only two values, "A" and "notA". It will be slightly different from the list way, but it's probably easier to handle.

ADD COMMENT
0
Entering edit mode
@92df89d4
Last seen 5 weeks ago
Leuven, Belgium

As mentioned in the error, you need to use a combination of the elements in resultsNames(dds) for the contrast-list syntax to work. In your case, since in the end you are interested in the average of the log2 fold changes between A and all other conditions (let's call this res), you have:

res = (1/23) x [log2(A/B) + log2(A/C) + ... + log2(A/X)] = - (1/23) x [log2(B/A) + log2(C/A) + ... + log2(X/A)] = (-1/23) x log2(B/A) + (-1/23) x log2(C/A) + ... + (-1/23) x log2(X/A)

where the minus sign comes from the fact that log2(1/X) = - log2(X). On the expression on the far right, each of the log2(Other/A) terms (where Other = B, C, ..., X) is given directly by each of your 23 coefficients "group_time_B_vs_A", "group_time_C_vs_A", ..., "group_time_X_vs_A", and all these 23 coefficients appear multiplied times (-1/23), therefore the following will give you what you are looking for using a numeric-contrast approach:

dds <-DESeqDataSetFromMatrix(countData = counts, colData = coldata, design = ~ group_time)
res <- results(dds, contrast = c(0,rep(-1/23, times = 23)))

where the 0 at the beginning of the numeric-contrast vector comes from the fact that, with the design you are using (~group_time), you should in fact get a total of 24 coefficients from resultsNames(dds), the first of them being an "Intercept" (representing the mean of the reference condition A). Note that you could have also used a design without intercept (i.e., ~0+group_time or ~group_time-1), in which case your 24 resultsNames(dds) terms would have been "group_timeA", "group_timeB", "group_timeC", ..., "group_timeX".With this design, your numeric contrast of interest would pretty much resemble the expression you were trying to use with the contrast-list approach (note the 1 instead of 0 in the first component of contrast, and note too that in this case you could also use the contrast-list syntax, but it will be much harder to read due to the fact that you have a lot of groups):

dds <-DESeqDataSetFromMatrix(countData = counts, colData = coldata, design = ~ 0 + group_time)
res <- results(dds, contrast = c(1,rep(-1/23, times = 23)))
ADD COMMENT

Login before adding your answer.

Traffic: 620 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6