Question: DESeq2 - lfcShrink reversing sign for all logFCs - clarification on "contrast" argument?
0
gravatar for christopherlhartl
4 weeks ago by
christopherlhartl0 wrote:

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 • 63 views
ADD COMMENTlink modified 4 weeks ago by Michael Love26k • written 4 weeks ago by christopherlhartl0
Answer: DESeq2 - lfcShrink reversing sign for all logFCs - clarification on "contrast" a
0
gravatar for Michael Love
4 weeks ago by
Michael Love26k
United States
Michael Love26k wrote:

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 COMMENTlink written 4 weeks ago by Michael Love26k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 439 users visited in the last hour