Question: DESEQ2 design with multiple conditions
gravatar for vrehaman
18 months ago by
vrehaman0 wrote:

Dear team,

I am working on RNASeq data with batches and later on I have to more covariates to design. I  had tried automating R script but it's not working. How can I automate design part of DESeq2 workflow?

My coldata file looks like below

condition batch
ctrl 1
ctrl 1
ctrl 2
ctrl 2
treat 1
treat 1
treat 2
treat 2



> covariate
[1] condition+batch
Levels: condition+batch

dds <- DESeqDataSetFromMatrix(countData = cts1,colData = coldata,design = ~ covariate)

I am getting below error. It is not taking column names from covariate object. Am I doing wrongly. 

Error in DESeqDataSet(se, design = design, ignoreRank) : 
  all variables in design formula must be columns in colData

Is there any way I can automate if have more than two columns (eg . age) , instead of specifying each covariate separately to design matrix like below

dds <- DESeqDataSetFromMatrix(countData = cts1,colData = coldata,design = ~ condition + batch + age 

Could you please help me to resolve this issue.

Thanks In Advance

Fazulur Rehaman




deseq2 design matrix • 750 views
ADD COMMENTlink modified 18 months ago by Michael Love25k • written 18 months ago by vrehaman0
Answer: DESEQ2 design with multiple conditions
gravatar for Michael Love
18 months ago by
Michael Love25k
United States
Michael Love25k wrote:

Because the design is such an important part of the data analysis process, we specifically didn't help this step be automated. The great majority of the DESeq2 posts here are analysts who are thinking about exactly how to model their data, what assumptions to make, which coefficients to include, whether to transform or add interaction terms between variables etc. I wouldn't recommend to just put all the covariates as simple addition into the design. Sometimes this is what users want to do, but not nearly all the time.

Note that we recommend to put the variable of interest, e.g. "condition" at the end of the design formula, in case a user calls results(dds) without specifying any specific coefficient, as this will give back the coefficient associated with the last variable in the design. See the vignette.

ADD COMMENTlink written 18 months ago by Michael Love25k

Dear Michael,

Thanks a lot for your quick response and suggestions on multiple covariates.

And I have checked the vignette , and will put condition at the end of formula like below.

dds <- DESeqDataSetFromMatrix(countData = cts1,colData = coldata,design = ~  batch + age + condition)

Thanks & Regards

Fazulur Rehaman


ADD REPLYlink written 18 months ago by vrehaman0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 132 users visited in the last hour