I would like to generate a batch-corrected expression matrix from RNA-seq data which is NOT on a log2 scale.
After looking at similar posts, it is commonly advised to use limma's removeBatchEffect on the output generated by the rlog function from DESeq2:
dds <- makeExampleDESeqDataSet() dds$batch <- factor(rep(c("A","B"), each = 3)) rld <- rlog(dds) mod <- model.matrix(~ condition, colData(rld)) assay(rld) <- limma::removeBatchEffect(assay(rld), batch = rld$batch, design = mod)
Would it be correct to simply inverse the log2 transformation to get the desired matrix?
normcounts <- counts(dds, normalized = TRUE) # normalized counts with batch normcounts.batch <- 2 ^ assay(rld) # normalized counts without batch
Doing it this way, the batch-corrected counts seem to be on a different scale than the normalized counts matrix. Therefore, would it be better to run the batch effect removal on the normalized counts matrix:
mod <- model.matrix(~ condition, colData(rld)) normcounts.batch <- limma::removeBatchEffect(normcounts, batch = rld$batch, design = mod)
I'm unsure as to whether the removeBatchEffect function requires the input values to be on a log2 scale?