FORUMDESeq2 error in design~ code
Morris asked 2 weeks ago



Hello everyone,

I’m using DESeq2 for RNA sequencing DGE analysis and I’m having error with this code
dds=DESeqDataSetFromTximport(txi,colData = coldata,design= ~ batch+condition)
Error in DESeqDataSet(se, design = design, ignoreRank) :
all variables in design formula must be columns in colData
Here is my coldata
coldata <- read.table(file.path(“Salm_txt_DEseq_update.txt”), header=TRUE)
and I have a column condition with16 rows 12 treated samples and 4 untreated sample
if I remove batch from the chmd line
dds=DESeqDataSetFromTximport(txi,colData = coldata,design=~condition)
it works ok .. but I wish to find out what’s wrong with the batch argument
any help would be appreciated
thank you

Rob Syme Staff replied 2 weeks ago

Hi Morris.

You’ve described that your file “Salm_txt_DEseq_update.txt” contains a column “condition”. Does that same file contain a column “batch”?

1 Answers
Rob Syme Staff answered 10 hours ago



For those coming to this question through search, the problem is probably a missing column “batch” in the coldata (“Salm_txt_DEseq_update.txt” in this case) data frame. Variables used in constructing the design formula (condition and batch in Morris’ example) must refer to columns the dataframe passed as coldata in the call to DESeqDataSetFromTximport.

Morris replied 3 hours ago

Hi Rob, sorry for the delay
yes my file now contains a column “batch” and the error is fixed but I can’t see variation after adding batch, which probably is due to
a mistake for using this command.
I have 4 different conditions (A,B,C,D), and for each condition I have two samples, there is a batch effect only in one condition (D) so, should I use a different
argument of batch for only this two samples (D)?
for example, here is the batch column of the data frame:
Condition Batch
A I
A I
B II
B II
C III
C III
D II
D III

Thank you