<p>I have RNA seq data and I need to use combat to remove the batch effects. Somehow when I run it, it isnt actually doing anything.</p>
<p>The code:</p>
<pre><code>dds &lt;- DESeq(dds, betaPrior=TRUE)
normalized_counts &lt;- counts(dds, normalized=TRUE)
log2 = log2(normalized_counts+1)

modcombat = model.matrix(~dex, metadata)# - with metadata being a variable containing treatment or control (under dex column) and batch and name of each patient.

com&lt;-ComBat(log2, metadata$Batch, mod = modcombat)
</code></pre>
<p>Its supposed to be 4 different batches, but in the com variable I can see that the values have stayed the same as in log2.</p>
<p>What could be wrong? Would appreciate any help!</p>

CC BY-SA 4.0
2021-03-10T19:28:46.620Z
side note: combat is a linear batch correction method and does not perform optimally on all datasets
Chris_Rands
CC BY-SA 4.0
2021-03-10T20:39:39.353Z
Are you completely sure that you can make the model matrix with a mix of column names as strings and object names like that?
swbarnes2
CC BY-SA 4.0
2021-03-12T08:38:35.370Z
No I am not sure about that, I havent found a good explanation for how to make the model matrix. I suspect my problem is there maybe.
emma
<rna-seq><batch-effects><combat>
How to use combat in order to remove batch effects?
# How to use combat in order to remove batch effects?

(Asked by: username_0 on 2021-03-10)

I have RNA seq data and I need to use combat to remove the batch effects. Somehow when I run it, it isnt actually doing anything.
The code:
dds <- DESeq(dds, betaPrior=TRUE)
normalized_counts <- counts(dds, normalized=TRUE)
log2 = log2(normalized_counts+1)

modcombat = model.matrix(~dex, metadata)# - with metadata being a variable containing treatment or control (under dex column) and batch and name of each patient.

com<-ComBat(log2, metadata$Batch, mod = modcombat)

Its supposed to be 4 different batches, but in the com variable I can see that the values have stayed the same as in log2.
What could be wrong? Would appreciate any help!

**Tags:** rna-seq, batch-effects, combat
> **Comments:**
> **username_1**: side note: combat is a linear batch correction method and does not perform optimally on all datasets  
> **username_2**: Are you completely sure that you can make the model matrix with a mix of column names as strings and object names like that?  
> **username_0**: No I am not sure about that, I havent found a good explanation for how to make the model matrix. I suspect my problem is there maybe.  

---

## 0 answers

