Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-10T19:28:46.620Z
Comments.Text: side note: combat is a linear batch correction method and does not perform optimally on all datasets
Comments.UserDisplayName: Chris_Rands
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-10T20:39:39.353Z
Comments.Text: Are you completely sure that you can make the model matrix with a mix of column names as strings and object names like that?
Comments.UserDisplayName: swbarnes2
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-12T08:38:35.370Z
Comments.Text: 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.
Comments.UserDisplayName: emma
Tags: <rna-seq><batch-effects><combat>
Title: How to use combat in order to remove batch effects?
ThreadText: # 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
  
  