# adjusting batch effect by multiple linear regression

I am analyzing rna-seq data in the format of counts. There is batch effect revealed by PCA.

One method I tried called RUVseq, it estimated the variation basing on control genes, and then added it to design matrix. I don't know why simply adding a continuous variable will work.

Here is an example, the experiment setting is:

samples groups
A      1
B      1
C      1
D      2
E      2
F      2
G      3
H      3
I      3


Then RUVseq methods could estimate the unwanted variation, for example,

B <- (-0.37670272 , 2.44136463, -0.79533912, -0.05487747,  0.25014132,  0.61824329 -0.17262350 ,-2.22390027, -1.26361438)


Then combine them together:

samples groups           B
A      1 -0.37670272
B      1  2.44136463
C      1 -0.79533912
D      2 -0.05487747
E      2  0.25014132
F      2  0.61824329
G      3 -0.17262350
H      3 -2.22390027
I      3 -1.26361438


Make a design matrix to fit glm, an example of design is

model.matrix( ~ 0 + groups + B)


My question is why this works? The coefficient of continuous variable means how many the read counts of genes will change of one unit of B changed, right? Then why B could be used for correcting the batch effect?