About interaction effect 2
2
0
Entering edit mode
zkwu2011 • 0
@zkwu2011-11723
Last seen 4.6 years ago

Dear Mike:

I am a newcomer of R. Let genotype: I II III and condition A B. If I considered interaction effect between genotype and condition by using a grouping variable, how can I extract the interaction term for condition effect in genotype II vs genotype I?

If I considered interaction effect by design ~ genotype+condition+genotype:condition, how can I compare subset with genotype I ,condition A and subset with genotype II, condition B?

sincerely

deseq2 • 576 views
ADD COMMENT
1
Entering edit mode
Bernd Klaus ▴ 590
@bernd-klaus-6281
Last seen 2.7 years ago
Germany

1.) "how can I extract the interaction term for condition effect in genotype II vs genotype I? "

If you use a "group" vector, you get the following coefficients:

library("DESeq2")
dds <- makeExampleDESeqDataSet(n=100,m=18)
dds$genotype <- factor(rep(rep(c("I","II","III"),each=3),2)) dds$group <- factor(paste0(dds$genotype, dds$condition))
design(dds) <- ~ group
dds <- DESeq(dds)

resultsNames(dds)

 "Intercept" "groupIA"   "groupIB"   "groupIIA"  "groupIIB"  "groupIIIA" "groupIIIB"

The interaction effect you want is the difference of the condition effect  between genotype II and I (An interaction is always a difference of differences), so you want the following contrast: (the intercept terms always cancel out as they are added to each of the group terms, so a group wise mean is always given by  terms like "Intercept" + "groupIA"; "Intercept" + "groupIB", etc., so I dropped them)

("groupIIB" - "groupIIA") - ("groupIB" - "groupIA")

= + "groupIA" - "groupIB" - "groupIIA" + "groupIIB"

which can be extracted using the contrast vector

c(0,1,-1,-1,1,0,0)

via

results(dds, contrast = c(0,1,-1,-1,1,0,0))

2.) "If I considered interaction effect by design ~ genotype+condition+genotype:condition, how can I compare subset with genotype I ,condition A and subset with genotype II, condition B? "

The resultsNames(dds)

in this case are:

dds <- makeExampleDESeqDataSet(n=100,m=18)
dds\$genotype <- factor(rep(rep(c("I","II","III"),each=3),2))
design(dds) <- ~ genotype + condition + genotype:condition
dds <- DESeq(dds)
resultsNames(dds)
 "Intercept"              "genotype_II_vs_I"       "genotype_III_vs_I"      "condition_B_vs_A"
 "genotypeII.conditionB"  "genotypeIII.conditionB"

The mean of AI is represented by the intercept term, while the mean of  BII is given by

the following sum of coefficients:

"Intercept" + "genotype_II_vs_I" + "condition_B_vs_A" + "genotypeII.conditionB"

so the contrast (B_II vs A_I) would be

"Intercept" + "genotype_II_vs_I" + "condition_B_vs_A" + "genotypeII.conditionB" - "Intercept"

= "genotype_II_vs_I" + "condition_B_vs_A" + "genotypeII.conditionB"

so the call would be

results(dds, contrast = c(0,1,0,1,1,0))

So you see that extracting group differences is rather complicated when using an interaction effect in the formula while extracting an interaction effect is complicated when using a grouping vector. (please double check my formulas carefully for errors ;).

So both types of formulas make your life easier in specific contexts, but are essentially equivalent.

Note however, that there will be no fold change shrinkage if you fit an interaction term, so the results will be different between the interaction based approach and the group-based approached as discussed in your other thread. (DESeq2 interaction term)

Bernd

ADD COMMENT
0
Entering edit mode
zkwu2011 • 0
@zkwu2011-11723
Last seen 4.6 years ago

Thanks Bernd for very detail answers. I understood it clearly.

ADD COMMENT

Login before adding your answer.

Traffic: 320 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.