Limma LmFit() giving error: Error in lm.fit(design, t(M)) : incompatible dimension
1
0
Entering edit mode
Vani ▴ 20
@vani-8145
Last seen 8.3 years ago
United States

Hi,

I am trying to run limma's lmFit on a geo dataset pertaining to heart failure. Whenever I run the lm.fit command I get the error: Lm.fit() giving Error in lm.fit(design, t(M)) : incompatible dimension. I am trying to run the differential expression on the non-failing and failing hearts. The Heart_Failure columns in the ESET contains the values yes (failing heart), no (non failing heart), NA. In my code I try to get rid of all the rows in the ESET that contain NA values .

Here is my code:

#Load dataset using inSilicoDb

eset21610 <- (getDataset("GSE21610", "GPL570", format = "CURESET", norm = "SCAN", features = "GENE"))

#Try to get rid of NA values

eset21610$Heart_Failure[eset21610$Heart_Failure == "NA"] <- NA

na.omit(pData(eset21610))

#Create Design matrix

design1 <- model.matrix(~ Heart_Failure, pData(eset21610))

#Run lmFit

afterLimma <- lmFit(eset21610, design = design1)

e4 <- eBayes(afterLimma)

 

Please advise.

limma differential expression design matrix error eset • 8.5k views
ADD COMMENT
0
Entering edit mode

What does design1 look like (i.e., how many rows are there)? What are the dimensions of eset21610?

ADD REPLY
0
Entering edit mode

design1: 38 rows & eset21610: 19528 rows, 68 colnames.  There were 30 NA's, 30 yes heart failure, and 8 no heart failure in the Heart_Failure column.

ADD REPLY
2
Entering edit mode
Aaron Lun ★ 28k
@alun
Last seen 12 hours ago
The city by the bay

When you construct a design matrix with model.matrix, any NA values in the input vectors will be dropped. This results in fewer libraries (i.e., rows) in the design matrix than there are columns in your expression matrix. Attempting to use lmFit will result in a mismatch in dimensions and the reported error. To avoid this, you should remove those libraries that are NA for heart failure:

keep <- !is.na(eset21610$Heart_Failure) # done after assignment of NA to replace "NA"
new.eset21610 <- eset21610[,keep]
new.design <- model.matrix(~ Heart_Failure, pData(new.eset21610))
new.fit <- lmFit(new.eset21610, new.design)

I see that you've tried to do this with na.omit, but I'm not sure that this is generally safe to do for ExpressionSet objects, given that they're S4 objects with several internal data structures. Even if it did work, you'd need to assign the na.omit output to replace the original, as the function doesn't do in-place removal of NA values.

ADD COMMENT
0
Entering edit mode

Thank You! It worked

ADD REPLY

Login before adding your answer.

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