Making sense out of makeContrasts and using coefficents for contrasts
1
0
Entering edit mode
Maiv • 0
@maiv-13337
Last seen 5.1 years ago
Norway

Hi,

I've been trying to redo a contrast using makeContrasts. The contrast was originally made using the coefficients, but I realized I did not really understand what it actually was doing, however I've been unable to recreate the results using the makeContrasts command.

design <- model.matrix(~0+targets$group, data=y$samples)
y <- estimateDisp(y,design,robust=TRUE)
fit <- glmQLFit(y, design,robust=TRUE)

colnames(fit)
[1] "T1.LD.FW"   "T2.LD.FW"   "T2.SP.FW"   "T3.LD.FW"   "T3.SP.FW"   "T4.LD.FW"   "T4.SP.FW"   "T4.SPLD.FW"
[9] "T5.LD.FW"   "T5.SP.FW"   "T5.SPLD.FW" "T6.LD.FW"   "T6.SP.FW"   "T6.SPLD.FW"

SPLLvsLL <- glmQLFTest(fit, contrast = c(0,0,0,0,0,-1,0,1,-1,0,1,-1,0,1))

Originally I thought it would work like the example in 3.3.1 in the user guide, with contrast=c(-1,0,1,1,0,-1) being equivalent to the the DrugvsPlacebo.2h contrast, but writing it out as

t<- makeContrasts (SPLDvsLD = (T6.SPLD.FW-T6.LD.FW) - (T5.SPLD.FW-T5.LD.FW) - (T4.SPLD.FW-T4.LD.FW), levels=design)

is not providing the same results. So I guess there's something I do not understand/a point that I'm missing. I've also tried some other 'creative' ways of writing this out without getting to the same results. I noticed that the signs for the placebo-coefficients are opposite to the drugs in the example of 3.3.1?

T1, T2, T3, T4, T5, T6 refers to timepoints for the sampling throughout the experiment, and LD, SP, SPLD refers to the treatments. The FW component is not relevant, it refers to one out of two conditions in the original experiment, but I'm just interested in the differences between treatments over time in the FW-condition. I realize that I might be better of running pairwise comparisons between treatments for each timepoint, but in any case I would like to gain some understanding of the above as well.

I'd much appreciate it if anyone has the time to clarify this for me,

Maiv :)

edger contrasts • 1.1k views
ADD COMMENT
0
Entering edit mode

What hypothesis are you attempting to test with this contrast? We can't tell you if your contrast is testing what you want to test unless you say what you want to test.

In any case, the contrast you have written appears to be subtracting two terms from one term, which usually yields a nonsense contrast.

ADD REPLY
0
Entering edit mode

Thanks for replying, I suspected that it might be the case that it was a nonsense contrast since I could not redo it using make contrast.

ADD REPLY
0
Entering edit mode

Quick follow-up question to check my understanding; would

t<-(T6.SPLD.FW-T6.LD.FW) - ((T5.SPLD.FW-T5.SP) + (T4.SPLD.FW-T4.LD.FW)) / 2

produce an output of genes that are responding to SPLD condition at T6, but not at T5 and T4?

ADD REPLY
0
Entering edit mode

I'll assume you meant T5.LD.FW instead of T5.SP. If so, you are testing the T6 difference against the mean of the T5 and T4 differences. That's not quite the same as what you're after. In any case, I find that these "difference of differences" contrasts are difficult to interpret without the context of the individual differences. For instance, a significant p-value in the above contrast could indicate that the gene is changing at T6 but not at T5 and T4, or vice versa. Or there could be changes at all time points, but in different directions.

ADD REPLY
2
Entering edit mode
@gordon-smyth
Last seen 54 minutes ago
WEHI, Melbourne, Australia

You are trying to combine separate contrasts into one contrast, but that can't be done. You do have to keep all the separate comparisons between treatments at each time-point as separate contrasts. So you need:

con<- makeContrasts(
    T6SPLDvsLD = T6.SPLD.FW - T6.LD.FW,
    T5SPLDvsLD = T5.SPLD.FW - T5.LD.FW,
    T4SPLDvsLD = T4.SPLD.FW - T4.LD.FW, levels=design)

and so on.

You can test all the contrasts together using one F-test if you wish, by passing the whole matrix of contrasts to glmQLFTest, but you do have to make a contrast column for each comparison. You cannot combine them all into one contrast column.

To test for a SPLD vs LD difference at any of the three times just use

glmQLFTest(fit, contrast = con)

It's the same as Aaron was trying to explain to you a couple of years ago for a different set of contrasts: https://support.bioconductor.org/p/97438/

ADD COMMENT
0
Entering edit mode

Hi, thank you for replying. Yes, I've been running analyses based on Aarons answer, which was very helpful. I've not worked on the dataset in quite some time, but picking it up again I wanted to try to understand more about the different approaches outlined in the User's Guide, so I have been trying to do some different stuff. I just was unsure about my understanding of section 3.3.1, even after reading several of the other posts about it. I'll stick to Aarons and your advice for anything that will be used downstream.

ADD REPLY

Login before adding your answer.

Traffic: 749 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