This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to pull specific comparisons for DEGs in DESeq2? Trying to understand setting contrasts after the model matrix and results lists.

Is there a way to get DEG results from a specific subset of comparisons without subsetting the samples prior to running the DESeq model?

I'm working with an RNAseq dataset that came from an experiment with a multifactorial design: two timepoints, two temperatures, and two drugs. The full model and contrasts give me the following list of results:

dds <- DESeqDataSetFromMatrix(gcounts, colData = colData, 
                          design = formula(~ drug * temp * timepoint))
ddsR <- DESeq(dds, minReplicatesForReplace = Inf)
res <- results(ddsR, contrast = c(0, 1, 0, 0, 0, 0, 0, 0)) #example

#[1] "Intercept"
#[2] "drug_B_vs_A"
#[3] "temp_18_vs_14"
#[4] "timepoint_24h_vs_0h"
#[5] "drugB.temp18"
#[6] "drugB.timepoint24h"
#[7] "temp18.timepoint24h"
#[8] "drugB.temp18.timepoint24hpi"

I'm trying to understand whether there's a way to get results like: a comparison of DEGs in temp18 and temp14 at 0h only, irrespective of their differences at 24h. 0h is currently set as the baseline for this factor.

Is there a way to do that by using the results(ddss, contrast = (x,x,x,x,x,x)) line? (some combination of 0, 1, and -1?) Or would I need to subset samples and run models on those smaller sample sets?

deg rnaseq deseq2

Maybe it's because my head is bad at understanding traditional interaction models, but I always encode things ike that as factorial combinations. For example drugA_temp1_timepointX as a single factor, lets call it group. Then the design is ~0 + group in the simplest case so every factor level is a coefficient in the design matrix. From there it is simply to make the contrasts as you do in this numeric fashion. You could also easily test averages, say the average of two levels versus the average of two other levels, though I generally find this easier to do in limma than DESeq2. Say for a design with four levels, an average contrast could be (.5, .5, -.5, -.5).

0 answers

No answers yet.

Log in to answer this question.