Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • paired-end, bam-file-format

    1.) Having a bam-file of paired-end data, how can I find out what the pairs are? I.e. which sequence is the start and which one the end of which pair?

    2.) If I only want the 5-prime end of each pair: how can I remove all the downstream pairs?

    Thanks!

  • #2
    Look at the FLAG bit field.

    Comment


    • #3
      Originally posted by maubp View Post
      Look at the FLAG bit field.
      Code:
      0x1 template having multiple fragments in sequencing
      0x2 each fragment properly aligned according to the aligner
      0x4 fragment unmapped
      0x8 next fragment in the template unmapped
      0x10 SEQ being reverse complemented
      0x20 SEQ of the next fragment in the template being reversed
      0x40 the rst fragment in the template
      0x80 the last fragment in the template
      0x100 secondary alignment
      0x200 not passing quality controls
      0x400 PCR or optical duplicate
      I do not understand the semantics of this and anyway I guess it's a little bit hard working with the bam-files directly anyway. I mean how are you supposed to look at the bit-field, with a hex-editor?!

      Is there an easier way? For example, can't I convert to bed-format, so that the paired-end information is retained? I tried bamToBed, but there as well I don't see how the pairs are matched. I also tried "view" from samtools.

      Comment


      • #4
        Try samtools view with -X to explain the flags.

        Comment


        • #5
          Use Pysam in Python!

          You can use Pysam in Python.

          First, you have to install this library.

          After that, you have to type the following code:
          ====================================

          import pysam
          samfile = pysam.Samfile("ex1.bam", "rb")
          pairedreads = pysam.Samfile("allpaired.bam", "wb", template=samfile)
          for read in samfile.fetch():
          if read.is_paired:
          pairedreads.write(read)

          pairedreads.close()
          samfile.close()
          =====================================

          This code is from: http://wwwfgu.anat.ox.ac.uk/~andreas...tools/api.html

          There, you can read more about it.

          The function read.is_paired looks, if a read is a paired-end read or a single read.

          I hope this helps you...

          Comment

          Latest Articles

          Collapse

          • seqadmin
            New Genomics Tools and Methods Shared at AGBT 2025
            by seqadmin


            This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

            The Headliner
            The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
            03-03-2025, 01:39 PM
          • seqadmin
            Investigating the Gut Microbiome Through Diet and Spatial Biology
            by seqadmin




            The human gut contains trillions of microorganisms that impact digestion, immune functions, and overall health1. Despite major breakthroughs, we’re only beginning to understand the full extent of the microbiome’s influence on health and disease. Advances in next-generation sequencing and spatial biology have opened new windows into this complex environment, yet many questions remain. This article highlights two recent studies exploring how diet influences microbial...
            02-24-2025, 06:31 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Today, 07:27 AM
          0 responses
          7 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, Yesterday, 12:50 PM
          0 responses
          13 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-03-2025, 01:15 PM
          0 responses
          183 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 02-28-2025, 12:58 PM
          0 responses
          280 views
          0 likes
          Last Post seqadmin  
          Working...
          X