I'm using readGAlignmentsList from package "GenomicAlignments" to read a paired-end sequencing BAM file, which contains both paired mates and singleton reads (R1 or R2 unmapped).
According to the manual, "readGAlignmentsList pairs records into mates according to the pairing criteria described below. The 1st mate will
always be 1st in the GAlignmentsList list elements that have mate_status set to "mated", and the 2nd mate will always be 2nd." This is easy to understand which one is mate1 or mate2. However, when we only have one mate (i.e. a singleton), readGAlignmentsList shows only one element for that read pair. In this case, I want to know how to tell which mate it is.
The only way I can think of is to use flag = ScanBamFlag(isFirstMateRead = TRUE) or flag = ScanBamFlag(isSecondMateRead = TRUE)in ScanBamParam. But this requires me to read BAM file twice, and moreover, I'll lose track of paired reads.
Could use the flag utilities like
bamFlagAsBitMatrix()
andbamFlagTest()
.Nice! thanks to both.