SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
BWA Reports High Mapping Quality for Poorly Mapped Pairs mdjones66 Bioinformatics 1 01-16-2012 09:29 PM
Identifying chromosomal gene pairs stephenhart Bioinformatics 0 12-14-2011 06:02 AM
Pick out high significant mutation from *.bed . louis7781x RNA Sequencing 0 08-05-2011 06:14 AM
single 18S pick rteixeira RNA Sequencing 4 06-03-2011 10:02 AM
pick up some unigene sequences based on a id set Lisa Bioinformatics 5 02-24-2010 12:01 AM

Reply
 
Thread Tools
Old 07-22-2011, 09:59 AM   #1
louis7781x
Member
 
Location: Hong Kong

Join Date: Oct 2010
Posts: 74
Default 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

Quote:
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.
louis7781x is offline   Reply With Quote
Old 07-22-2011, 10:19 AM   #2
swbarnes2
Senior Member
 
Location: San Diego

Join Date: May 2008
Posts: 912
Default

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.
swbarnes2 is offline   Reply With Quote
Old 07-22-2011, 10:40 AM   #3
louis7781x
Member
 
Location: Hong Kong

Join Date: Oct 2010
Posts: 74
Default

Quote:
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
louis7781x is offline   Reply With Quote
Old 07-22-2011, 02:05 PM   #4
swbarnes2
Senior Member
 
Location: San Diego

Join Date: May 2008
Posts: 912
Default

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
swbarnes2 is offline   Reply With Quote
Old 07-22-2011, 07:08 PM   #5
louis7781x
Member
 
Location: Hong Kong

Join Date: Oct 2010
Posts: 74
Default

Quote:
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!
louis7781x is offline   Reply With Quote
Old 07-23-2011, 03:32 AM   #6
volks
Member
 
Location: hd.de

Join Date: Jun 2010
Posts: 81
Default

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).
volks is offline   Reply With Quote
Old 07-23-2011, 07:43 PM   #7
louis7781x
Member
 
Location: Hong Kong

Join Date: Oct 2010
Posts: 74
Default

Quote:
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

Quote:
-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?
louis7781x is offline   Reply With Quote
Old 07-23-2011, 11:39 PM   #8
volks
Member
 
Location: hd.de

Join Date: Jun 2010
Posts: 81
Default

Quote:
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.
volks is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 01:47 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO