**190**wrote:

Dear all,

I need your advice in designing contrast and design matrices for use in *limma*.

My study consists of 2 groups that are followed longitudinally at three time points (repeated measures):

- Group has 2 factors, i.e. groupA and groupB.
- Timepoint has 3 factors, i.e. t0, t1, and t2.

After browsing the user guide and the Bioc forum, I understand that I can combine my Group and Timepoint variables into one variable:

```
group_time <- paste(Group, Timepoint, sep="_")
```

Thus, for the group_time variable, I have 6 factors: groupA_t0, groupA_t1, groupA_t2, groupB_t0, and so on. And then I make my design matrix in the following way:

```
design1 <- model.matrix(~ 0+ group_time)
```

I am interested to see the changes between the time points within each of the groups. Therefore, I formulate my contrast matrix in such a way:

```
t0t1_inGroupA = groupA_t0 - groupAt1,
t0t2_inGroupA = groupA_t0 - groupAt2,
t0t1_inGroupB = groupB_t0 - groupBt1,
t0t2_inGroupB = groupB_t0 - groupBt2,
levels=design
```

I really love this way because of its sheer simplicity!

I showed this method of making design and contrast matrices to a statistician colleague and he insisted to alter my design matrix to:

```
design2 <- model.matrix(~ Group * Timepoint).
```

He stated that design2 is way better because now it incorporates an interaction term between my Group and Timepoint variable. But then now I am having a hard time to create a contrast matrix to do the same comparison as the above.

My question is, would there be any difference between the results? From what I understand, contrast matrix is simply a way to 'switch on and off' which samples that I want to compare. For now, I cannot really know because I still haven't succeeded in making the appropriate contrast matrix for the new design matrix.

Thank you for your advice.

Best regards,

Mikhael

**51k**• written 12 months ago by mikhael.manurung •

**190**