I have a design matrix for my data as below. I run command for analyzing and comparing different groups together but get error.
I would like to have these comparisons: L4vsL6.L8 , Q3vsQ5.Q7, QvsL
design matrix:
> design
organoids_biological_samples method
L4_D49_rep_1 L4 L
L4_D49_rep_2 L4 L
L6_L8_D49_rep_1 L6_L8 L
L6_L8_D49_rep_2 L6_L8 L
Q3_D49_rep_1 Q3 Q
Q3_D49_rep_2 Q3 Q
Q5_Q7_D49_rep_1 Q5_Q7 Q
Q5_Q7_D49_rep_2 Q5_Q7 Q
> design$organoids_biological_samples <- factor(design$organoids_biological_samples, levels = c("L4","L6_L8", "Q3", "Q5_Q7"))
> design$method <- factor(design$method, levels = c("L", "Q"))
> all(rownames(design) %in% colnames(data))
> all(rownames(design) == colnames(data))
> Group <- factor(paste(design$organoids_biological_samples,design$method,sep="."))
> design<- cbind(design,Group)
> design.matrix <- model.matrix(~0+Group+method,design)
> colnames(design.matrix) <- c("L4.L", "L6_L8.L", "Q3.Q", "Q5_Q7.Q", "method")
> design.matrix
L4.L L6_L8.L Q3.Q Q5_Q7.Q method
L4_D49_rep_1 1 0 0 0 0
L4_D49_rep_2 1 0 0 0 0
L6_L8_D49_rep_1 0 1 0 0 0
L6_L8_D49_rep_2 0 1 0 0 0
Q3_D49_rep_1 0 0 1 0 1
Q3_D49_rep_2 0 0 1 0 1
Q5_Q7_D49_rep_1 0 0 0 1 1
Q5_Q7_D49_rep_2 0 0 0 1 1
attr(,"assign")
[1] 1 1 1 1 2
attr(,"contrasts")
attr(,"contrasts")$Group
[1] "contr.treatment"
attr(,"contrasts")$method
[1] "contr.treatment"
> edgeR.dgelist = DGEList(counts = data,group = Group)
> edgeR.dgelist = calcNormFactors(edgeR.dgelist,method = "TMM")
> CommonDisp <- estimateGLMCommonDisp(edgeR.dgelist, design.matrix)
Error in glmFit.default(y, design = design, dispersion = dispersion, offset = offset, :
Design matrix not of full rank. The following coefficients not estimable:
method