Hi there,
I've got a little snippet that merges raw (non-shrunk) log-FC values with shrinkage values
model.str <- "~ genotype + individual"
eset$genotype <- factor(eset$genotype, levels=c('WT', 'KO'))
eset.model <- DESeqDataSet(eset, design=formula(model.str))
eset.fit = DESeq(eset.model)
eset.fit.results.nofilter <- as.data.frame(results(eset.fit, independentFiltering=F))
eset.fit.results = as.data.frame(lfcShrink(eset.fit, contrast=c('genotype', levels(eset.model$genotype))))
eset.fit.results = eset.subset.results[!is.na(eset.fit.results$padj)),]
colnames(eset.fit.results) <- c('shrunk.baseMean', 'shrunk.log2FoldChange',
'shrunk.lfcSE', 'shrunk.stat', 'shrunk.pvalue', 'shrunk.padj')
eset.fit.results <- merge(eset.fit.results.nofilter, eset.fit.results[,c('shrunk.log2FoldChange',
'shrunk.pvalue', 'shrunk.padj', 'shrunk.baseMean')],
by.x='row.names', by.y='row.names', all=T)
Shrinkage is doing what should be expected; but lfcShrink appears to be switching all the signs (as though the factor levels had been reversed)
of course I can manually switch the sign; and switching the levels
lfcShrink(eset.fit, contrast=c('genotype', rev(levels(eset.model$genotype)))))
also works. Will it always be the case that for a 2-level factor, the contrast ordering should be the reverse of the factor level ordering?