Question: Lmfit Method Of Limma Package Throwing Error While Calculating P Values
0
gravatar for Curious Mind
5.9 years ago by
Curious Mind10
Curious Mind10 wrote:

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

bioinformatics limma • 4.9k views
ADD COMMENTlink modified 4.2 years ago by ahmedc3.ri0 • written 5.9 years ago by Curious Mind10
0
gravatar for Sean Davis
5.9 years ago by
Sean Davis25k
National Institutes of Health, Bethesda, MD
Sean Davis25k wrote:

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 COMMENTlink written 5.9 years ago by Sean Davis25k

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 REPLYlink written 5.9 years ago by Curious Mind10

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

ADD REPLYlink written 5.9 years ago by Curious Mind10

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

ADD REPLYlink written 5.9 years ago by Sean Davis25k
0
gravatar for ahmedc3.ri
4.2 years ago by
ahmedc3.ri0
United States
ahmedc3.ri0 wrote:

U 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 COMMENTlink written 4.2 years ago by ahmedc3.ri0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1053 users visited in the last hour