Question: DESeq2: error, the model matrix is not full rank, linear combinations
0
gravatar for arielle
7 months ago by
arielle0
arielle0 wrote:

Hi, I am using DESeq2 with this model matrix (dput of the model matrix and DESeq2 command are pasted below). However, DESeq2 complains that some of the columns in the model matrix are linear combinations of each other (also see the error below). I am aware that this is an usual model matrix, but I don't see why I get this error. Thank you for your advice.

colData <- structure(list(s1 = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 
1L, 1L, 1L, 1L), .Label = c("0", "1"), class = "factor"), s2 = structure(c(1L, 
2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L), .Label = c("0", 
"1"), class = "factor"), s3 = structure(c(1L, 1L, 2L, 1L, 1L, 
1L, 1L, 1L, 2L, 1L, 1L, 1L), .Label = c("0", "1"), class = "factor"), 
    s4 = structure(c(1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 
    1L, 1L), .Label = c("0", "1"), class = "factor"), s5 = structure(c(1L, 
    1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L), .Label = c("0", 
    "1"), class = "factor"), s6 = structure(c(1L, 1L, 1L, 1L, 
    1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L), .Label = c("0", "1"), class = "factor"), 
    condition = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    2L, 2L, 2L), .Label = c("0", "1"), class = "factor"), var = structure(c(2L, 
    2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", 
    "1"), class = "factor")), class = "data.frame", row.names = c("s1_a", 
"s2_a", "s3_a", "s4_a", "s5_a", "s6_a", "s1_b", "s2_b", "s3_b", 
"s4_b", "s5_b", "s6_b"))

dds <- DESeqDataSetFromMatrix(countData = count_input,
                                colData = colData,
                                design = ~ s1 + s2 + s3 + s4 + s5 + s6 + condition + var)

Error in checkFullRank(modelMatrix) : the model matrix is not full rank, so the model cannot be fit as specified. One or more variables or interaction terms in the design formula are linear combinations of the others and must be removed.

Please read the vignette section 'Model matrix not full rank':

vignette('DESeq2')

deseq2 • 162 views
ADD COMMENTlink modified 7 months ago by Peter Langfelder2.3k • written 7 months ago by arielle0
Answer: DESeq2: error, the model matrix is not full rank, linear combinations
0
gravatar for Peter Langfelder
7 months ago by
United States
Peter Langfelder2.3k wrote:

You get this error because the sum of all s variables gives the intercept column:

xx = apply(colData, 2, as.numeric)
rowSums(xx[, 1:6])

Intercept is part of the model matrix unless you include -1 in the model specification. In this case, you need to either specify -1 or remove one of the s variables.

ADD COMMENTlink modified 7 months ago • written 7 months ago by Peter Langfelder2.3k
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 16.09
Traffic: 299 users visited in the last hour