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
            Recent Advances in Sequencing Analysis Tools
            by seqadmin


            The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
            Today, 07:48 AM
          • 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

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Today, 07:17 AM
          0 responses
          11 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-02-2024, 08:06 AM
          0 responses
          19 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-30-2024, 12:17 PM
          0 responses
          20 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-29-2024, 10:49 AM
          0 responses
          28 views
          0 likes
          Last Post seqadmin  
          Working...
          X