I am creating contrast matrix and i am following every procedure but still i don't understand where i am getting error
1
0
Entering edit mode
Rishav ▴ 20
@rishav-25031
Last seen 21 months ago
Patna

Here is what I am doing, after creating the design matrix, I am trying to create the contrast matrix


# > sample <- factor(rep(c("Non neoplastic","Tumor"), each=21))
> design.mat <- model.matrix(~0+sample)
> colnames(design.mat) <- levels(sample)
> design.mat
   Non neoplastic Tumor
1               1     0
2               1     0
3               1     0
4               1     0
5               1     0
6               1     0
7               1     0
8               1     0
9               1     0
10              1     0
11              1     0
12              1     0
13              1     0
14              1     0
15              1     0
16              1     0
17              1     0
18              1     0
19              1     0
20              1     0
21              1     0
22              0     1
23              0     1
24              0     1
25              0     1
26              0     1
27              0     1
28              0     1
29              0     1
30              0     1
31              0     1
32              0     1
33              0     1
34              0     1
35              0     1
36              0     1
37              0     1
38              0     1
39              0     1
40              0     1
41              0     1
42              0     1
attr(,"assign")
[1] 1 1
attr(,"contrasts")
attr(,"contrasts")$sample
[1] "contr.treatment"

> contrast.mat <- makeContrasts(diff = "Non neoplastic-Tumor", levels = design.mat)

#Error in makeContrasts(diff = "Non neoplastic - Tumor", levels = design.mat) : 
  The levels must by syntactically valid names in R
RNASeqR • 1.9k views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 1 hour ago
United States

You cannot use a syntactically invalid name with makeContrasts. In your case, the problem is that you have a space, and R doesn't recognize that Non and neoplastic are intended to go together. Normally R would run that sort of thing through make.names to make it syntactically valid (for example as a column name for a data.frame), but the expectation for makeContrasts is that you already have that.

> make.names("Non neoplastic")
[1] "Non.neoplastic"

So one thing you could do is change it to Non.neoplastic. Or Non_neoplastic, or NonNeoplastic. You get the idea.

ADD COMMENT
0
Entering edit mode

thank you so much

ADD REPLY

Login before adding your answer.

Traffic: 691 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6