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
Gordon Smyth thank you.
For instance, considering the comparison
A.Adj_vs_A.Con_VS_C.Adj_vs_C.Con
,groups
A.Adjuvant
is denoted1
andA.Control
by-1
(comparing Drug A - Adjuvant to it's respective Control; this is fine), however, why group,C.Adjuvant
by-1
, andC.Control
by1
. 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?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.
Meaning this
(A.Adj - A.Con) - (C.Adj - C.Con)
is same asA.Adj - A.Con - C.Adj + C.Con
....?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.
Thank you very much for the example. It's clear now.