3
$\begingroup$

I have sam and bam files for the chimeric reads, which come from two different parts of the genome (For example, the first half of the read from part of Chromosome 1 and the second half of the read from part of Chromosome 3). I have removed the low mapping quality reads (MAPQ <= 30) and reads with high mismatches. This might result in some unpaired reads which need to be removed before further analysis. May I ask whether there is any way to remove the unpaired reads in sam/bam files? Thanks!

$\endgroup$
0

1 Answer 1

1
$\begingroup$

The -f option of samtools view is for flags and can be used to filter reads in bam/sam file matching certain criteria such as properly paired reads (0x2) :

samtools view -f 0x2 -b in.bam > out.bam
$\endgroup$
2
  • 1
    $\begingroup$ Thanks. If I remove the low mapping quality reads and reads with high mismatches after the alignment, will the flags be updated? If they are not updated, there will possibly be unpaired reads even if I use flags for filtering in my point of view. $\endgroup$
    – Wang Ming
    Jun 22, 2022 at 6:06
  • $\begingroup$ That is a good question and there is a good change those flags won't be updated, it would need some testing. Here is a post on seqanswers that might help you. $\endgroup$ Jun 22, 2022 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.