I have an experiment where I have two groups (control and disease). In my control group, n=5 and for the disease group, n=10. Within each group I have measures over time (0, 24, and 48) and so n=15 for control and n=30 for disease. I am trying to design a design matrix in edgeR to test for change over time in each group (C0 vs C24, C0 vs C48, and C24 vs C48 and the same for disease group), and change at each timepoint between the two groups (C0 vs D0, C24 vs D24 and C48 vs D48).

My current code is:

```
grouping <- experiment_info$time_group
grouping <- factor(grouping) # the levels of groups for e.g. C0, D0, C24, D24
patient <- experiment_info$patient_id # adjust for patient differences
patient <- factor(patient)
design <- model.matrix(~0 + grouping + patient)
design <- design[,-20] # not a full rank
#where design headings are:
[1] "groupingControl_0" "groupingControl_24" "groupingControl_48" "groupingDisease_0" "groupingDisease_24"
[6] "groupingDisease_48" "patient75" "patient79" "patient80" "patient82"
[11] "patient84" "patient100" "patient101" "patient115" "patient116"
[16] "patient124" "patient133" "patient135" "patient152"
```

I then make contrasts between my groups of interest

```
# n.b. contrasts are made using the diffcyt package but works the same way as used in edgeR - my question is directed at the method rather than the packages used
contrast1 <- createContrast(c(-1,1,0,0,0,0,rep(0,13))) #C0-C24
contrast2 <- createContrast(c(-1,0,1,0,0,0,rep(0,13))) #C0-C48
contrast3 <- createContrast(c(0,-1,1,0,0,0,rep(0,13))) #C24-C48
contrast4 <- createContrast(c(0,0,0,-1,1,0,rep(0,13))) #D0-D24
contrast5 <- createContrast(c(0,0,0,-1,0,1,rep(0,13))) #D0-D48
contrast6 <- createContrast(c(0,0,0,0,-1,1,rep(0,13))) #D24-D48
```

This works fine for within group comparisons, but how do I make between group comparisons? Is it find to continue making contrasts using this model design even though the between group comparisons (n=30 and n=15) are not paired? or does the model account for this?

For example:

```
contrast7 <- createContrast(c(1,0,0,-1,0,0,rep(0,13))) #C0-D0
```

Or do I need to build a new model without the patient blocking?

Thanks in advance

Thank you very much, very clear and I understand everything now! :)