DESeq2: Variables in the design section
1
1
Entering edit mode
Matan G. ▴ 60
@matan-g-22483
Last seen 3.1 years ago

Hi,

Is there a way to set the input in the design section of DESeq2 as variables?

The aim is that the colname chosen will be a variable that can be changed elsewhere in the script rather than the location of the design itself.

Best

deseq2 • 2.3k views
ADD COMMENT
1
Entering edit mode
@mikelove
Last seen 2 days ago
United States

You can use formula() to convert character string to formula.

ADD COMMENT
0
Entering edit mode

Hi Michael, Thank you for replying.

I'm getting the message:

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

Tried in various ways to apply your suggestion with no success. According to the error I understand that I have to define colData before running dds <- DESeqDataSetFromMatrix...

And then make sure that the variable in the design section would be a column in colData.

This is one of the methods I've tried:

  colData = coldata # where coldata is my metatdata table
  ccon = "cc" # the string I'd like to make as formula which is a function of colData column 
  con = 9 # the variable which will be the number of column to choose from
  formula(ccon ~ colData[con]) # the formula



# then I'm trying to run it this way:
    dds <- DESeqDataSetFromMatrix(
    countData = countdata,
    colData = coldata,
    design = ~ ccon)

I'm obviously using it wrong, I thought it has to do either with the fact that it has to be in the context of a dataset and not a seperate data frame. or with the fact that the column subsetting I'm using is not equivalent to using "$".

Hope you can help me solve this.

All the best

ADD REPLY
0
Entering edit mode

I don’t think you got my suggestion. The design argument takes a formula. So you can provide a character string to formula() to pass to design.

ADD REPLY
0
Entering edit mode

Hi thank you for the input.

Unfortunately i still can't mange to apply it. struggling with the information about formula() usage.

Best regards

ADD REPLY
0
Entering edit mode

I guess this is a bit out of scope for the support site, as there isn't an issue with using DESeq2 per se, but you want to write a program that calls DESeq2 programmatically. As you are stuck at this stage, I would recommend consulting with someone at your institute who has R programming experience.

ADD REPLY
0
Entering edit mode

Ok sure,

Thank you for your time and explanation.

Best

ADD REPLY
0
Entering edit mode

For whoever is interested, what worked for me was:

  con = 4
  clin_con <- colnames(coldata[con])
  clin_con <-  paste("~",clin_con)



  dds <- DESeqDataSetFromMatrix(
    countData = countdata,
    colData = coldata,
    design = as.formula(clin_con))

Best

ADD REPLY

Login before adding your answer.

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