Hi all,
I am struggling to make a contrast with EdgeR.

    design <- model.matrix(~Gender + Age + Group, data = patient.table)

The (disease) Group is a factor with [Control, Mild, Severe]. I want to compare C-M. M-S and C-S. Thus s i

    DGEL <- edgeR::DGEList(expressionData)
    keep <- edgeR::filterByExpr(DGEL)
    DGEL <- DGEL[keep, , keep.lib.sizes=FALSE]
    DGEL <- edgeR::calcNormFactors(DGEL, method = "TMM")
    
    DGEL <- edgeR::estimateDisp(DGEL, design)
    fit  <- edgeR::glmQLFit(DGEL, design)
    
    contrasts <- makeContrasts(c.vs.m  = GroupC - GroupM,
                               m.vs.s  = GroupM - GroupS,
                               c.vs.s  = GroupC - GroupS,
                               levels  = design)

However, there is no GroupC in the model matrix. There is only an Intercept, GroupM and GroupS. How can I compare anything against the control group on a full-rank design matrix.

I already searched in the user manual and here on the website, but could not find it. Also, I tried

    design <- model.matrix(~Gender + Age + Group,
        data = patient.table,
        contrasts.arg = list(
          Group = contrasts(patient.table$Group, contrasts = FALSE)
        )
      )

But edgeR did not like that and informed me that the table was not of full rank.
I am pretty sure this is something basic, but I just don't get it as a wet-lab worker.

Check [edgeR Users Guide][1], chapter 3.3, on how to define the contrasts for such a complex design. For me, the approach that works better (as in, it is easier to understand) is the one described in section 3.3.1. Start by creating a composite `group` variable:

    group <- factor( paste0( patient.table$Gender, paste0( patient.table$Age, patient.table$Group ) )

Then specify the design without an intercept, and create the contrasts of interest.

    design <- model.matrix( ~0 + group )
    colnames( design ) <- levels( group )
    contrasts <- makeContrasts( GenderM_Age0_GroupC_vs_M = GenderMAge0GroupC - GenderMAge0GroupM,
    # and so on for the other contrasts
                                levels=design)

To perform the tests:

    fit <- glmQLFit( DGEL, design )
    qlf <- glmQLFTest( fit, contrast = contrastss[ , "GenderM_Age0_GroupC_vs_M" ] )

This tests for **GroupC** vs **GroupM** differences within **GenderM** and **Age0**.

See https://www.biostars.org/p/453485/ for a recent similar post, you may find the answer there useful.

If you want more complex tests, such as any genes changing over all ages, read sections 3.3.3 and 3.3.4 from the guide.

  [1]: http://bioconductor.org/packages/3.12/bioc/vignettes/edgeR/inst/doc/edgeRUsersGuide.pdf