I am currently performing a differential gene expression analysis containing 1000s of samples. The samples have 3 different genotypes and were treated either with A
or B
, so the meta data looks something like this:
# this is an example subset
mdata <- data.frame(condition=rep(c("A","B"),each=3, 3),
genotype=rep(c("I","II","III"),each=6))
mdata <- mdata %>% mutate(type=paste(genotype, condition,sep="_"))
I understand, that when running the differential expression, an appropriate design would look something like this (i am excluding all batch effects for simplicity):
~ 0 + genotype + condition + genotype:condition
However, I usually find interactions a bit more challenging to interpret and also sometimes have a difficult time extracting the right comparisions using results
from DESeq2
, so instead I like to do what was suggested by the DESeq2 vignette to use a grouping variable (called type
in my case), which means my design looks very simple ~ 0+type
.
After running DESeq2 (by calling DESeq()
), I want to answer the following question:
Does the condition (A or B) have different effects depending on the genotype (for example genotype III vs genotype I).
So my first question is, if this is equivalent of asking "is the interaction term genotypeII.conditionB
significantly different from genotypeIII.conditionB
?.
Also, is it correct that to extract this comparisions I would run
res_interaction <- results(dds_interaction_term, contrast=list("genotypeIII.conditionB", "genotypeII.conditionB"))
As I mentioned before, I usually like to use a grouping variable. Is it correct to use the following contrast to answer my question from above:
# create the contrast matrix for the combined object
design <- model.matrix(~ 0+type, colData(dds_combined))
contrasts <- limma::makeContrasts(
interaction= (typeIII_B - typeIII_A) - (typeII_B - typeII_A),
levels = design
)
res_comb <- results(dds_combined, contrast = contrasts[,1])
Any insights are very much appreciated!
Cheers!
Yes, asking, 'is term X different than term Z' can be extracted with
results(dds, contrast=list("X", "Z"))