Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • louis7781x
    Member
    • Oct 2010
    • 74

    #1

    pick out nonmapped pairs from bwa

    Hi,

    I have used bwa to align paired-end read against to refseq and output sam file.

    Now,I have a problem.

    If I want to pick out the read like bowtie's parameter --un.

    How can I do like bowtie's output?

    Like bowite's maual

    Paired-end reads will be written to two parallel files with _1 and _2 inserted in the filename, e.g., if <filename> is unaligned.fq, the #1 and #2 mates that fail to align will be written to unaligned_1.fq and unaligned_2.fq respectively.
  • swbarnes2
    Senior Member
    • May 2008
    • 910

    #2
    As far as I know, there's no way to get it make you the fastq of the unmapped reads. However, you can get a sam/bam file containing only unmapped reads, and from that you can make the fq with a simple script.

    samtools view -F 0x0004 your.bam > unmapped.sam

    the 4 flag is set when the read is unmapped. -F will make sure that only reads with the 4 flag are included in the sam.

    Comment

    • louis7781x
      Member
      • Oct 2010
      • 74

      #3
      Originally posted by swbarnes2 View Post
      As far as I know, there's no way to get it make you the fastq of the unmapped reads. However, you can get a sam/bam file containing only unmapped reads, and from that you can make the fq with a simple script.

      samtools view -F 0x0004 your.bam > unmapped.sam

      the 4 flag is set when the read is unmapped. -F will make sure that only reads with the 4 flag are included in the sam.
      Thanks!!

      But it has a problem, if pairs has only one mapped,and the other is nonmapped.

      I can't pick out both reads.

      I know bowtie --un in pairs,if one is map ,one is numapped. it will also output to unmapped_1.fa and unmapped_2.fa

      Comment

      • swbarnes2
        Senior Member
        • May 2008
        • 910

        #4
        samtools view -F 0x0004 your.bam > unmapped.sam

        Will get all the unmapped reads

        samtools view -F 0x0008 your.bam > unmapped_mates.sam

        will get all the reads whose mates are unmapped.

        Or, once you have the names of the unmapped read, you could go through your fastqs and pull out both reads that have that name

        Comment

        • louis7781x
          Member
          • Oct 2010
          • 74

          #5
          Originally posted by swbarnes2 View Post
          samtools view -F 0x0004 your.bam > unmapped.sam

          Will get all the unmapped reads

          samtools view -F 0x0008 your.bam > unmapped_mates.sam

          will get all the reads whose mates are unmapped.

          Or, once you have the names of the unmapped read, you could go through your fastqs and pull out both reads that have that name

          OK I see ,Thanks a lot!

          Comment

          • volks
            Member
            • Jun 2010
            • 80

            #6
            samtools view -Sb -F 2 your.sam > not_proper_pair.bam

            will give you the reads which are not mapped in proper pairs. the output can be converted to fastq or used in BWA directly (-b option).

            Comment

            • louis7781x
              Member
              • Oct 2010
              • 74

              #7
              Originally posted by volks View Post
              samtools view -Sb -F 2 your.sam > not_proper_pair.bam

              will give you the reads which are not mapped in proper pairs. the output can be converted to fastq or used in BWA directly (-b option).
              Hi,thanks for yorr reply

              I have seen manual in bwa

              -b Specify the input read sequence file is the BAM format. For paired-end data, two ends in a pair must be grouped together and options -1 or -2 are usually applied to specify which end should be mapped. Typical command lines for mapping pair-end data in the BAM format are:
              bwa aln ref.fa -b1 reads.bam > 1.sai
              bwa aln ref.fa -b2 reads.bam > 2.sai
              bwa sampe ref.fa 1.sai 2.sai reads.bam reads.bam > aln.sam

              -0 When -b is specified, only use single-end reads in mapping.
              -1 When -b is specified, only use the first read in a read pair in mapping (skip single-end reads and the second reads).
              -2 When -b is specified, only use the second read in a read pair in mapping.
              I don't understand why -b parapeter can converted to fastq in BWA directly?

              Comment

              • volks
                Member
                • Jun 2010
                • 80

                #8
                Originally posted by louis7781x View Post
                I don't understand why -b parapeter can converted to fastq in BWA directly?
                with -b you can use a BAM as input, for example if you want to align the unmapped reads to a different genome. it is not converted to fastq, but there are other tools for that.

                Comment

                Latest Articles

                Collapse

                • SEQadmin2
                  Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                  by SEQadmin2



                  Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                  Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                  ...
                  10-14-2026, 09:55 AM
                • SEQadmin2
                  New Genomics Technologies Take Aim at Long-Standing Limits
                  by SEQadmin2


                  Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                  We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                  ...
                  09-28-2026, 10:25 AM

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by SEQadmin2, 10-22-2026, 11:13 AM
                0 responses
                27 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 10-22-2026, 10:48 AM
                0 responses
                20 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 10-15-2026, 10:52 AM
                0 responses
                36 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 10-14-2026, 05:39 AM
                0 responses
                43 views
                0 reactions
                Last Post SEQadmin2  
                Working...