This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Get the regions mapped by the same reads

Dear all,

I have a bam file and a bed file (with a thousand regions).

I would like, for each region in the bed, to get all the reads that mapped to this region (relatively straightforward) but I also want to get, if any, other regions mapped by these same reads.

I could not find something useful in this regard in the sam documentation.

bedtools bamtobed also seems promising but I think it output only the unique alignments (from the documentation: "There is not yet a standard method for reporting multiple alignments using BAM.").

I mapped Illumina reads with bwa, so I have access to the XA tags. But it will take a long time to parse the bam to get the XA tag for each region of the bed.

Does anyone tried to do something similar ?

bam sam bed reads multiple alignments

No, I only have one bam file, and I am looking for reads that map to multiple regions in this one bam.

Have you tried samtools view -F 0x04 filename.bam?

You can take the not primary alignments with samtools

samtools view -f 256 in.bam

I think I will use these commands to get the multiple mapped reads and then get the other regions from the XA flag, thanks !

0 answers

No answers yet.

Log in to answer this question.