Manisha Brahmachary
2007-Nov-13 18:43 UTC
[R] need help with error message:Error in lm.fit(design, t(M)) : incompatible dimensions
Hello, I am trying to run a code (see reference section) and when I run the line: fit<-lmFit(xen1dataeset,design), I get the error message: Error in lm.fit(design, t(M)) : incompatible dimensions I will really appreciate if someone can help me understand this error message and possibly help me debug the problem. Thanks manisha Reference section xen1data<-ReadAffy() # Read Affy dataset cell files xen1dataeset<-gcrma(xen1data) # Normalize with GCRMA write.exprs(xen1dataeset,file="xen1_exprs") # write normalzed expression values>str(exprs(xen1dataeset))num [1:22690, 1:2] 12.0 11.3 13.0 11.6 10.3 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:22690] "1415670_at" "1415671_at" "1415672_at" "1415673_at" ... ..$ : chr [1:2] "A1_xen1_1_1.CEL" "A2_xen2a_5_2.CEL" targets<-readTargets("xen1shrt.txt") # Read target files>targetsName FileName Target 1 A1_xen1_1_1 A1_xen1_1_1.CEL A_xen 2 A2_xen2a_5_2 A2_xen2a_5_2.CEL A_xen 3 A3_xen2b_6_3 A3_xen2b_6_3.CEL A_xen 4 B1_cr1_2_4 B1_cr1_2_4.CEL B_crp 5 B2_cr2a_9_5 B2_cr2a_9_5.CEL B_crp 6 B3_cr2b_10_6 B3_cr2b_10_6.CEL B_crp f<-factor(targets$Target,levels=c("A_xen", "B_crp")) # Define levels>f[1] A_xen A_xen A_xen B_crp B_crp B_crp Levels: A_xen B_crp design<-model.matrix(~0+f) # Define design matrix based on Factors>designA_xen B_crp 1 1 0 2 1 0 3 1 0 4 0 1 5 0 1 6 0 1 attr(,"assign") [1] 1 1 attr(,"contrasts") attr(,"contrasts")$f [1] "contr.treatment" colnames(design)<- c("A_xen", "B_crp") # Define colnames of the design matrix fit<-lmFit(xen1dataeset,design) # Fit linear model based on the design matrix contrast.matrix<- makeContrasts(B_crp- A_xen) # define contrast matrix fit2<-contrasts.fit(fit,contrast.matrix) # calculate contrast fit3<-eBayes(fit2) # Calculate B and P-values for contrast crpMxen<-topTable(fit3,coef=1,number=22690,adjust.method="BH",sort.by='B') [[alternative HTML version deleted]]