Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Counting Reads in BAM file by Region

    Greetings!

    I am a neophyte Bioinformaticist working with SAMtools for the very first time. To make matters worse, I have to work in Java, which is not a language I am particularly familiar with. To make matters even worse, it seems that most individuals run SAMtools functions through command line, while I am working towards compilable code in an IDE instead.

    My goal is to create java code that will count the number of reads in a region of a BAM file specified by the user. Could anyone start me off in the right direction by pointing out what specific SAMtools functions I should be looking at to accomplish this? I would be eternally grateful for any help.

  • #2
    Generally this is done using bedtools or featurecounts.

    http://bedtools.readthedocs.org/en/l.../coverage.html (https://github.com/arq5x/bedtools2)

    http://www.ncbi.nlm.nih.gov/pubmed/24227677 (http://subread.sourceforge.net)

    You will need samtools to generate the necessary BAM.
    Last edited by GenoMax; 03-24-2014, 10:54 AM.

    Comment


    • #3
      Originally posted by CodeHippo View Post
      To make matters worse, I have to work in Java
      Nonono, Java makes things BETTER!

      But have you considered Picard? It has most or all of the functionality of samtools, and is written in Java, so you'll be able to access the bam-related functions directly.

      Comment


      • #4
        Originally posted by Brian Bushnell View Post
        Nonono, Java makes things BETTER!

        But have you considered Picard? It has most or all of the functionality of samtools, and is written in Java, so you'll be able to access the bam-related functions directly.
        Picard is actually exactly what I'm using! I've found a very nice piece of Java code that uses Picard to count the total number of reads in a BAM file right here (courtesy of Andrew E. Bruno):



        My main issue now I suppose is figuring out how to take it a step further and use Picard to count only the number of reads within a specified region, and not the whole BAM file. I guess the real problem here isn't the Java, but the SAM/BAM terminology and interfaces that I'm not familiar with.

        I am searching through the javadoc for Picard and the BAMIndexMetaData Class looks like it has what I'm looking for, but I'm still not entirely sure how it works. Oh well, I guess it's back to flipping burgers for a living.

        Comment


        • #5
          The methods queryOverlapping() or queryContained() in SAMFileReader should give you want you want:

          Comment

          Latest Articles

          Collapse

          • seqadmin
            Essential Discoveries and Tools in Epitranscriptomics
            by seqadmin




            The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
            04-22-2024, 07:01 AM
          • seqadmin
            Current Approaches to Protein Sequencing
            by seqadmin


            Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
            04-04-2024, 04:25 PM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Yesterday, 11:49 AM
          0 responses
          13 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-24-2024, 08:47 AM
          0 responses
          16 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-11-2024, 12:08 PM
          0 responses
          61 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 10:19 PM
          0 responses
          60 views
          0 likes
          Last Post seqadmin  
          Working...
          X