Question: DESEQ2 design with multiple conditions
gravatar for vrehaman
6 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




ADD COMMENTlink modified 6 months ago by Michael Love19k • written 6 months ago by vrehaman0
gravatar for Michael Love
6 months ago by
Michael Love19k
United States
Michael Love19k 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 6 months ago by Michael Love19k

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 6 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 2.2.0
Traffic: 320 users visited in the last hour