Lmfit Method Of Limma Package Throwing Error While Calculating P Values
2
0
Entering edit mode
11.3 years ago
Curious Mind ▴ 10

Hi,

I am trying to find the p-values for golub data. I have loaded the data as follows:

library(multtest)
library(annotate)
library(limma)

dat<-golub[,]
dat<-as.data.frame(dat)

The first 27 columns are controls and the remaining 11 are tests. I want to calculate the p-values using the eBayes(0 method in the limma package. The following is my code:

design<-as.data.frame(cbind(dat[,1:27], dat[,28:38]))
fit<-lmFit(dat,design)

However, I am getting the following error:

Error in lm.fit(design, t(M)) : incompatible dimensions

When I checked, the dim of design and dat, they are of same dimension as shown below:

dim(design)
[1] 3051   38
dim(dat)
[1] 3051   38

Thanks

limma • 8.2k views
ADD COMMENT
0
Entering edit mode
11.3 years ago

Your design matrix should not have the same dimensions as your data. I find it useful to create both design and contrast matrices and to create the design matrix using a factor (or a character vector, as below, that will be converted to factor).

design = model.matrix(~0+c(rep('control',27),rep('test',11)))
colnames(design) = c('control','test')
cm = makeContrasts(test-control,levels=design)
fit = lmFit(dat,design)
fit2 = contrasts.fit(fit,cm)
fit3 = eBayes(fit2)
ADD COMMENT
0
Entering edit mode

Hello Sean, Thanks for the reply. Now the error is gone. When I tried to get the p-Values using .p.Values<-fit3$p.value[,2] , I am getting the following error: Error in fit3$p.value[, 2] : subscript out of bounds Thanks

ADD REPLY
0
Entering edit mode

I have found the p values as follows. p.Values<-fit3$p.value Thanks

ADD REPLY
0
Entering edit mode

You may want to use topTable() for this type of thing.

ADD REPLY
0
Entering edit mode
9.6 years ago
ahmedc3.ri • 0

You will need to define the whole data set first then you define your dimensions:

For example I have a data of 17 samples 2 groups.

7 sample in the first group and 10 in the second.

I can say

des=cbind(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2))

so cbind is the total samples and the c will specify how many for each group.

Then you can fit your model

fit=lmFit(exprs.eset,design=des)
gene.ps=rownames(exprs.eset)
ADD COMMENT

Login before adding your answer.

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