Question: Responder Vs Non-Responders Paired Comparison DESeq2
0
gravatar for penny.lane
4 weeks ago by
penny.lane0
penny.lane0 wrote:

There was an earlier post that nicely explained how to build a design matrix for a paired responder vs non-repsonder analysis: https://support.bioconductor.org/p/95143/#124666

In that example, the assumption was that there were two conditions, "screen" and "treatment", representing before and after treatment. What if instead there are several conditions, say "before", "during" and "after", how would you specify that you want "before" to be the base case for your comparison to "during" or "after"? It seems like it might be defaulting to alphabetical order, leaving me without the "groupY.conditionAfter" and "groupN.conditionAfter" variables to contrast.

I also commented in that other post if anyone prefers to respond there. Thanks!

deseq2 • 73 views
ADD COMMENTlink modified 4 weeks ago by Michael Love25k • written 4 weeks ago by penny.lane0

No one really wants to hold your hand through how to use the software. You will get better answers if you read through some DESeq tutorials, write some code using the examples you see, and ask about specific lines that you think might not be doing what you want them to.

ADD REPLYlink written 4 weeks ago by swbarnes2330

As far as I can tell this is not explained in the tutorials (I have read them). I'd be happy to be wrong about that though, so please point me to where you see it explained and I'll be out of your hair. It does not seem to be a very basic form of analysis and one that could easily be done wrong because of the wonky way in which the design matrix is generated. This is why I was seeking an expert opinion. Not everyone is an expert. Not everyone is a nice person either I guess.

ADD REPLYlink written 4 weeks ago by penny.lane0
Answer: Responder Vs Non-Responders Paired Comparison DESeq2
1
gravatar for Michael Love
4 weeks ago by
Michael Love25k
United States
Michael Love25k wrote:

https://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#note-on-factor-levels

ADD COMMENTlink written 4 weeks ago by Michael Love25k

I had actually tried to implement the relevel approach outlined in the vignette, but it didn't fix mt problem, so I wasn't sure it was actually what I needed to do. However, since you sent me back there I tried modifying my original code. I think the code in the vignette assumes a dds object exists to modify before actually calling DESeqDataSetFromTximport or whatever method is used to construct the dds, no? So, my original/failed code was this:

dds = DESeqDataSetFromTximport(txi, colData=sampleTable, ~1)
dds$VisitGroup = relevel(dds$VisitGroup, ref = "BeforeTx")
model = model.matrix( ~Responder + Responder:PtId + Responder:VisitGroup, sampleTable)
model = model[, -which(apply(model, 2, function(x) all(x==0)))]
dds = DESeq(dds, full=model, betaPrior=FALSE)
res = results(dds, contrast=list("ResponderY.VisitGroupDuringTx", "ResponderN.VisitGroupDuringTx"))

If I instead relevel the sampleTable before passing it to DESeqDataSetFromTximport, this seems to fix my problem:

sampleTable$VisitGroup = relevel(dds$VisitGroup, ref = "BeforeTx")
dds = DESeqDataSetFromTximport(txi, colData=sampleTable, ~1)
model = model.matrix( ~Responder + Responder:PtId + Responder:VisitGroup, sampleTable)
model = model[, -which(apply(model, 2, function(x) all(x==0)))]
dds = DESeq(dds, full=model, betaPrior=FALSE)
res = results(dds, contrast=list("ResponderY.VisitGroupDuringTx", "ResponderN.VisitGroupDuringTx"))

Does that look right to you Michael?

ADD REPLYlink written 4 weeks ago by penny.lane0

The top code doesn't work because you create model from sampleTable which has the wrong coding.

ADD REPLYlink written 4 weeks ago by Michael Love25k

Ah, I see, but do you agree that in the context of this code it's simpler just to relevel the sampleTable from the outset rather than to have to do it twice? Just want to make sure I'm not still misunderstanding something.

ADD REPLYlink written 4 weeks ago by penny.lane0

Either way is fine. When you relevel the column of the DESeqDataSet, you haven’t modified the sampleTable obviously. R doesn’t back propagate your changes to objects used to construct dds.

ADD REPLYlink written 4 weeks ago by Michael Love25k

OK, thanks again Michael.

ADD REPLYlink written 4 weeks ago by penny.lane0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 193 users visited in the last hour