edgeR error "Design matrix not of full rank"
1
0
Entering edit mode
sat • 0
@ccbf0270
Last seen 9 months ago
italy

I have a analysis in edgeR, but it ended by error.

This is my data:

Sample  treat   factor1 factor2
   s1   CT  1   c1
   s2   CT  1   c1
   s3   CT  2   c1
   s4   CT  2   c1
   s5   CT  1   c2
   s6   CT  2   c2
   s7   CT  2   c2
   s8   CT  1   c2
   s9   CT  1   c2
   s10  CT  2   c2
   s11  treatmetn   2   c3
   s12  treatmetn   2   c3
   s13  treatmetn   1   c3
   s14  treatmetn   2   c3
   s15  treatmetn   1   c3
   s16  treatmetn   2   c3
   s17  treatmetn   1   c3
   s18  treatmetn   2   c4
   s19  treatmetn   2   c4
   s20  treatmetn   2   c4
   s21  treatmetn   1   c4
   s22  treatmetn   2   c4

I used this formula for analysis

 --formula "treat+factor1+factor2" \

at the end I have this error:

Error in glmFit.default(sely, design, offset = seloffset, dispersion = 0.05,  :
  Design matrix not of full rank.  The following coefficients not estimable:
 factor2C4
Calls: estimateDisp ... estimateDisp -> estimateDisp.default -> glmFit -> glmFit.default
Execution halted
edgeR methylation • 968 views
ADD COMMENT
0
Entering edit mode
@gordon-smyth
Last seen 1 hour ago
WEHI, Melbourne, Australia

treat is completely confounded with factor2. It is impossible to include two factors in the linear model when one is a special case of the other.

What are you trying to do? Why have you tagged the question with the "methylation" tag?

ADD COMMENT
0
Entering edit mode

Thanks for reply. factor1 is sex and factor 2 is effect of mother. I need to have both of them in the models. whats your propose? Thanks a lot!

ADD REPLY
0
Entering edit mode

As Gordon already noted, you cannot include both in your design matrix. The only alternative is to use the limma-voom pipeline and fit a GLS to account for the correlation between samples from the same mother. Something like

design <- model.matrix(~ treat + factor1)
fit <- voomLmFit(sely, design, factor2)
fit2 <- eBayes(fit)

The issue is that mother is nested in treatment (e.g., the offspring for each mother is either treated or control), which is problematic. Ideally the offspring would have been randomized to the two treatment arms, in which case it would be possible to fit factor2 in the model as a fixed effect. It is crucial to design an experiment carefully to avoid this sort of thing.

ADD REPLY
0
Entering edit mode

Thanks James for the reply. When i use the factor2, I have a error at the end due to number of rows.

      > fit <- voomLmFit(y, design, data$factor2)
     Error in qr.qty(QR, design.block) :
        'qr' and 'y' must have the same number of rows

     > fit <- voomLmFit(y, design)

Its ok when i didn't use the factor2

ADD REPLY
0
Entering edit mode

You must have made a mistake in your code. Ideally you would provide a self-contained example. Here is an example of what that means.

## make some plausible fake data (using code from ?glmQLFit)
> nlibs <- 22
## for reproducibility
> set.seed(0xabeef)
> y <- rnbinom(ngenes*nlibs,mu=20,size=1/dispersion.true)
> y <- matrix(y,ngenes,nlibs)
## recreate your data.frame
> d.f <- data.frame(treat = factor(rep(c("CT","Treat"), c(10,12))), factor1 = factor(c(1,1,2,2,1,2,2,1,1,2,2,2,1,2,1,2,1,2,2,2,1,2)), factor2 = rep(c("c1","c2","c3","c4"), c(4,6,7,5)))
> d.f
   treat factor1 factor2
1     CT       1      c1
2     CT       1      c1
3     CT       2      c1
4     CT       2      c1
5     CT       1      c2
6     CT       2      c2
7     CT       2      c2
8     CT       1      c2
9     CT       1      c2
10    CT       2      c2
11 Treat       2      c3
12 Treat       2      c3
13 Treat       1      c3
14 Treat       2      c3
15 Treat       1      c3
16 Treat       2      c3
17 Treat       1      c3
18 Treat       2      c4
19 Treat       2      c4
20 Treat       2      c4
21 Treat       1      c4
22 Treat       2      c4
## make a design matrix
> design <- model.matrix(~treat + factor1, d.f)
## and a DGEList, with normalization factors
> d <- DGEList(y)
> d <- normLibSizes(d)
## fit the model
> fit <- voomLmFit(d, design, d.f$factor2)
First intra-block correlation  -0.03758207
Final intra-block correlation  -0.03757853
ADD REPLY
0
Entering edit mode

Thank a lot. But I don't understand whats the mistake here, another error!

> fit2 <- voomLmFit(d, design, data$factor2)
Error in lmFit(y, design, weights = prior.weights) :
  row dimension of design doesn't match column dimension of data object
ADD REPLY
1
Entering edit mode

Here is something that you should be able to diagnose by yourself by simply reading the error message (they are usually meant to help!).

It says

Error in lmFit(y, design, weights = prior.weights) :
  row dimension of design doesn't match column dimension of data object

Which clearly states what the problem is. The rows of your design matrix are supposed to correspond to each column of your data, and they are mis-matched (you have more of one than the other). You will have to inspect the design matrix and figure out where you went wrong.

ADD REPLY
0
Entering edit mode

samples are related to the methylation analysis

ADD REPLY

Login before adding your answer.

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