Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • How to filter paired reads with one is mapped and the other is unmapped

    Hi everybody,

    I want to filter the paired reads that one is mapped and the other is unmapped from bam file created by Bowtie2 with paired-end reads. Can it be done by samtools view?

    Many thanks!

  • #2
    Code:
    samtools view -f 8 -F 4 -b foo.bam > foo.filtered.bam
    That'll get you reads that are mapped with unmapped mates.

    Comment


    • #3
      Thanks!I am new to samtools. The following is my analysis.

      samtools view -f 8 -F 4 -b from.bam > mapped.bam
      This is for the mapped reads with unmapped mates
      Flagstat:
      3390726 + 0 in total (QC-passed reads + QC-failed reads)
      0 + 0 duplicates
      3390726 + 0 mapped (100.00%:-nan%)
      3390726 + 0 paired in sequencing
      1509156 + 0 read1
      1881570 + 0 read2
      0 + 0 properly paired (0.00%:-nan%)
      0 + 0 with itself and mate mapped
      3390726 + 0 singletons (100.00%:-nan%)
      0 + 0 with mate mapped to a different chr
      0 + 0 with mate mapped to a different chr (mapQ>=5)

      samtools view -F 8 -f 4 -b from.bam > unmapped.bam
      This is for the unmapped reads with mapped mates
      Flagstat:
      3390726 + 0 in total (QC-passed reads + QC-failed reads)
      0 + 0 duplicates
      0 + 0 mapped (0.00%:-nan%)
      3390726 + 0 paired in sequencing
      1881570 + 0 read1
      1509156 + 0 read2
      0 + 0 properly paired (0.00%:-nan%)
      0 + 0 with itself and mate mapped
      0 + 0 singletons (0.00%:-nan%)
      0 + 0 with mate mapped to a different chr
      0 + 0 with mate mapped to a different chr (mapQ>=5)

      So the values for the paired reads with one is mapped and the other is unmapped:
      one read: mapped, the mate is unmapped
      the other: unmapped, the mate is mapped
      Last edited by Shenglin; 04-22-2014, 05:44 AM.

      Comment


      • #4
        -F 8 -f 4 will yield unmapped reads with mapped mates, but flagstat doesn't count mapped mates unless the read being looked at is also mapped (thus, the singleton metric with -f 8 -F 4).

        Comment


        • #5
          Yes, many thanks!
          I have another question: could samtools view be used to filter paired reads with upstream read is reverse stranded and downstream read is forward stranded (that means two reads with diverge direction)?

          Comment


          • #6
            Originally posted by Shenglin View Post
            Yes, many thanks!
            I have another question: could samtools view be used to filter paired reads with upstream read is reverse stranded and downstream read is forward stranded (that means two reads with diverge direction)?
            Those will be considered improper pairs, if the aligner was assuming normal Illumina fragment library orientation, so you just need to filter for proper pairs.

            Comment


            • #7
              Originally posted by Brian Bushnell View Post
              Those will be considered improper pairs, if the aligner was assuming normal Illumina fragment library orientation, so you just need to filter for proper pairs.
              Jein, to borrow a word from German. While looking for mapped reads lacking the properly-paired bit will likely get the alignments in question, you'll also get alignments distanced further apart than the aligner expected (or on different chromosomes, should any such alignments exist). The only reliable way to do this is to script things in a convenient language (I'd recommend python with pysam).

              Comment

              Latest Articles

              Collapse

              • seqadmin
                Latest Developments in Precision Medicine
                by seqadmin



                Technological advances have led to drastic improvements in the field of precision medicine, enabling more personalized approaches to treatment. This article explores four leading groups that are overcoming many of the challenges of genomic profiling and precision medicine through their innovative platforms and technologies.

                Somatic Genomics
                “We have such a tremendous amount of genetic diversity that exists within each of us, and not just between us as individuals,”...
                05-24-2024, 01:16 PM
              • 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...
                05-06-2024, 07:48 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by seqadmin, 06-03-2024, 06:55 AM
              0 responses
              12 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 05-30-2024, 03:16 PM
              0 responses
              26 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 05-29-2024, 01:32 PM
              0 responses
              29 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 05-24-2024, 07:15 AM
              0 responses
              215 views
              0 likes
              Last Post seqadmin  
              Working...
              X