Dear all,
I think I need a hint here I am confused right now. I want to create a Differential Expression Analysis comparing Male to Female via Limma. But I also want to adjust the model for e.g. Age, sample site.
Now when I create the Contrast matrix it asks for the design, which includes all my variables. Please find some code below:
> design = model.matrix( ~ AGE + SAMPLE.SITE + DIAGNOSIS + SEX,
> metadata)
Now I try to do the contrasts I am interested in with
> contrasts <- makeContrasts("M-F",levels=design)
It gives me the error:
Error in makeContrasts("M-F", levels = design) : The levels must by syntactically valid names in R, see help(make.names). Non-valid names: AGE.GROUPAbove 70,AGE.GROUPUnder 50 In addition: Warning message: In makeContrasts("M-F", levels = design) : Renaming (Intercept) to Intercept
Not sure what I am doing wrong. Any hint very appreciated!
Maybe I dont even need to do a contrast matrix? Maybe I can get the result just with
> result <- topTable(fit, number = 50, adjust = "BH", p.value = 0.05,
> lfc = 1.2, coef = "SEXM")
Sex only has M or F.
Thanks, Bine
It is hard to help without knowing the complete design you have, but if you have the Sex category with only two levels then your column "SEXM" refers to the comparison M-F and you do not need to make contrasts. Your
topTable()
code is correct and you can use it.So that means I only need to use make contrasts when i have more than 2 levels in one category?