Hello all,

I have a question regarding batch effect correction with LIMMA. I have some proteomics data, and when I do my PCA plot I see that samples cluster by patient rather than my treatment (I have three samples per patient, each sample with a different treatment). For this reason I would like to include patient as a batch effect in my linear model (rather than use removebatcheffects because I then want to perform differential analysis with LIMMA).

My plan was to use the following:

```
design = model.matrix(~0+Patient+Treatment, data=metadata)
fit1 = lmFit(log2all.df.filter,design = design)
cont <- makeContrasts(TreatmentCombo-TreatmentControl, TreatmentCombo-TreatmentLipid, TreatmentLipid-TreatmentControl, levels = design)
fit2 = contrasts.fit(fit1,contrasts = cont)
fit3 <- eBayes(fit2)
```

This does work, however when I view my design instead of my five patients, there are only four listed in the design table.

Similarly if I change the order of the design to:

```
design = model.matrix(~0+Treatment+Patient, data=metadata)
```

and view the design, there are only two treatments included in the design instead of the three treatments that I have (so I can't proceed with my DE analysis).

Is anyone aware of a solution to this? Any help is much appreciated!

Many thanks, Sandra

For the benefit of future readers, let me note that your description of the two design matrices is actually reversed. The first design matrix will produce linear model coefficients for all the Patients while the second will produce coefficients for all the Treatments. When you use

`~0+`

to remove the intercept, the intercept can only be removed once, and this is always applied to the first factor in the model (Patient in the first case and Treatment in the second).A linear model only has one intercept to remove, no matter how many factors there are in the model, so it is only possible to expand out one of the factors when the intercept is removed.