This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Synthetically valid name error in "MakeContracts" in Limma

Hi,

I have a design matrix that looks like this

design matrix

    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

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

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

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

Basti ,

Thank you for your response.

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"
)))`

Basti ,

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

1 answer

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 ;)

Log in to answer this question.