This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DESeq2 use of factors for colData

Hi, I am doing differential expression analysis using a count matrix with four samples and two groups using the function:

DESeqDataSetFromMatrix(countMatrix, colData = colData, design = ~groups.

I set the corresponding rows in my colData$groups to c("ctl", "ctl", "trt", "trt"), and I get one result, same as if I set colData$groups to c(0,0,1,1). But if I set it to c(0,0,2,2), I get a different result. However, if I set colData$groups to factor(c(0,0,2,2)) I get the same results as 0,0,1,1.

What is DESeqDataSetFromMatrix doing to give the different results for colData$groups 0,0,2,2?

Thank you

deseq2 expression differential

1 answer

If you don't want the groups to be literal numbers, making them factors is the correct thing to do.

DESeq2 tends to do this automatically if you give it strings for the colData, but it won't do that if you give it numbers.

Thanks for your answer. Do you know what DESeq2 is doing when given numbers?

I believe it will try to make a linear correlation between the logs of the counts and your numerical colData. But it's hard to know without seeing the rest of your code.

Log in to answer this question.