Question: Limma LmFit() giving error: Error in lm.fit(design, t(M)) : incompatible dimension
0
4.3 years ago by
Vani20
United States
Vani20 wrote:

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:

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)

modified 4.3 years ago by Aaron Lun25k • written 4.3 years ago by Vani20

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

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.

Answer: Limma LmFit() giving error: Error in lm.fit(design, t(M)) : incompatible dimens
2
4.3 years ago by
Aaron Lun25k
Cambridge, United Kingdom
Aaron Lun25k wrote:

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.