Hy, guys
I checked the edegR manual and the explanation for coef
is not clear for me. For 2 or 3 groups it's very simple to determine the coef for comparisons (coef:2
for 2vs1 and coef=3
for 3vs1). But what coef
should I use if I want to compare many groups like below:
group <- factor(c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7))
y <- DGEList(counts=data,group=group)
y
norm_data <- calcNormFactors(y)
design <- model.matrix(~group)
norm_data <- estimateDisp(norm_data,design)
fit <- glmQLFit(norm_data, design)
qlf2vs1 <- glmQLFTest(fit, coef=2)
Is there a rule for that? For example: how to compare groups 7 vs 1 or 5 vs 2... etc?
Thanks in advance
It looks easier.
For 6vc1 is it something like this, right?:
One simple question: why in this case should I use
~0+groups
instead of~groups
?Thanks again
Looks about right, I would make the name like G6 instead of 6 though, also the contrasts like G6vsG1 rather than 6vs1, be safe and avoid numbers as variable names.
It worked very well.
I think you didn't see my last question. "One simple question: why in this case should I use ~0+groups instead of ~groups?"
Thanks again
The design without intercept (the one with the zero) does not use the first sample as the reference, therefore you can make all possible combinations via the contrast function.
Actually, it's not properly working.
When I use the classical aproach it works fine. The results are ok, logFC as expected and some differentially expressed genes:
With the new code it seems the comparison is not correct. logFC is like -300 for most of genes and almost all of them are differentially expressed:
I can't see any error in the code but it's obviously wrong in some point.
Do you know what is the probable error?
Probably because you use integers as variables which is bad practice in R. Something like
G2vsG1=G2-G1
would be better than2-1
. Not sure how the function interpretes integers. In any case it is bad practice to use integers as colnames or variables.Perfect. Now is everything working well.
Thank you very much