Question about making Contrasts for comparisons and assignment of values
1
0
Entering edit mode
@mohammedtoufiq91-17679
Last seen 14 days ago
United States

Hi,

I was making a contrasts using makeContrasts function for comparing groups in edgeR for differential expression analysis. I am comparing each group compared to it's baseline. Once the contrasts was created, it seems like the assignment of values (1 and -1) in the matrix is different. Ideally, Adjuvant samples should be labelled as 1 and it's respective Control samples should be -1. In the below case, it's the matrix output is different. Am I missing something or assigning differently? Perhaps, the results would be impacted due to this (especially, the direction of logFC)?

#>      Drug   Groups
#> S.1     A  Control
#> S.2     B  Control
#> S.3     C  Control
#> S.4     A  Control
#> S.5     B Adjuvant
#> S.6     C Adjuvant
#> S.7     A Adjuvant
#> S.8     B Adjuvant
#> S.9     C  Control
#> S.10    A  Control
#> S.11    B Adjuvant
#> S.12    C Adjuvant
#> S.13    A  Control
#> S.14    B  Control
#> S.15    C Adjuvant
#> S.16    A Adjuvant
#> S.17    B  Control
#> S.18    C Adjuvant

Drug.Groups <- paste(Sample_metadata$Drug, Sample_metadata$Groups, sep=".")
Drug.Groups <- factor(Drug.Groups, levels=c("B.Adjuvant", "B.Control", "C.Adjuvant", "C.Control",  "A.Adjuvant", "A.Control"))
design <- model.matrix(~0+Drug.Groups)
colnames(design) <- levels(Drug.Groups)
rownames(design) <- rownames(Sample_metadata)


Contrast.Drug.Groups <- makeContrasts(
  "A.Adj_vs_A.Con_VS_C.Adj_vs_C.Con" = (A.Adjuvant - A.Control) - (C.Adjuvant - C.Control), 
  "A.Adj_vs_A.Con_VS_B.Adj_vs_B.Con" = (A.Adjuvant - A.Control) - (B.Adjuvant - B.Control), 
  "C.Adj_vs_C.Con_VS_B.Adj_vs_B.Cont" = (C.Adjuvant - C.Control) - (B.Adjuvant - B.Control), 
  levels=design)

#>             Contrasts
#> Levels       A.Adj_vs_A.Con_VS_C.Adj_vs_C.Con A.Adj_vs_A.Con_VS_B.Adj_vs_B.Con
#>   B.Adjuvant                                0                               -1
#>   B.Control                                 0                                1
#>   C.Adjuvant                               -1                                0
#>   C.Control                                 1                                0
#>   A.Adjuvant                                1                                1
#>   A.Control                                -1                               -1
#>             Contrasts
#> Levels       C.Adj_vs_C.Con_VS_B.Adj_vs_B.Cont
#>   B.Adjuvant                                -1
#>   B.Control                                  1
#>   C.Adjuvant                                 1
#>   C.Control                                 -1
#>   A.Adjuvant                                 0
#>   A.Control                                  0

Thank you,

Mohammed

edgeR contrasts limma design model.matrix • 921 views
ADD COMMENT
1
Entering edit mode
@gordon-smyth
Last seen 9 hours ago
WEHI, Melbourne, Australia

The contrast matrix is correct. It reflects exactly the interactions you defined.

ADD COMMENT
0
Entering edit mode

Gordon Smyth thank you.

For instance, considering the comparison A.Adj_vs_A.Con_VS_C.Adj_vs_C.Con,

groups A.Adjuvant is denoted 1 and A.Control by -1 (comparing Drug A - Adjuvant to it's respective Control; this is fine), however, why group, C.Adjuvant by -1, and C.Control by 1. Shouldn't it be opposite way? since I again comparing Drug C - Adjuvant to it's respective Control. Does the logFC columns output as a result of this would be accurate to interpret or the direction of the (+/-) change?

ADD REPLY
1
Entering edit mode

No. The contrast is (A.Adj - A.Con) - (C.Adj - C.Con) which is the same as A.Adj - A.Con - C.Adj + C.Con.

ADD REPLY
0
Entering edit mode

Meaning this (A.Adj - A.Con) - (C.Adj - C.Con) is same as A.Adj - A.Con - C.Adj + C.Con....?

"A.Adj_vs_A.Con_VS_C.Adj_vs_C.Con" itself has 4 groups;
A.Adjuvant
A.Control
C.Adjuvant
C.Control

I want it to first compare;
`(A.Adjuvant - A.Control)`
Then;
`(C.Adjuvant - C.Control)`
followed by comparison as a whole:
"A.Adj_vs_A.Con_VS_C.Adj_vs_C.Con" = `(A.Adjuvant - A.Control) - (C.Adjuvant - C.Control)`
ADD REPLY
1
Entering edit mode

And as I already said, there is no difference whatsoever between (A.Adj - A.Con) - (C.Adj - C.Con) and A.Adj - A.Con - C.Adj + C.Con. For example

(3-2) - (5- 8) = 1 - (-2) = 3

And

3 - 2 - 5 + 8 = 3

Because addition is associative.

ADD REPLY
0
Entering edit mode

Thank you very much for the example. It's clear now.

ADD REPLY

Login before adding your answer.

Traffic: 768 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