Answers.Body: <p><code>samtools rmdup</code> and <code>samtools markdup -r</code> do the same thing. Without the <code>-r</code> flag <code>samtools markdup</code> only flags the duplicates.</p>
  
  <p>You'll have to run <code>samtools fixmate -m</code> and sort the output to add ms and MC tags to prepare the file for <code>markdup</code>..</p>
  
  <p>According to the current <a href="http://www.htslib.org/doc/samtools.html" rel="nofollow noreferrer">documentation</a>, <code>rmdup</code> is obsolete. Please do not use <code>rmdup</code>. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-03T14:01:49.103Z
Answers.LastActivityDate: 2018-07-03T14:01:49.103Z
Answers.UserDisplayName: Kohl Kinning
Answers.Body: <p><strong>TL;DR:</strong> just use <code>markdup</code>.</p>
  
  <p><code>rmdup</code> removes duplicates from BAM, while <code>markdup</code>, like Picard's <code>MarkDuplicates</code>, marks duplicates by default without hard removal – the latter is usually the desired behavior. In addition, <code>markdup</code> implements a better algorithm that takes care of more corner cases and gives more consistent results.</p>
  
  <p>PS: to emphasize – I see no point to use <code>samtools rmdup</code> nowadays. It has been declared obsolete as @kohlkopf said.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-12T15:16:54.837Z
Answers.Text: Could you elaborate regarding why not performing hard removal "is usually the desired behavior"? For instance, what useful stuff is typically done using the duplicates?
Answers.UserDisplayName: bli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-03T14:03:51.340Z
Answers.LastActivityDate: 2018-07-03T14:29:53.890Z
Answers.LastEditDate: 2018-07-03T14:29:53.890Z
Answers.UserDisplayName: user172818
Body: <p>What is difference between samtools mark duplicates and remove duplicates ?  Is it necessary to mark duplicates before removing duplicates with samtools?</p>
  
Tags: <phylogenetics><ngs><samtools>
Title: Difference between samtools mark duplicates and samtools remove duplicates?
ThreadText: # Difference between samtools mark duplicates and samtools remove duplicates?
  
  (Asked by: username_0 on 2018-07-03)
  
  What is difference between samtools mark duplicates and remove duplicates ? Is it necessary to mark duplicates before removing duplicates with samtools?
  
  **Tags:** phylogenetics, ngs, samtools
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-07-03. Score: 3 | Accepted answer
  
  `samtools rmdup` and `samtools markdup -r` do the same thing. Without the `-r` flag `samtools markdup` only flags the duplicates.
  
  You'll have to run `samtools fixmate -m` and sort the output to add ms and MC tags to prepare the file for `markdup`..
  
  According to the current [documentation](http://www.htslib.org/doc/samtools.html), `rmdup` is obsolete. Please do not use `rmdup`.
  
  
  ---
  
  ### Answer by username_2 on 2018-07-03. Score: 2
  
  **TL;DR:** just use `markdup`.
  
  `rmdup` removes duplicates from BAM, while `markdup`, like Picard's `MarkDuplicates`, marks duplicates by default without hard removal – the latter is usually the desired behavior. In addition, `markdup` implements a better algorithm that takes care of more corner cases and gives more consistent results.
  
  PS: to emphasize – I see no point to use `samtools rmdup` nowadays. It has been declared obsolete as @kohlkopf said.
  
  > **Comments:**
  > **username_3**: Could you elaborate regarding why not performing hard removal "is usually the desired behavior"? For instance, what useful stuff is typically done using the duplicates?  
  
  ---
  
  