I want to get the difference of differences from a limma voom analysis. In a simplified example, I have 3 genotypes: Parent1, Parent2 and the Hybrid (of the two parents). For this example, I want to find whether the Hybrid expression is closer to the expression level of Parent1 or Parent2 (or equally close to both parents). In the analysis, we already compare both parents to the Hybrid in individual contrasts.
y <- DGEList(countdata)
y <- calcNormFactors(y)
design <- model.matrix(~ 0 + sampleinfo$Genotype + sampleinfo$REP.BAT)
v <- voomWithQualityWeights(y,design)
fit <- lmFit(v, design)
makeContrasts(Parent1-Hybrid, Parent2-Hybrid, levels=design)->mat.a
fit.a <- contrasts.fit(fit, mat.a)
fit.a <- eBayes(fit.a)
fit.treat.a <- treat(fit.a)
By subtracting the absolute values of the coefficients from those contrasts, we should get the difference of differences. What I am looking for, is to get the corresponding statistical test for these results.
abs(fit.treat.a[["coefficients"]][,1])-abs(fit.treat.a[["coefficients"]][,2])
Is there a way, to also extract the corresponding standard deviation and calculate the corresponding t-tests? Or is there a way, to build a contrast directly, that compares the difference of Parent1vsHybrid and Parent2vsHybrid directly?
makeContrasts((Parent1-Hybrid) - (Parent2-Hybrid), levels=design)->mat.a
Like this, but it the Hybrid is being cut out in this formulation, resulting in Parent1-Parent2, which is not what I want.
Thank you for the clarification. We did the comparisons you suggested, and have an idea which parent the Hybrid is closer to, where the expression in the Hybrid is only significantly different from one of the two parents. In cases of genes, where the expression is Parent1<Hybrid<Parent2, our impression is, that the distance to Parent2 is smaller than to Parent1. By also comparing the average of both parents to the hybrid in combination with the Parent1vsParent2 results, we should be able to check that impression at least for some genes.
If the Hybrid expression is higher than the average of Parent1+Parent2 and the Parent2 expression is higher than Parent1, then the Hybrid expression must be closer to Parent2 (for Parent1<Hybrid<Parent2).