# DEseq2 contrast in two time points

I need help with some clarifications please

I have control versus treatment in two time points like

> y
X condition time
1       CTRL_24_hrs_replicate1   control   24
2       CTRL_24_hrs_replicate2   control   24
3       CTRL_24_hrs_replicate3   control   24
4  treatment_24_hrs_replicate1        t   24
5  treatment_24_hrs_replicate2        t   24
6  treatment_24_hrs_replicate3        t   24
7       CTRL_48_hrs_replicate1   control   48
8       CTRL_48_hrs_replicate2   control   48
9       CTRL_48_hrs_replicate3   control   48
10 treatment_48_hrs_replicate1        t   48
11 treatment_48_hrs_replicate2        t   48
12 treatment_48_hrs_replicate3        t   48
>


I want to see the difference of treatment versus control from 24 hours to 48 hours, so this is not just the difference of treatment versus control or difference between 24 versus 48 hours rather the treatment versus control from 24 hours to 48 hours

This is what I have done so far

>  dds <- DESeqDataSetFromMatrix(countData=count,
+                                 colData=design,
+                                 design=~condition, tidy = FALSE)
Warning message:
In DESeqDataSet(se, design = design, ignoreRank) :
some variables in design formula are characters, converting to factors
>   dds$$group <- factor(paste0(dds$$time, dds$condition)) > design(dds) <- ~ group > dds <- DESeq(dds) estimating size factors estimating dispersions gene-wise dispersion estimates mean-dispersion relationship final dispersion estimates fitting model and testing > resultsNames(dds) "Intercept" "group_24IT_vs_24control" "group_48control_vs_24control" "group_48IT_vs_24control" >  How to find the difference at time point 24 vs 48 in condition ? I searched and I found a similar thing but I don't know how to adopt that to my data results(dds, contrast=list(c("time_4_vs_0", "conditionLD.time4")), test="Wald")  I tried this and I got error > results(dds, contrast=list(c("time_48_vs_24", "conditionIT.time24")), test="Wald") Error in checkContrast(contrast, resNames) : all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)' >  Can you help me in adopting this to my data please? ## 2 Answers You can't figure out how to adapt this to your data? http://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#contrasts Ignore resultsNames. You don't need them for simple comparisons like you want to do. • Sorry even by ignoring resultsNames, I don't know what to put into this formula. For instance what I should put instead of time_4_vs_0 ? This gave me error > results(dds, contrast=list(c("time_48_vs_24", "conditionIT.time24")), test="Wald") Error in checkContrast(contrast, resNames) : all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)' > Commented Oct 8, 2021 at 17:26 • Where have you looked? Did you read the link I posted? Did you look at the entry for deseq2 results? rdrr.io/bioc/DESeq2/man/results.html Can you not find a single tutorial anywhere which shows you how to use specify the contrast? Commented Oct 8, 2021 at 17:54 you can do: data$$condition_new <- as.factor(paste0(data$$condition, " - ", data$time))
dds <- DESeqDataSetFromMatrix(countData=count,
colData=design,
design=~condition_new
, tidy = FALSE)
enter code here
results(dds, contrast=c("condition_new", "control - 24", "condition - 4"))


I hope it helps.