text: user14902: I want to find and compare the results from STAR and BWA- MEM mapped. I have 150bp paired end reads in sorted.bam files in each case and i want to find in each case uniquely mapped reads, number of reads mapped to multiple loci and number of unmappped reads.
  Especially for uniquely mapped reads i tried different solutions from biostars and this Obtaining uniquely mapped reads from BWA mem alignment but i dont know what to trust,
  Could you please suggest the best way to find mapping results from bam paired end files ?
  
  user15084: Bam files contain a MAPQ field that informs on whether an alignment is unique or not. With STAR, a MAPQ value of 255 means the read is mapped uniquely and a score lower than 255 means not unique.
  You can use samtools on a bam file to count or output the uniquely or multimapped reads by filtering for the MAPQ as described here: https://groups.google.com/forum/#!topic/rna-star/ipHc9FrgaPU
  For example, count uniquely mapped reads:
  samtools view -c -q 255 myBamFile.bam
  Output uniquely mapped reads:
  samtools view -q 255 myBamFile.bam
  There are differences between STAR and BWA MAPQ output though. see here for details: https://sequencing.qcfail.com/articles/mapq-values-are-really-useful-but-their-implementation-is-a-mess/
  
original_text: 14902: <p>I want to find and compare the results from STAR and BWA- MEM mapped. I have 150bp paired end reads in sorted.bam files in each case and i want to find in each case uniquely mapped reads, number of reads mapped to multiple loci and number of unmappped reads.</p>
  <p>Especially for uniquely mapped reads i tried different solutions from biostars and this <a href="https://bioinformatics.stackexchange.com/questions/508/obtaining-uniquely-mapped-reads-from-bwa-mem-alignment">Obtaining uniquely mapped reads from BWA mem alignment</a> but i dont know what to trust,</p>
  <p>Could you please suggest the best way to find mapping results from bam paired end files ?</p>
   15084: <p>Bam files contain a MAPQ field that informs on whether an alignment is unique or not. With STAR, a MAPQ value of 255 means the read is mapped uniquely and a score lower than 255 means not unique.</p>
  <p>You can use samtools on a bam file to count or output the uniquely or multimapped reads by filtering for the MAPQ as described here: <a href="https://groups.google.com/forum/#!topic/rna-star/ipHc9FrgaPU" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/rna-star/ipHc9FrgaPU</a></p>
  <p>For example, count uniquely mapped reads:
  <code>samtools view -c -q 255 myBamFile.bam</code><br />
  Output uniquely mapped reads:
  <code>samtools view -q 255 myBamFile.bam</code></p>
  <p>There are differences between STAR and BWA MAPQ output though. see here for details: <a href="https://sequencing.qcfail.com/articles/mapq-values-are-really-useful-but-their-implementation-is-a-mess/" rel="nofollow noreferrer">https://sequencing.qcfail.com/articles/mapq-values-are-really-useful-but-their-implementation-is-a-mess/</a></p>
  