I'm analyzing a 2^3 factorial design with replication with edgeR
and am fitting cell means models to test differences in treatment means and also fitting factor levels models to test main effects and interactions. I am finding that results for the tests for zero main effects give the exact same results as certain tests for the equality of two treatment means. This does not make sense to me and I can't find a mistake in my code. A reproducible example follows.
library(edgeR) n <- 10000 samps <- c("cca1","cca2","cca3","cca4","cca5","cca6","cpa1","cpa2","cpa3","cpa4", "cpa5","cpa6","fca1","fca2","fca3","fca4","fca5","fca6","fpa1","fpa2", "fpa3","fpa4","fpa5","fpa6","ccs1","ccs2","ccs3","ccs4","ccs5","ccs6", "cps1","cps2","cps3","cps4","cps5","cps6","fcs1","fcs2","fcs3","fcs4", "fcs5","fcs6","fps1","fps2","fps3","fps4","fps5","fps6") n.chips <- length(samps) r.counts <- matrix(rpois(n*n.chips, 10), n, n.chips) colnames(r.counts) <- samps f1 <- factor(substr(colnames(r.counts), 1, 1)) f2 <- factor(substr(colnames(r.counts), 2, 2)) f3 <- factor(substr(colnames(r.counts), 3, 3)) f3 <- relevel(f3, "s") group <- factor(paste(f1, f2, f3, sep = ".")) design.cm <- model.matrix(~0+group) # cell means model design.fl <- model.matrix(~f1*f2*f3) # factor levels model, dat.new <- DGEList(counts=r.counts, group=group) dat.new <- calcNormFactors(dat.new, method = "RLE") dat.cm <- estimateGLMCommonDisp(dat.new, design.cm, verbose=TRUE) dat.fl <- estimateGLMCommonDisp(dat.new, design.fl, verbose=TRUE) fit.cm <- glmFit(dat.cm, design.cm) fit.fl <- glmFit(dat.fl, design.fl) colnames(fit.cm$coef) colnames(fit.fl$coef) lrt.cm <- glmLRT(fit.cm, contrast = c(1, -1, 0, 0, 0, 0, 0, 0)) lrt.fl <- glmLRT(fit.fl, coef = 4) all.equal(lrt.cm$table, lrt.fl$table) lrt.cm <- glmLRT(fit.cm, contrast = c(0, -1, 0, 1, 0, 0, 0, 0)) lrt.fl <- glmLRT(fit.fl, coef = 3) all.equal(lrt.cm$table, lrt.fl$table) lrt.cm <- glmLRT(fit.cm, contrast = c(0, -1, 0, 0, 0, 1, 0, 0)) lrt.fl <- glmLRT(fit.fl, coef = 2) all.equal(lrt.cm$table, lrt.fl$table)
Can someone explain why this is happening?