text: user4881: I have aligned a nanopore data set to a reference genome with graphmap, minimap2 and BLASR. The alignment results are stored in BAM files. 
  I would like to do some concordance assessment, looking at the number of base pairs that are mapped to the same position by different aligner.   
  Are there any tools or ways that allow me to do this effectively?
  
  user4937: I don't know of a single tool that can read multiple sets of BAM files and compare them. But you can use the Sam_Reader python3 module to create a csv file that summarizes each position in the genome for each of your 3 results and then compare them manually.
  It should be installable with:
  pip3 install sam_reader
  
  And then generate the CSV with 
  from sam_reader import Sam_Reader
  my_files = Sam_Reader('my_bam_file_or_folder/')
  my_files.per_base_stats(write_file='new_file.csv')
  
  *but FYI this module requires pysam, which does not work on windows
  
  user96: I'm not aware of any tools that do this out-of-the-box. Assuming some programming experience, it would be fairly straightforward to implement this in Python using pysam (or htslib bindings for your favorite scripting language). In particular, the pileup is a very useful data structure.
  Ultimately, you'll need to store an index of reference sequence positions by read name and position.
  read 1, offset 0 --> chrom 3, offset 248879
  read 1, offset 1 --> chrom 3, offset 248880
  read 1, offset 2 --> chrom 3, offset 248882
  ...
  ...
  ...
  
  Once you've done this for a pair of BAM files, computing the concordance statistics involves trivial set operations.
  There are some important practical considerations though. If you implement the approach completely in memory, it will only be tractable for small-ish BAM files. It wouldn't take very many reads (relatively speaking) to overwhelm available RAM on a laptop or desktop. For large BAM files, you might even overwhelm the available RAM on a big-memory server. Alternatively, you could store the indexes in an on-disk database such as sqlite3. This would keep RAM requirements low, but would slow things down substantially.
  I think the most reasonable approach would be to process the BAM files in batches: grab all the reads in a 100kb region (or whatever size makes sense), compute the index, store the congruence statistics, move on to the next 100kb region and repeat, and then aggregate statistics when all regions have been processed.
  
original_text: 4881: <p>I have aligned a nanopore data set to a reference genome with graphmap, minimap2 and BLASR. The alignment results are stored in BAM files. </p>
  
  <p>I would like to do some concordance assessment, looking at the number of base pairs that are mapped to the same position by different aligner.   </p>
  
  <p>Are there any tools or ways that allow me to do this effectively?</p>
   4937: <p>I don't know of a single tool that can read multiple sets of BAM files and compare them. But you can use <a href="https://github.com/KyleLevi/SAM_Reader#how-do-i-examine-the-matches-at-each-individual-position-in-the-genome" rel="nofollow noreferrer">the Sam_Reader python3 module</a> to create a csv file that summarizes each position in the genome for each of your 3 results and then compare them manually.</p>
  
  <p>It should be installable with:</p>
  
  <pre><code>pip3 install sam_reader
  </code></pre>
  
  <p>And then generate the CSV with </p>
  
  <pre><code>from sam_reader import Sam_Reader
  my_files = Sam_Reader('my_bam_file_or_folder/')
  my_files.per_base_stats(write_file='new_file.csv')
  </code></pre>
  
  <p>*but FYI this module requires <a href="https://pysam.readthedocs.io/en/latest/installation.html" rel="nofollow noreferrer">pysam</a>, which does not work on windows</p>
   96: <p>I'm not aware of any tools that do this out-of-the-box. Assuming some programming experience, it would be fairly straightforward to implement this in Python using <a href="https://pysam.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">pysam</a> (or htslib bindings for your favorite scripting language). In particular, the pileup is a very useful data structure.</p>
  
  <p>Ultimately, you'll need to store an index of reference sequence positions by read name and position.</p>
  
  <pre><code>read 1, offset 0 --&gt; chrom 3, offset 248879
  read 1, offset 1 --&gt; chrom 3, offset 248880
  read 1, offset 2 --&gt; chrom 3, offset 248882
  ...
  ...
  ...
  </code></pre>
  
  <p>Once you've done this for a pair of BAM files, computing the concordance statistics involves trivial set operations.</p>
  
  <p>There are some important practical considerations though. If you implement the approach completely in memory, it will only be tractable for small-ish BAM files. It wouldn't take very many reads (relatively speaking) to overwhelm available RAM on a laptop or desktop. For large BAM files, you might even overwhelm the available RAM on a big-memory server. Alternatively, you could store the indexes in an on-disk database such as <a href="https://docs.python.org/3/library/sqlite3.html" rel="nofollow noreferrer">sqlite3</a>. This would keep RAM requirements low, but would slow things down substantially.</p>
  
  <p>I think the most reasonable approach would be to process the BAM files in batches: grab all the reads in a 100kb region (or whatever size makes sense), compute the index, store the congruence statistics, move on to the next 100kb region and repeat, and then aggregate statistics when all regions have been processed.</p>
  