Difference of difference, paired design
2
0
Entering edit mode
Bloodgas • 0
@bloodgas-21280
Last seen 4.7 years ago

Gene expression was quantified before and after exercise.

Exercise was performed in two conditions: untrained and trained, but it is the same individuals in both conditions.

How do I get genes that increase/decrease more after exercise in the trained vs untrained state?

Mark! I do not want to compare «before» values between untrained/trained, only the difference of difference: (after-before)trained - (after-before)untrained

edger deseq2 limma • 1.7k views
ADD COMMENT
1
Entering edit mode

I've been trying to suggest that users not tag the names of many different methods when posting questions, as this triggers emails to all the developers involved. I understand the desire to have many developers look at your question, but it's not really support for a specific package anymore, but general strategies for analysis.

ADD REPLY
0
Entering edit mode

I am sorry, I didn't know!

ADD REPLY
1
Entering edit mode
@gordon-smyth
Last seen 1 hour ago
WEHI, Melbourne, Australia

For limma or edgeR you need a factor Patient and another factor Group taking on levels untreated.before", 'untreated.after', 'treated.before and treated.after.

In limma it would go something like:

design <- model.matrix(~0+Group+Patient)
Contrast <- makeContrast( Diff.of.Diff =
  (treated.after - treated.before) - (untreated.after - untreated.before),
  levels = design)
fit <- lmFit(y, design)
fit2 <- contrasts.fit(fit, Contrast)
fit2 <- eBayes(fit)
topTable(fit2)
ADD COMMENT
0
Entering edit mode

Hi, thank you. I have, but Im still not quite sure how to get the difference in slopes comparing the two conditions. I do not want to compare absolute expression levels, only the increases/decreases.

ADD REPLY
1
Entering edit mode

You know, it would really help if you had provided a sample table. Let's just make one up:

# 6 individuals, first 3 are trained.
individuals <- gl(6, 2)
trained <- factor(rep(c("Y", "N"), each=6))
exercise <- factor(rep(c("before", "after"), 6))
exercise <- relevel(exercise, "before")

Then you should just do:

design <- model.matrix(~0 + individuals + trained:exercise)
design <- design[,!grepl("before", colnames(design))] # get to full rank.

The first 6 coefficients represent the fitted log-expression for each individual before exercise. The last two coefficients represent the log-fold change upon exercise in each training regime, i.e., your "slope". (Your terminology doesn't really make sense as you don't have a numerical time point, but whatever.) You can then compare them to each other to see if the exercise has a different effect between trained and untrained individuals - this is a standard test for non-zero interactions.

ADD REPLY
0
Entering edit mode

Sorry, double posted..

ADD REPLY
0
Entering edit mode

Sorry, double posted..

ADD REPLY
0
Entering edit mode

Hi, thank you very much! Extremely helpful.

ADD REPLY
0
Entering edit mode

Absolutely beautiful both Gordon and Aron! Sorry that I did not understand it the first time.

ADD REPLY
0
Entering edit mode
swbarnes2 ★ 1.3k
@swbarnes2-14086
Last seen 15 hours ago
San Diego

So you have 4 groups, A,B,C and D. A and B are trained, A and C are before exercise?

To compare A to B or A to C in DESeq, see what the vignette does here:

http://bioconductor.org/packages/devel/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#interactions

To get (A/B)/(C/D) go to "The different response in genotypes (interaction term)"

https://rpubs.com/ge600/deseq2

ADD COMMENT
0
Entering edit mode

Hi, I have one group of subjects. First, we obtained a baseline sample (A), then an after exercise sample (B). Then, the subjected underwent an intervention. After the intervention, the same subjects were tested again: new baseline sample (A) and a new after exercise sample (B).

So, I want to compare the response from A to B before the intervention, to the response from A to B after the intervention.

Mark! I do not want the main effect of the intervention, only the interaction between exercise (A and B) and intervention.

Mark! The design is paired, the same subjects are measured every time.

ADD REPLY
0
Entering edit mode

Yelling "Mark!" at people when you are asking for help is very impolite.

ADD REPLY
0
Entering edit mode

What does yelling 'Mark! ' mean, exactly? I originally thought Bloodgas thought Mike Love's name was Mark, but maybe I am out of the loop?

ADD REPLY
1
Entering edit mode

FWIW, I think that the OP is using that word to mean, "note that", not referring to a person.

ADD REPLY
1
Entering edit mode

Oh, hi Mark! ;-D

  • Bullets are so passe

as are, these days

  1. Numbered lists

I do suppose.

Which is your haiku of the day(TM)

ADD REPLY
0
Entering edit mode

It meant "note that". Because you obviously misunderstood the design quite severely.

ADD REPLY
0
Entering edit mode

Mark! I didn't misunderstand anything about the design, instead I misunderstood what yelling Mark!!1!! means to kids these days.

Mark! Gordon Smyth already answered your question, to which you responded with some nonsense about slopes, which what? This is an ANOVA, so there aren't any slopes. Instead you are computing means of groups (or differences between means, depending on the coefficients). And Gordon is the man, so if he tells you how to do it, rest assured that's how to do it. And he full well understands that you have repeated measurements, and gave you the correct answer for testing the interaction, given your design.

Mark! Then Aaron Lun gave you another way to analyze your data. And he is the man as well, so now you have two perfectly good answers to your question. The only thing Aaron didn't explicitly describe is to say that you have to make a contrast between the last two coefficients. Well, he did describe it, but didn't give the exact code required.

Mark! Being repeatedly rude to people is, like, what Twitter is for. Doing that on this site, where people are volunteering their time to help random internet strangers is not the best way to proceed. Unless your goal is to get ignored, in which case, it will probably work.

ADD REPLY
0
Entering edit mode

What are you taking.. Cant you see Gordon edited the answer? Thats why I did not understand it at first. Also, "Mark!" was meant to clear up what was misinterpret in the first response by swbarnes2.

Then you all have at me.. Nice forum.. Calling me rude? Sure you pissed me of by accusing me of being childish. But why on earth would I call someone named Mike for Mark?! It was only meant to clear up a misunderstanding..

Being drunk when reading online or something? Getting some steam out online by bashing random people?

ADD REPLY

Login before adding your answer.

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