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
Thank you! Your detailed answer are very helpful to me! Sorry for no patient to carefully read the manual!