question about two factor makeContrasts
0
0
Entering edit mode
6.9 years ago
mforde84 ★ 1.4k

Hi,

I have a linear model:

model <- model.matrix(~0 + SNF + CRS)

Both factors are categorical, where SNF has 3 levels (1, 2, or 3), and CRS has 2 levels (high or low)

Initially we were interested in comparing each SNF group against the others using the planned contrasts:

contrasts <- makeContrasts(
    SNF1 - (SNF2 + SNF3) / 2, 
    SNF2 - (SNF1 + SNF3) / 2, 
    SNF3 - (SNF1 + SNF2) / 2, 
    levels=model)

Now we want to add the second factor of CRS so that we can compare the group differences within and between CRS for SNF. I'm having some conceptual difficulties determining the right contrast formula.

E.g., we want to compare say SNF1&high VS SNF1&low.

Would this be equal to?: (SNF1 + CRS_high) - (SNF1 + CRS_low)

For between comparisons, E.g., we want to perfom the planned contrasts as listed above but for either high or low CRS, separately.

This I'm not even sure how to form, and I'm confused on how I would tell makeContrast to effectively subset the data in this contrast.

R edgeR linear model • 2.5k views
ADD COMMENT
0
Entering edit mode

Ah I think I see, I have to specify an interaction, like so:

model <- model.matrix(~0 + SNF + CRS + SNF:CRS)

contrasts <- makeContrasts(
    SNF1:CRS_high - SNF1:CRS_low,
    SNF1:CRS_high - (SNF2:CRS_high + SNF3:CRS_high) / 2
    ... 
    levels=model)
ADD REPLY
0
Entering edit mode

Just want to confirm, is this accurate?

ADD REPLY
0
Entering edit mode

Eh, it doesn't look right. For some reason, model.matrix is omitting two of the interactions for SNF1:

 > colnames(group.intercepts)
    [1] "snf1"         "snf2"         "snf3"         "crsHigh"        
    [5] "crsLow"          "snf2:crsHigh" "snf3:crsHigh" "snf2:crsLow" 
    [9] "snf3:crsLow"

Whereas it should include both snf1:crsHigh and snf1:crsLow.

ADD REPLY

Login before adding your answer.

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