Hello fellow DESeq2 users,
Using the example given in the vignette regarding interaction terms, I am unable to output a results table where the log2 fold changes are shrunken using lfcShrink(). I tried using the 'contrast' and 'coef' arguments but have had luck with neither. I also tried using 'coef=8', as this is the number of coefficients in resultsNames(dds)
Code:
colData <- as.data.frame(cbind(condition, genotype))
rownames(colData) <- colnames(countData)
dds <- DESeqDataSetFromMatrix(countData = countData, colData = colData, design = ~ genotype + condition + genotype:condition)
dds <- DESeq(dds, fitType='local')
resultsNames(dds)
[1] "Intercept" "genotype_II_vs_I" "genotype_III_vs_I"
[4] "condition_B_vs_A" "genotypeII.conditionB" "genotypeIII.conditionB"
res <- results(dds, contrast = c("genotype", "II", "I" )) #equivalent to res <- results(dds, name="genotype_II_vs_I" )
resLFC <- lfcShrink(dds, contrast = c("genotype", "II", "I" ), res=res)
Error in averagePriorsOverLevels(objectNZ, betaPriorVar) :
beta prior for genotypeI.conditionA,genotypeII.conditionA,genotypeIII.conditionA,genotypeI.conditionB is not greater than 0
resLFC <- lfcShrink(dds, coef=2, res=res)
Error in designAndArgChecker(object, betaPrior) :
betaPrior=FALSE should be used for designs with interactions
I know by default the betaprior=FALSE, so I am not sure about the second error. How can I get the shrunken LFC as I do when making pairwise comparisons?
-R
Hi Michael,
Thanks for the response. I look forward to seeing that functionality in the new release. For now, wouldn't it be the same if I instead used a group design where I made the same pairwise comparison as above and then used lfcShrink()?
Code:
Yes, if you want to compare individual groups, this is a perfectly valid approach.
I have noticed before that the results of using these two different design approaches have minor variations when looking at equivalent comparisons. Is there a brief explanation for this?
You mean the group based analysis with shrinkage compared to the interaction term without shrinkage? Or both without shrinkage? The latter can be just numeric convergence differences (likelihood doesn't change more in relative amount than a threshold so the iterative method stops).
Yes, I meant the latter. Could you explain what you mean by numeric convergence differences?
Two numbers not being equal to all decimal places, because the differences in that number (say the coefficient) was within the tolerance of the iterative algorithm with respect to changes in the objective.