Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • How to exclude the unmapped pair reads in bam files

    There is a bam file with the pair-end reads alignment.

    I want to exclude the reads only when neither of pair reads are mapped onto the genome.
    What command I should type?

    I have tried samtools view -f 2, which just removed the pair if either one is unmapped.( The same as samtools view -F 12 )

    Besides, samtools view -F 4 or samtools view -F 8 will remove a read while the other is mapped.

    Thanks!

    Best regards!

  • #2
    I would suggest to go through the file a couple of times, first to take the half mapped reads, and then the ones completely mapped:

    samtools view -F 4 -f 8 input.bam > only_this_end_mapped.sam
    samtools view -F 8 -f 4 input.bam > only_that_end_mapped.sam
    samtools view -F 12 input.bam > both_ends_mapped.sam

    And then, merge them.

    Alternatively, you could select the reads that you want to exclude, write their names in a file, and use that list as a filter with Picard's FilterSamReads:

    samtools view -f 12 input.bam | cut -f 1 > blacklist
    java -jar FilterSamReads.jar INPUT=input.bam FILTER=excludeReadList READ_LIST_FILE=blacklist OUTPUT=clean.bam

    Comment


    • #3
      Thanks for your reply Lluc!

      It seem no other method can be faster... I would like to try the first one you mention above.
      Hoping someone could write a program in C or C++, which can make it faster.

      Best regards!

      Comment

      Latest Articles

      Collapse

      • 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
      • seqadmin
        Strategies for Sequencing Challenging Samples
        by seqadmin


        Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
        03-22-2024, 06:39 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, 04-11-2024, 12:08 PM
      0 responses
      30 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 10:19 PM
      0 responses
      32 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 09:21 AM
      0 responses
      28 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-04-2024, 09:00 AM
      0 responses
      53 views
      0 likes
      Last Post seqadmin  
      Working...
      X