DESeq2: error, the model matrix is not full rank, linear combinations
1
0
Entering edit mode
arielle • 0
@arielle-12244
Last seen 5.4 years ago

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 • 1.4k views
ADD COMMENT
0
Entering edit mode
@peter-langfelder-4469
Last seen 5 weeks ago
United States

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 COMMENT

Login before adding your answer.

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