Hello everyone,
I was exploring my dataset with a three-way interaction design (~TimePoint * Drug * Cell Line
) and decided to check if, when comparing two levels of one of the variables, if the shrunken log2FC using apeglm
would vary when releveled. For example, I want to check if the shrunken log2FC between TimePoint
1 and 10 would vary if we do TimePoint_10_vs_1
or TimePoint_1_vs_10
. I checked and indeed are some relevant differences (I did subtraction of absolute values):
> summary(Dif)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2.703706 -0.000064 0.000000 0.000917 0.000062 1.914137
Now, considering the complexity of my dataset, I decided to check if this would happen in a simpler dataset - so I created an example DESeq Datataset:
set.seed(123)
dds <- makeExampleDESeqDataSet(n = 10000,m=20)
dds
dds_example<-DESeq(dds)
res_BvA_shrink<-lfcShrink(dds_example,coef = "condition_B_vs_A")
dds_example$condition<-relevel(dds_example$condition,ref = "B")
dds_example<-nbinomWaldTest(dds_example)
res_AvB_shrink<-lfcShrink(dds_example,coef = "condition_A_vs_B")
Looking at the difference of absolute values between the two:
> summary(abs(res_BvA_shrink$log2FoldChange)-abs(res_AvB_shrink$log2FoldChange))
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
-3.20841 -0.00003 0.00000 0.00012 0.00002 3.08496 8
Is this expected? Can someone please help me to understand the logic?
Thanks in advance
Thanks ATpoint for your answer!
The issue with that is then it severely hinders the possiblity of using
apeglm
shrinking approach, since we cannot change the reference level.Looking at the link you sent me (thanks once again!) and checking Michael Love answer, I just wanted to additionally say that, in my dataset (the real one, not the example one), I already filter every gene whose mean counts across the samples is below 5:
dm<-dm[rowMeans(assay(dm))>5,]
I took a look and the posterior width for these (fairly rare) examples overlaps zero. So the posterior when it disagrees is not narrow.
Anyway, you can also use ashr if you want releveling to not have an effect.