Synthetically valid name error in "MakeContracts" in Limma
1
0
Entering edit mode
4 months ago
Jakpa ▴ 50

Hi,

I have a design matrix that looks like this

    fit <- lmFit(expressionData_2, design = design)

fit <- eBayes(fit)


Then, I want comparing each subtype to all the other subtypes using MakeContracts function. I wrote this code:

   contrast_matrix <- makeContrasts(

"MS1avsOther" = MS1a - (MS1b + MS2a_1 + MS2a_2 + MS2b_1 + MS2b2_1 + MS2b2_2) / 6,

"MS1bvsOther" = MS1b - (MS1a + MS2a_1 + MS2a_2 + MS2b_1 + MS2b2_1 + MS2b2_2) / 6,

"MS2a_1vsOther" = MS2a_1 - (MS1b + MS1b + MS2a_2 + MS2b_1 + MS2b2_1 + MS2b2_2) / 6,

"MS2a_2vsOther" = MS2a_2 - (MS1b + MS2a_1 + MS2a_1 + MS2b_1 + MS2b2_1 + MS2b2_2) / 6,

"MS2b_1vsOther" = MS2b_1 - (MS1b + MS2a_1 + MS2a_2 + MS2b_1 + MS2b2_1 + MS2b2_2) / 6,

"MS2b2_1vsOther"  = MS2b2_1 - (MS1b + MS2a_1 + MS2a_2 + MS2b_1 + MS2b_1 + MS2b2_2) / 6,

"MS2b2_2vsOther" = MS2b2_2 - (MS1b + MS2a_1 + MS2a_2 + MS2b_1 + MS2b2_1 + MS1a) / 6,

'levels = design
)


i got this error: The levels must by syntactically valid names in R, see help(make.names). Non-valid names: MS1a, MS1b, MS2a_1, MS2a_2, MS2b_1, MS2b2_1, MS2b2_2

I read the make.name documentation and from what I understood, my naming is correct. initially, the MS2b_1, MS2b_2 were MS2b.1, MS2b.2 I was not expecting to see same error after renaming.

Please, I need assistance on this.

Regards,

Matrix limma GeneExpression R • 568 views
1
Entering edit mode

Could you share dput(design) instead of a picture ?

0
Entering edit mode

Basti , I could not send the output of dput(design) . I clicked of save button but it did not deliver. I think the its because the output is too long

0
Entering edit mode

dput(design[1:6,1:7]) should do the trick

0
Entering edit mode

This is the output:

    structure(c(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0), dim = 6:7, dimnames = list(c("GSM814052", "GSM814053",
"GSM814054", "GSM814055", "GSM814056", "GSM814057"), c(" MS1a",
" MS1b", " MS2a_1", " MS2a_2", " MS2b_1", " MS2b2_1", " MS2b2_2"
)))

0
Entering edit mode

Thank you for the observation. After remove the space, its works perfectly :)

3
Entering edit mode
4 months ago
Basti ★ 1.4k

Well now you can see that you have a space in the beggining of each of your colnames, this is why it does not work ;)