''Model_Matrix'' error
1
0
Entering edit mode
Laghalelle • 0
@ec2eae12
Last seen 7 months ago
Tunisia

Greeting, i wanted to make a diffrential gene expression analysis using Limma package,

sample_info <- read.csv("matrix.csv" , header= TRUE, row.names = 1)
Group <- factor(sample_info$group)
design <- model.matrix(~Group)

But i got this error message:

Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
  contrasts can be applied only to factors with 2 or more levels

Just to mention, in my ''sample_info'', the only factor thar i have is ''Group'' which contains ''Low_Grade'' and ''High_Grade"

Thank you in advance.

DifferentialExpression limma • 408 views
ADD COMMENT
0
Entering edit mode
@gordon-smyth
Last seen just now
WEHI, Melbourne, Australia

This is actually an error message from base R rather than from limma. The error says that Group contains 0 or 1 levels, so your assumption that it contains 'Low_Grade'' and ''High_Grade" cannot be true.

Please type

levels(Group)

or

table(Group)

to see what the levels of Group actually are.

This is just a wild guess, but one possibility is that you have simply forgotten to capitalize Group, i.e., you used

Group <- factor(sample_info$group)

when

Group <- factor(sample_info$Group)

would have been correct. You can type names(sample_info) to confirm which name is correct.

In general, it would much quicker to you to trouble-shoot simple errors like this at your end rather than asking for help on a public forum. If Group gives an error when input to a standard function like model.matrix, then have a look at what Group contains. The reason for the error should become quickly apparent.

ADD COMMENT

Login before adding your answer.

Traffic: 417 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