I encountered problems when dealing with paired-end read using readGAlignmentPairs function. I tested on the data the package comes with (i.e. extdata), no problem, this function returns the paired end data as expected. However when I applied to my own paired-end data (aligned from tophat), I got no records for some reason. I tested it using testPairedEndBam function, it returned TRUE. I also manually examined the SAM file, all reads appeared in pairs. Anyone has any hints on this?
> library(Rsamtools) > library("GenomicAlignments") > setwd("~/degnorm") #read in paired-end bam file > bamfile="SRR873822.bam" > ##testing whether single or paired-end > testPairedEndBam(bamfile)  TRUE > > ##subsetting the bam file for test > t <- scanBamHeader(bamfile)[][["targets"]] > which <- GRanges(names(t), IRanges(1, unname(t))) > > ##only look at chrI > param <- ScanBamParam(which=which, what=character(), flag=scanBamFlag(isProperPair=TRUE, + isDuplicate=FALSE, + isSecondaryAlignment=FALSE)) > galp2 <- readGAlignmentPairs(bamfile, use.names=TRUE, param=param) > galp2 GAlignmentPairs object with 0 pairs, strandMode=1, and 0 metadata columns: seqnames strand : ranges -- ranges <Rle> <Rle> : <IRanges> -- <IRanges> ------- seqinfo: 25 sequences from an unspecified genome