Question: DESeq2: 5 Conditions (B vs C) vs (D vs B)
0
gravatar for Fischer-philipp
3 months ago by
Fischer-philipp20 wrote:

DESeq2: 5 Conditions (B vs C) vs (D vs B)

Consider a setup with 5 Conditions A-E, where E is the untreated condition and hence the reference label.

I want to know which genes are upregulated in B vs C but are downregulated in D vs B. All samples should be compared to E (the untreated condition).

coldata
        condition
    A_1 "A"      
    A_2 "A"      
    A_3 "A"      
    B_1 "B"      
    B_2 "B"      
    B_3 "B"      
    C_1 "C"      
    C_2 "C"      
    C_3 "C"      
    D_1 "D"      
    D_2 "D"      
    D_3 "D"      
    E_1 "E"      
    E_2 "E"      
    E_3 "E"

    dds_f <- DESeqDataSetFromMatrix(countData = data_f, 
                                    colData = coldata,
                                    design = ~ condition)

    dds_f$condition <- relevel(dds_f$condition, ref = "E")
    dds_f <- DESeq(dds_f)
    resultsNames(dds_f)

    [1] "Intercept"        "condition_A_vs_E" "condition_B_vs_E" "condition_C_vs_E" "condition_D_vs_E"

    upd <- results(dds_f, listValues = c(1, -1/2), 
                           contrast = list(c("condition_B_vs_E"), c("condition_C_vs_E", "condition_D_vs_E")))
    rn <- rownames(upd[!is.na(upd$padj) & upd$padj <= 0.05 & upd$log2FoldChange >= 1, ])

My questions are:

1.) I want to find genes which are downregulated in (condition_D_vs_E vs condition_B_vs_E) but upregulated in (condition_B_vs_E vs condition_C_vs_E)

2.) Is this the right comparison (condition_B_vs_E vs condition_C_vs_E) vs (condition_D_vs_E vs condition_B_vs_E)?

3.) Does the contrast I choose answer this question?

*2.) or does one has to interpret this contrast like this: On average condition_B_vs_E is smaller or higher than condition_C_vs_E and condition_D_vs_E? Meaning that it could happen that this could result in a positive log2 fold change even though the gene expression levels of condition_D_vs_E are actually higher than in condition_B_vs_E? Which is because of the average of condition_D_vs_E with condition_C_vs_E, which in this case contains very low expressed genes.

ADD COMMENTlink modified 3 months ago by Michael Love23k • written 3 months ago by Fischer-philipp20
Answer: DESeq2: 5 Conditions (B vs C) vs (D vs B)
1
gravatar for Michael Love
3 months ago by
Michael Love23k
United States
Michael Love23k wrote:

This comes up a few times on the support forum. Comparing X vs Y, with both compared to Z, is equivalent to X vs Y alone. The algebra on the log scale is:

(X - Z) - (Y - Z) = X - Y

DESeq2 can form the contrasts for you if you just do:

results(dds, contrast=c("condition","D","B"))

You don't have to bother with the list here.

If you want downregulated in D vs B but upregulated in B vs C, you should build two results tables, the first one for D vs B and the second one for B vs C, and then just take the intersection. You can specify altHypothesis="greaterAbs" or "lessAbs" to perform one sided testing.

ADD COMMENTlink modified 3 months ago • written 3 months ago by Michael Love23k

Thank you for your answer.

Just for confirmation: The code would be like this (with lfcThreshold = 0). And the results would just be a list.

m1 <- results(dds_f, contrast = c(0, 0, 1, -1, 0)) #B vs C
m2 <- results(dds_f, contrast = c(0, 0, -1, 0, 1)) #D vs B
rn.m1 <- rownames(m1)[m1$log2FoldChange >= 1 & m1$padj  <=  0.05 & !is.na(m1$padj)]
rn.m2 <- rownames(m2)[m2$log2FoldChange <= -1 & m2$padj  <=  0.05 & !is.na(m2$padj)]

un <- intersect(rn.m1, rn.m2)
head(un)
[1] "Klf6"   "Tbx2"   "Trim25" "Pparg"  "Slc5a5" "Ccl3"  

Is there also a way to compare resulting in a log2 fold change? Or am I getting something wrong?

Thank you in advance.

ADD REPLYlink modified 3 months ago • written 3 months ago by Fischer-philipp20

Sorry I mistyped above. To get a one sided test, above 1 or below -1, you should do lfcThreshold=1 and altHypothesis="greaterAbs" or altHypothesis="lessAbs". You can use a numeric contrast, but it's safer to use the code I had above, because it will always be correct even if you happened to relevel the variables.

You can intersect on the rownames and then index the two results objects with the rownames vector:

res[idx,]

ADD REPLYlink written 3 months ago by Michael Love23k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 106 users visited in the last hour