DESeq2 - lfcShrink reversing sign for all logFCs - clarification on "contrast" argument?
1
0
Entering edit mode
@christopherlhartl-10884
Last seen 4.5 years ago

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)

reversal

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?

deseq2 • 531 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 9 hours ago
United States

There’s a lot going on in your code, and it looks like you’re not explicitly asking for a particular contrast in results(). Try that first, which probably will fix your plot.

ADD COMMENT

Login before adding your answer.

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