Question: Difference of difference, paired design
0
14 days ago by
Bloodgas0
Bloodgas0 wrote:

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

limma edger deseq2 • 190 views
modified 11 days ago by swbarnes2220 • written 14 days ago by Bloodgas0
1

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.

I am sorry, I didn't know!

Answer: Difference of difference, paired design
1
12 days ago by
Gordon Smyth38k
Walter and Eliza Hall Institute of Medical Research, Melbourne, Australia
Gordon Smyth38k wrote:

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)


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.

1

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.

Sorry, double posted..

Sorry, double posted..

Hi, thank you very much! Extremely helpful.

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

Answer: Difference of difference, paired design
0
11 days ago by
swbarnes2220
swbarnes2220 wrote:

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

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.

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

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?

1

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

1

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)

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

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.

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?