This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Split paired-end reads BAM file into Forward and Reverse Strands

Hello,

I’m trying to split BAM files with paired-end reads into forward and reverse strands. I know samtools view -F 16 and samtools view -f 16 separates into forward and reverse strands, but I’ve read in some forums that it doesn’t deal well with paired-end reads. What other methods would people recommend for paired-end reads?

Thank you for your help!

rna-seq bam

Thank you! I will look into his approach.

I've read the tutorial you sent me and I have a question that you might know the answer to. I'm trying to understand how the SAM flags work in the script from the tutorial. My original SAM file has flags: 99, 147, 163, and 83, but this script uses flags: 128, 80, 144, and 64. Do you know the difference between these flags? Would the split.sh script still separate my BAM file into forward and reverse strands with the flags it lists or should I edit the script to reflect my flags (99, 147, 163, 83)? Thank you for your help!!

Thank you for the explanation!! I appreciate it!

2 answers

I'm not sure what you mean by "doesn't deal well". In almost every case, one read will align in the forward direction, and the other in reverse, so if everything is working right, every pair should be split between the two directions.

If you want an alternative way, you may sort the bam files by read-names and then convert bam files into fastq files using Samtools. After that, you can split the fastq files to forward and reverse read files by a simple bash script(or python whatever you feel comfortable with).

Thanks for the advice!

Log in to answer this question.