Does edgeR need to specify reference group?
2
0
Entering edit mode
15958021290 ▴ 10
@15958021290-21573
Last seen 4.4 years ago

Hi guys! I want to know if edgeR also need to specify reference group data similar to DESeq2? Because DESeq2 need to use

dds$condition <- factor(dds$condition, levels = c("untreated","treated"))
# or
dds$condition <- relevel(dds$condition, ref = "untreated")

to specify which group is reference group. But I didn't find relevant info when read the edgeR manual.I just find

group <- factor(c(1,1,2,2))

but didn't clearly specify the reference group. Any ideas are welcome! Thank you !

edgeR reference group • 2.1k views
ADD COMMENT
4
Entering edit mode
@james-w-macdonald-5106
Last seen 2 minutes ago
United States

With edgeR you specify the design and contrast (if needed) matrices directly, and you choose the reference based on either accepting R's factor level defaults, or by specifying your own. For example, in your example, the '1' group will be the reference, because that's the default (R uses alphanumerical ordering to specify the reference). You could have done

> group <- factor(c(1,1,2,2,2), levels = c("2","1"))
> group
[1] 1 1 2 2 2
Levels: 2 1

> model.matrix(~group)
  (Intercept) group1
1           1      1
2           1      1
3           1      0
4           1      0
5           1      0
attr(,"assign")
[1] 0 1
attr(,"contrasts")
attr(,"contrasts")$group
[1] "contr.treatment"

To set the '2' group as the reference. Or you can fit a cell means model and specify the comparisons directly, which is often the easiest way to go.

> design <- model.matrix(~0+group)
> design
  group2 group1
1      0      1
2      0      1
3      1      0
4      1      0
5      1      0
attr(,"assign")
[1] 1 1
attr(,"contrasts")
attr(,"contrasts")$group
[1] "contr.treatment"

> contrast <- makeContrasts(group2-group1, levels = design)
> contrast
        Contrasts
Levels   group2 - group1
  group2               1
  group1              -1

ADD COMMENT
0
Entering edit mode

Thank you! It helps! Your answer are accepted!

ADD REPLY
3
Entering edit mode
@gordon-smyth
Last seen 4 hours ago
WEHI, Melbourne, Australia

edgeR and DESeq2 are identical in the way that they define factors since both packages simply use base R functions like factor and relevel. Specifying the reference level explicitly is optional in both packages.

You will find a discussion of the relevel function for example on pages 30, 33, 37, 53 and 91 of the edgeR User's Guide.

edgeR gives you complete flexibility to use base R functionality, and it defines design matrices and contrasts exactly like the limma package, so you can leverage knowledge from one package to the other. James MacDonald gives a nice summary in his answer and more examples can be found in Chapter 3 of the edgeR User's Guide or Chapter 9 of the limma User's Guide.

ADD COMMENT
0
Entering edit mode

Thank you! Your detailed answer are very helpful to me! Sorry for no patient to carefully read the manual!

ADD REPLY

Login before adding your answer.

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