I'm trying to run DESeq
in an RScript using parameters input from the command line. I used optparse
to parse user arguments and am trying to pass the design argument into the DESeqDataSetFromMatrix()
function.
I tested the function directly and it works perfectly:
DESeq_tbl <- DESeqDataSetFromMatrix(countData=counts_tbl,
colData=coldata, design=~taxonomy)
However, if I try to pass the variable opt$design
(which is a character string = "~taxonomy"), I get the following error:
DESeq_tbl <- DESeqDataSetFromMatrix(countData=counts_tbl,
colData=coldata, design=opt$design)
Error: $ operator is invalid for atomic vectors Execution halted
I've tried noquote()
, various combinations of cat
/paste
and creating the entire command as a string to pass to the DESeqDataSetFromMatrix()
function, but nothing has worked. Any advice would be greatly appreciated.
the solution
Thanks to Ben Bolker's answer below, the following worked:
DESeq_tbl <- DESeqDataSetFromMatrix(countData=counts_tbl,
colData=coldata, design=as.formula(opt$design))