adding batch variable in colData(dds)
2
0
Entering edit mode
5.5 years ago
Mozart ▴ 330

Dear all, I am quite struggling with some sort of coding here. Essentially, what I am trying to do is to simply add the batch variable to my design in DESeq2. Thus, I am doing:

dds$batch = factor(c('1','1','2','2','3','3'))
dds <- DESeqDataSetFromTximport(txi.kallisto.tsv, table, ~batch+condition)

but it returns an error message

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

perfect, but when I type

colData(dds)

it returns, as expected, two columns:

> colData(dds)
DataFrame with 6 rows and 2 columns
          condition    batch
           <factor> <factor>
sample_1      wt        1
sample_2      ko        1
sample_3      wt        2
sample_4      ko        2
...

any ideas?

Thanks in advance

deseq2 • 5.2k views
ADD COMMENT
0
Entering edit mode

It really seems that you need to create the same identical column in sample table, too. Thus, by doing this you should mange to solve the problem:

sampletable$batch=factor(c('1','1','2','2','3','3'))

if someone could confirm this, that would be great. thanks.

ADD REPLY
2
Entering edit mode
5.5 years ago
prabin.dm ▴ 260

Have a look at the DESeq2 vignette

library("DESeq2")
ddsTxi <- DESeqDataSetFromTximport(txi,
                                   colData = samples,
                                   design = ~ condition)

As the error msg says, the colData should have the batch variables as a column, that is your table. So instead adding a column to dds if you add your batch column to your table which is your colData, it should work.

ADD COMMENT
0
Entering edit mode

Thanks so much for your reply; soon thereafter my thread I tried to add by myself this other column to my table and your reply comes as a confirmation for me. Thanks

ADD REPLY
0
Entering edit mode
5.5 years ago

You need to stop and think and understand what your commands are doing, not make things up. It does no good to add things to dds when your next command is trying (and failing) to remake it from scratch. You need to find some tutorials and walk through them step by step so that you can understand what each command is doing

ADD COMMENT
0
Entering edit mode

Hi and thanks for your reply. Literally I got confounded by the double approach to deal with batch effect in DESeq2 because, reading the manual and other posts on bioconductor and here, apparently dds$batch is required once you have your counts transformed (e.g. vsd) for visualisation purposes. So, correct myself if I am doing something wrong here, please.

ADD REPLY
0
Entering edit mode

Hi Mozart, did you figure it out? cause I have the same problem

thanks

ADD REPLY
0
Entering edit mode

see here: link

ADD REPLY

Login before adding your answer.

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