tavareshugo / tutorial_DESeq2_contrasts

54 stars 14 forks source link

inconsistent contrast results #1

Closed jasminetat closed 2 years ago

jasminetat commented 2 years ago

Hi Hugo,

Thanks so much for this tutorial, it has been extremely helpful!

I'm following the code and noticed that the methods used to contrast linear combinations (pink vs white) from the nested design are inconsistent. The log2FC from below res1 / res2 comparisons are not the same.

The res1 method using the model matrix vectors is more intuitive for me, but I couldn't tell if the equivalent contrast in res2 method is correct. Could you please check this and explain the differences?

Thank you!

Pink vs White (in the shade):

res1_pink_white_shade <- results(dds, contrast = pink_shade - white_shade)

or equivalently

res2_pink_white_shade <- results(dds, contrast = list(c("species_B_vs_A"), c("species_C_vs_A", "species_D_vs_A")))

Pink vs White (in the sun):

res1_pink_white_sun <- results(dds, contrast = pink_sun - white_sun)

or equivalently

res2_pink_white_sun <- results(dds, contrast = list(c("species_B_vs_A", "speciesB.conditionsun"), c("species_C_vs_A", "species_D_vs_A", "speciesC.conditionsun", "speciesD.conditionsun")))

`

tavareshugo commented 2 years ago

Dear @jatatucsd, thank you so much for opening this issue!

You are absolutely right, I had a mistake (actually two mistakes) in the code I was using with the named coefficients:

With those two fixes (which I've pushed to the repo), the results are now identical between the two approaches, which you can check with similar plots as I was doing for earlier sections, for example:

plot(res1_pink_white_sun$log2FoldChange, res2_pink_white_sun$log2FoldChange)
abline(0, 1)