Hi Everyone,
I am working on RNA-Seq data. I'm using DESeq2 for my analysis. I have 20 samples from 3 batches. I am testing for 2 conditions, cond1 and cond2.
dds<-DESeqDataSetFromMatrix(countData=countTable3,colData=coldata,design = ~cond1*cond2)
When i performed PCA, I could clearly see some batch effect. I read in the forum that adding batch to the design in DESeq removes the batch effect. But I am not sure if this is the right way to go about it because I can still see the same batch effect
dds<-DESeqDataSetFromMatrix(countData=countTable3,colData=coldata,design = ~batch+cond1*cond2)
I tried using Combat but I'm unable to use combat results in DESeq. It gives me the following error.
Error in DESeqDataSet(se, design = design, ignoreRank) :
some values in assay are negative
I am not sure if removeBatchEffects() function can be used with DESeq. Can someone please help me out here.
Thanks
I agree, that is the way DESeq handles batch effects. Is there a way to visualize or diagnose how the batch effects were modeled? For example, I can do
plotPCA(rlog(dds))
to plot the PCA showing the batch effects. I model the effects as~ condition + replicate
and compute the results. Now I'd like some way to see how the resulting log2fc was only due to the condition and the replicate/batch effects are "separate".I am thinking the some transform of
coef(dds)
provides what I am thinking of.You should always put the condition of interest at the end of the design formula for safety (see vignette).
You can just use
plotCounts
with intgroup=c("replicate","condition") to split apart replicate effects and condition effects. The batch term fit by DESeq2 will be the mean of the normalized count which are plotted.Thank you. Well, plotCounts plots the counts for a single gene, so yes, you can see the batch effects and the treatment effect in the counts. But I was thinking of a way to look at the (all/top) genes like plotPCA does and conclude aha! DESeq2 correctly modeled/removed the batch effects so the log2fc/pvalues we are getting are due to the treatment and not the batch effects.
Batch effects are gene-specific, and DESeq2 fits gene-specific coefficients for the batch term. If you want to get an idea how much batch variability contributes to a PCA plot, I've recommended the following approach on the support site before:
variance stabilize the counts, apply limma's removeBatchEffect to assay(vsd), then use plotPCA to plot the residuals.
An example:
Make some simulated data with a batch effect:
VST, remove batch effect, then plotPCA:
Hi, Michael. Can I used the batch removed data in the DESeq2 function? If I can, how should I run it? Using vsd instead of dds?
DESeq() only takes as input the original counts, and this is on purpose. This is the optimal statistical approach. To account for batch, you put the variables at the beginning of the design, e.g. ~batch + condition
Hi Michael,
Could you please state how I can get DEG from the data where we have removed batch effect using VST.
Hoping for prompt response.
Thanks.
See this answer directly above your comment from 17 months ago:
https://support.bioconductor.org/p/76099/#101057
Hi Michael,
There is a great difference between the normalized count table when using: vsd <- vst(dds) assay(vsd) WITHOUT batch removal
compared to the normalized count table generated by DESeq2 using: dds <- estimateSizeFactors(dds); counts(dds, normalized=TRUE)
In order to compare the two normalized count tables I use: library(dataCompareR) rCompare(normalizedcounts, normalizedtransformed_counts)
What is essentially the great difference between the two normalizations?
Thanks
This is answered below in my reply to Adam’s answer.
Thank you.
By saying "This is just normalization for sequencing depth" you mean when using the following DESeq function: DESeq2 using: dds <- estimateSizeFactors(dds); counts(dds, normalized=TRUE) ?
So the other normalization (ie vst(dds)) takes other things into consideration? Best
Neither remove batch effects, which is the point of the question in the FAQ in the vignette.
Hello Michael, I am sorry for reviving an old post, but there seems to be an small error in the answer. As Gordon Smith recommends
the design matrix should be included in the call to removeBatchEffect,
so that the third line should be
Hope I got it right...
Sure, I’ll add this to the documentation for unbalanced batch designs.
One more question removal the batch effect : Which is more correct : to remove the batch effect from the normalized counts and to perform vst on the corrected results, or to transform the normalized counts via vst, and remove the batch effect from the vst transformed results, like in the code above?
Using the approach in the vignette (the latter).