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 ?
Is bedtools multicov what you are looking for ?
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
I think I will use these commands to get the multiple mapped reads and then get the other regions from the XA flag, thanks !