Batch effect: Is it correct to put ~0 preparing the model.matrix to remove batch effect?
1
0
Entering edit mode
greta • 0
@4c8dd85f
Last seen 15 months ago
Italy

Hello,

I'm trying to remove batch effect from a dataset that include three experimental conditions (C_25,C_50,C_CTRL) and three batches (1,2,4). I prepared a table with all these information (targets) and then I tried to create a design matrix using ~0+group+batch in my model formula. I would like to know if this approach is correct or it's better to put ~batch+group. I tried also this last approach but I found some problems later setting the contrasts because one experimental condition didn't appear in the matrix (C_CTRL). For the following analysis I used makeContrasts, glmQLFit, glmQLFTest functions of EdgeR package. The code and the outputs are the following:

group <- factor(targets$CONDITION)
batch <- factor(targets$BATCH)
design <- model.matrix(~0+group+batch,data=log2.cpm.filtered.norm.df)
design
groupC_CTRL groupC_T25 groupC_T50 batch2 batch4
1               1              0              0                   0      1
2               1              0              0                   1      0
3               1              0              0                   0      0
4               0              0              1                   0      1
5               0              0              1                   1      0
6               0              0              1                   0      0
7               0              1              0                   0      1
8               0              1              0                   1      0
9               0              1              0                   0      0
attr(,"assign")
[1] 1 1 1 2 2
attr(,"contrasts")
attr(,"contrasts")$group
[1] "contr.treatment"

attr(,"contrasts")$batch
[1] "contr.treatment"

This is the other script and output:

group <- factor(targets$CONDITION)
batch <- factor(targets$BATCH)
design <- model.matrix(~batch+group,data=log2.cpm.filtered.norm.df)
design
 (Intercept) batch2 batch4 groupC_T25 groupC_T50
1           1      0      1       0           0
2           1      1      0       0           0
3           1      0      0       0           0
4           1      0      1       0           1
5           1      1      0       0           1
6           1      0      0       0           1
7           1      0      1       1           0
8           1      1      0       1           0
9           1      0      0       1           0
attr(,"assign")
[1] 0 1 1 2 2
attr(,"contrasts")
attr(,"contrasts")$batch
[1] "contr.treatment"

attr(,"contrasts")$group
[1] "contr.treatment"

The fact that in this last matrix two elements are missing (one batch and one experimental condition) does it mean that the function took these two as intercepts so I could consider groupC_T50 and groupC _T25 as contrasts? So later prepearing the contrast.matrix I could use the following script? Is it right? I think that anyway in this case there is a problem related to the direction of the contrast.. because I want C_T50 vs CTRL and not the opposite.

contrast.matrix <- makeContrasts(C_T50vsC_CTRL = groupC_T50  , 
                                 C_T25vsC_CTRL=groupC_T25,                          
                                 levels=design)

sessionInfo( ) R version 4.2.1 (2022-06-23 ucrt) Running under: Windows 10 x64 (build 22621)

Thanks in advance for your help

Greta

edgeR model.matrix BatchEffect • 1.0k views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 17 hours ago
United States

The only difference between the two models is that you need to specify a contrast in the call to glmQLFTest for the first model, whereas you need to specify the coefficient for the second. And you don't need to use makeContrasts for the second model since the coefficients are inherently the differences you care about.

ADD COMMENT

Login before adding your answer.

Traffic: 542 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6