bbmap command to extract mapped and unmapped pair end reads
1
1
Entering edit mode
7.8 years ago
Bioinfonext ▴ 470

Hi please suggest command to extract mapped and unmapped pair end reads from bam file.

RNA-Seq • 6.1k views
ADD COMMENT
1
Entering edit mode
7.8 years ago

It's more straightforward from a fastq file... in that case you can use "outu=" for unmapped pairs and "outm=" for the mapped pairs in a single command. From a bam you need to use two commands:

reformat.sh in=x.bam out=y.bam mappedonly
reformat.sh in=x.bam out=z.bam unmappedonly

Depending on exactly what you want to do with unmapped mates of mapped reads, you can get a finer degree of control with these two flags:

requiredbits=0          (rbits) Toss sam lines with any of these flag bits unset.  Similar to samtools -f.
filterbits=0            (fbits) Toss sam lines with any of these flag bits set.  Similar to samtools -F.
ADD COMMENT
0
Entering edit mode

I dont want any unmapped mate of mapped reads in case of extracting mapped pair end read.

same is in the case of unmapped reads only unmapped reads with pair when extracting unmapped reads.

ADD REPLY
0
Entering edit mode

OK, then use the reformat commands I gave with "mappedonly" and "unmappedonly".

ADD REPLY
0
Entering edit mode

when running above cammand:

Found samtools. /home/yog/software/bbmap/reformat.sh in=216_5W_Ca1.bam out=216_5W_Ca1.mapped.bam mappedonly

Input is being processed as unpaired

Waiting on header to be read from a sam file. Input: 17336990 reads 2067204125 bases Output: 11202398 reads (64.62%) 1348474253 bases (65.23%)

why it reading input as unpaired?

ADD REPLY
0
Entering edit mode

Sam and bam files are always processed as "unpaired", because Reformat is a streaming tool and there is no way to ensure paired reads in a sam/bam file are located near each other. It doesn't matter in this case - the end result is that you get a file containing all of the mapped records from the input bam, with the read number information intact.

ADD REPLY
0
Entering edit mode

Do I need to sort mapping bam file before extraction fo unmap and mapped reads in bam file format. then need to convert fastq using bamtool.

Is there any direct way to extract pair mapped reads in fastq format from bam file and also unmaaped pair end reads.

ADD REPLY
0
Entering edit mode

Sorting is unnecessary in this case. For fastq output, just change the output names and add "primaryonly":

reformat.sh in=x.bam out=y.fq mappedonly primaryonly
reformat.sh in=x.bam out=z.fq unmappedonly primaryonly
ADD REPLY

Login before adding your answer.

Traffic: 1933 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6