text: user1696: I have a RNA-seq bam file and there are few reads that are puzzling me.
  According to the bam header, this bam file is sorted by coordinate, created using tophat and markduplicate step is not done. But some reads are marked for being duplicate in the samflag. What is worse is when I run picard markduplicate, these reads' pcr duplicate flag is toggled, marking them not a duplicate. Also I manually found the duplicate of this read (identical reads with same start positions and mates start position) so initial marking looks true.
  So my questions are: 
  Any idea why would this happen?
  Does Tophat mark reads for being duplicate? ( I don't think so)
  And does picard markduplicate toggle the duplicate flag if the reads are already marked as being duplicates?
  Here is how the read looks before and after mark duplicate step.
  Before:
  C0RTF 1187 17 7579880 255 61M10754N40M = 7579927 10902 CTC... 
  0UNP1 163 17 7579880 255 61M10754N40M = 7579927 10902 CTC... 
  
  After Markduplicate:
  C0RTF 163 17 7579880 255 61M10754N40M = 7579927 10902 CTC... 
  0UNP1 163 17 7579880 255 61M10754N40M = 7579927 10902 CTC... 
  
  
  user77: Yes, if MarkDuplicates encounters a pair that's marked as a duplicate that it considers (for whatever reason) to not be a duplicate then it will unset the duplicate mark. You can test this yourself by making a small BAM file either with or without duplicate entries but some marked regardless. In the case of actual duplicates, the duplicate flag will be maintained. In the case where there are no actual duplicates then the flag will be removed. At least that's the case in version 2.14.
  
original_text: 1696: <p>I have a RNA-seq bam file and there are few reads that are puzzling me.</p>
  
  <p>According to the bam header, this bam file is sorted by coordinate, created using tophat and markduplicate step is not done. But some reads are marked for being duplicate in the samflag. What is worse is when I run picard markduplicate, these reads' pcr duplicate flag is toggled, marking them not a duplicate. Also I manually found the duplicate of this read (identical reads with same start positions and mates start position) so initial marking looks true.</p>
  
  <p>So my questions are: </p>
  
  <p>Any idea why would this happen?</p>
  
  <p>Does Tophat mark reads for being duplicate? ( I don't think so)
  And does <code>picard markduplicate</code> toggle the duplicate flag if the reads are already marked as being duplicates?</p>
  
  <p>Here is how the read looks before and after mark duplicate step.<br></p>
  
  <p>Before:</p>
  
  <pre><code>C0RTF 1187 17 7579880 255 61M10754N40M = 7579927 10902 CTC... 
  0UNP1 163 17 7579880 255 61M10754N40M = 7579927 10902 CTC... 
  </code></pre>
  
  <p>After Markduplicate:</p>
  
  <pre><code>C0RTF 163 17 7579880 255 61M10754N40M = 7579927 10902 CTC... 
  0UNP1 163 17 7579880 255 61M10754N40M = 7579927 10902 CTC... 
  </code></pre>
   77: <p>Yes, if MarkDuplicates encounters a pair that's marked as a duplicate that it considers (for whatever reason) to not be a duplicate then it will unset the duplicate mark. You can test this yourself by making a small BAM file either with or without duplicate entries but some marked regardless. In the case of actual duplicates, the duplicate flag will be maintained. In the case where there are no actual duplicates then the flag will be removed. At least that's the case in version 2.14.</p>
  