Entering edit mode
6.0 years ago
salamandra
▴
550
Hi, a question regarding deseq2 design formula.
I have two variables time and treatment and I know how to get genes which fold-change of treated vs untreated varies with time:
Table <- data.frame(sampleName = sampleNames, fileName = sampleFiles, time = time, Treatment = Treatment, condition = condition)
Table
sampleName fileName time Treatment condition
1 A1_1 1A_ATCACG_counts t0 Treat Treatt0
2 A1_2 2A_CAGATC_counts t0 Treat Treatt0
3 B1_1 2B_ACTTGA_counts t0 Untreat Untreatt0
4 B1_2 3B_CGATGT_counts t0 Untreat Untreatt0
5 A2_1 2C_GATCAG_counts t1 Treat Treatt1
6 A2_2 3C_TTAGGC_counts t1 Treat Treatt1
7 B2_1 2E_GGCTAC_counts t1 Untreat Untreatt1
8 B2_2 3F_GCCAAT_counts t1 Untreat Untreatt1
dds3 <- DESeqDataSetFromHTSeqCount(sampleTable = Table, design= ~ Treatment + time + Treatment:time)
ddsHTSeq3 <- DESeq(dds3)
resultsNames(ddsHTSeq3)
"Intercept" "Treatment_Treat_vs_Untreat" "time_t1_vs_t0" "TreatmentTreat.timet1"
resHTSeqb <- results(ddsHTSeq3, name = "TreatmentTreat.timet1")
But how do to get genes which fold-change of time1 vs time0 varies with treatment? cause
results(ddsHTSeq3, name = "timet1.TreatmentTreat")
doesn't work
In the example we test whether treatment depends on the time: results(ddsHTSeq3, name = "TreatmentTreat.timet1") what I wanted to know is how to test whether time depends on the treatment, that is if time1 vs time0 fold-change is the same for treated and untrated samples or if it changes.
In the example, 'TreatmentTreat.timet1' relates to the
time
effect forTreatmentTreat
VersusTreatmentUnTreat
. That is, it tests whether the effect of time is different between treated and untreated. I feel that this indirectly answers your question.Another way to look at it:
In your current example, 'time_t1_vs_t0' relates to
timet1
versustimet0
forTreatmentUntreat
. If you re-level Treatment to haveTreat
as the reference level, then 'time_t1_vs_t0' would relate totimet1
versustimet0
forTreatmentTreat
. This would tell you if treated and untreated change in the same way independently at the 2 time-points.-----------------------------------------------------
Also be sure to read the DESeq2 vignette, in particular:
Thank you for your time. From what you pointed to in theDESeq2 vignette I intrepert as
time_t1_vs_t0
is time t1 vs t0 for the refference level (Untreat
)Looking at the example in the vignette (easier to understand). To test if the condition effect (A vs B) varies with genotype (genotype II vs I) we would do:
To test if the genotype effect (genotype II vs I) varies with condition effect (A vs B) I believe we would do:
But then noticed that
results(ddsHTSeq3, name="genotypeII.conditionB")
is same asresults(ddsHTSeq4, name="conditionB.genotypeII")
Maybe, both tests are actually testing for the same...Yes, they would be looking at the same thing. Changing the order of the interaction term will not make any difference (e.g.
Condition:Time
orTime:Condition
). What you need to do is re-level the factors in your metadata in order to change the category that is the reference level.Take a look at Devon's answer, here: A: DESeq2 doesn't compare the right ctrl vs treatment?
sorry, i'm not understanding we have a table like this:
and we do:
if we relevel like you suggested, for e.g. like this:
and when do:
There is no term "conditionB.genotypeII" available. The only thing relevel seems to do is change reference level in each factor.
what I wanted was to know how condition effect (B vs A with A as ref level) varies with genotype (II vs I with I as ref level) I do not want to know how genotype effect (II vs I with I as ref level) varies with condition (B vs A with A as ref level)
Yes, that is all that relevel does, but that is key to know.
For what you want, if genotype 'I" is the reference level:
If you want something more complex, then consider merging multiple factors into the same factor (e.g. your
group
factor)). If you are still not content with my explanation, then please try the Bioconductor support forumFor example, if you abandon the interaction terms in your model and instead just use
~ group
, you could then generate different results with pairwise comparisons:Please take time to read the vignette for interactions: https://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#interactions