Question: Does edgeR need to specify reference group?
0
gravatar for 15958021290
7 weeks ago by
159580212900 wrote:

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 • 106 views
ADD COMMENTlink modified 7 weeks ago by Gordon Smyth39k • written 7 weeks ago by 159580212900
Answer: Does edgeR need to specify reference group?
4
gravatar for James W. MacDonald
7 weeks ago by
United States
James W. MacDonald52k wrote:

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 COMMENTlink written 7 weeks ago by James W. MacDonald52k

Thank you! It helps! Your answer are accepted!

ADD REPLYlink written 7 weeks ago by 159580212900
Answer: Does edgeR need to specify reference group?
3
gravatar for Gordon Smyth
7 weeks ago by
Gordon Smyth39k
Walter and Eliza Hall Institute of Medical Research, Melbourne, Australia
Gordon Smyth39k wrote:

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 COMMENTlink modified 7 weeks ago • written 7 weeks ago by Gordon Smyth39k

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

ADD REPLYlink modified 7 weeks ago • written 7 weeks ago by 159580212900
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 343 users visited in the last hour