DESeq2 contrast and complex comparisons
1
0
Entering edit mode
ribioinfo ▴ 100
@ribioinfo-9434
Last seen 3.8 years ago

Hello, I would like to do what is explained in edgeR user guide: https://bioconductor.org/packages/release/bioc/vignettes/edgeR/inst/doc/edgeRUsersGuide.pdf

in the section 3.3.1 pages 35-36.

I would like to use all the experimental factors combined into one combined factor (group column) then I would like to create a contrast like in the example: DrugvsPlacebo.1h = (Drug.1h-Drug.0h)-(Placebo.1h-Placebo.0h).

Reading the DESeq2 manual I can use contrast using a list of two character vectors or a numeric contrast vector. Both requires to use the names in resultsNames but in resultsNames I do not get all the names that I need.

Is there a way to obtain DrugvsPlacebo.1h = (Drug.1h-Drug.0h)-(Placebo.1h-Placebo.0h) using all the experimental factors combined into one combined factor (group column) using DESeq2?

Thank you.

deseq2 • 1.2k views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 1 day ago
United States

This is described in the vignette, see "combine the factors of interest into a single factor with all combinations of the original factors..."

ADD COMMENT
0
Entering edit mode

Thank you. I was using that solution but how can you do something like this: DrugvsPlacebo.1h = (Drug.1h-Drug.0h)-(Placebo.1h-Placebo.0h)?

My problem is not to create a group column as in the edgeR example but the contrast. If I understood the contrast correctly I can only do these comparisons: Drug.1vs0 = Drug.1h-Drug.0h, Drug.2vs0 = Drug.2h-Drug.0h, Placebo.1vs0 = Placebo.1h-Placebo.0h, Placebo.2vs0 = Placebo.2h-Placebo.0h, DrugvsPlacebo.0h = Drug.0h-Placebo.0h

To do this: DrugvsPlacebo.1h = (Drug.1h-Drug.0h)-(Placebo.1h-Placebo.0h), I have to do the Drug.1vs0 test and the Placebo.1vs0 test then this (Drug.1vs0) vs (Placebo.1vs0 ) test. I understood how to do it on edgeR using makeContrasts but I am not sure how to do it using DESeq2. My solution was to try to use resultNames in contrast, but I do not get all the names that I need, since with only the one combined column I think that I cannot do it.

Is there a way to do that comparison just creating the column in the vignette?

Thank you.

ADD REPLY
0
Entering edit mode

You can do it with numeric contrasts. If you use a design of ~0+group then each element of resultsNames will be a combination. Then you can use a numeric contrast=c(-1,0,1,0,...).

If you want to have (A-B)-(C-D), this reduces to (A+C)-(B+D), so you put +1 for A and C, and -1 for B and D in the contrast vector.

ADD REPLY
0
Entering edit mode

Thank you! I am trying to summarize what I understood about DESeq2:

1) The one combined column approach it is easy to understand it can be used with the LFC shrinkage but does not allow complex design as discussed above.

2) The solution with ~0+group allows me to use the one column approach with the possibility to do complex design using the numerical contrasts but the LFC shrinkage cannot be used.

3) The solution with ~Treat + Time + Treat:Time allows me to use the LFC shrinkage and complex designs like DrugvsPlacebo.1h = (Drug.1h-Drug.0h)-(Placebo.1h-Placebo.0h) but I cannot test all the conditions, for example: Drug.1vs0 = Drug.1h-Drug.0h

Could you please help me to understand what would be the better solution?

The solution 2 allows me to do one analysis using the same model but I have to give up the possibility to use the LFC shrinkage.

If I use 1) and 3) I can use the LFC shrinkage and all the comparison that I need but I have to do two different analysis the first one with ~group and the second one with ~Treat + Time + Treat:Time. Would it be correct and can I obtain comparable results since I am using two different designs?

Thank you.

ADD REPLY
0
Entering edit mode

LFC shrinkage can be used for the group approach with type="ashr". See this vignette section

You can also perform LFC shrinkage for drug 1hr vs 0hr with type="apeglm", you would just need to change the design or change factor levels. You can generally get just about any effect as a single coefficient with the right design and refactoring of levels. And as we say in the vignette, "the dispersion does not have to be estimated again, as the designs are equivalent, up to the meaning of the coefficients. Instead, one need only run nbinomWaldTest to re-estimate MLE coefficients". But if you're not sure about how to rearrange design or factor levels to get the effect as a single coefficient, just stick with type="ashr".

ADD REPLY
0
Entering edit mode

Thanks!

Is it normal that using that the results change a little bit between ~0+group and ~group?

I am trying to use a new design as explained in the vignette: "We show how the coefficients change with model.matrix, but the user would, for example, either change the levels of dds$condition or replace the design using design(dds)<-, then run nbinomWaldTest followed by lfcShrink."

I tried to change dds$condition: dds$condition=new_matrix

and then: design(dds)=~colnameinnewmatrix

but I got an error that say that all the variables in the design formula must be columns in colData. I am importing the data from rsem using txtimport.

Should I do something else?

Thank you

ADD REPLY
0
Entering edit mode

Give a shot debugging this a bit more — the message is very self explanatory.

ADD REPLY
0
Entering edit mode

I tried to create a matrix using moldel.maltrix, I converted it in a dataframe and I loaded it in DESeqDataSetFromTximport using ~A as design where A is column of the dataframe and B is the reference level. If I check resultsNames() I obtain A1vs0 and I think that it is considering the samples of A vs all all the other samples: B, C etc. I would like to have Avs_B as I obtained running the standard workflow loading one column from a dataframe. What should I do?

Thank you.

ADD REPLY
0
Entering edit mode

"I tried to create a matrix using moldel.maltrix, I converted it in a dataframe and I loaded it in DESeqDataSetFromTximport"

I don't see how this approach will work.

I'd recommend to just use numeric contrast with ~0 + group and type="ashr".

ADD REPLY
0
Entering edit mode

Thank you. I know that you can create different and complex designs with DESeq2, I was wondering if this simple strategy can give good results using DESeq2:

Assuming two conditions: A and B and 2 time points: 0 and 1. the conditions are merged in one column, for example A1. result1= A1 vs A0 result2= B1 vs B_0 Union of the differentially expressed genes of result1 and result2 to check what is changing during the time. I found this paper where it seems that the pairwise comparisons can give good results: https://academic.oup.com/bib/article/20/1/288/4364840

Could it be a reasonable strategy using DESeq2?

Thank you.

ADD REPLY
0
Entering edit mode

The choice of analysis and statistical design is really up to you. There are many choices, and we provide software for formulating a specific hypothesis in terms of a GLM and then estimating coefficients, etc. I unfortunately don't have sufficient time to provide statistical analysis recommendations on the support site, but have to restrict myself to software usage questions.

ADD REPLY

Login before adding your answer.

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