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
        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, Today, 08:06 AM
      0 responses
      4 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-30-2024, 12:17 PM
      0 responses
      13 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-29-2024, 10:49 AM
      0 responses
      19 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-25-2024, 11:49 AM
      0 responses
      26 views
      0 likes
      Last Post seqadmin  
      Working...
      X