I don't completely understand how the paired end mode works. I want to count reads only when both the read and its mate map to the same gene. Here's what I did.
Filtered the bam file to include only reads where the read and its mate were aligned.
Ran featureCounts using the -p option.
Consider these cases.
a. Both the read and and its mate map to the same gene. This is counted and is what I want.
b. The read maps to one gene and its mate maps to another gene. Is this counted? Is it counted for both genes?
c. The read maps to one gene and its mate doesn't overlap any feature in the gtf file. Is this counted. once or not at all?
featureCounts counts fragments, not reads, because both reads from a pair are supposed to have been originated from a single RNA fragment. Moreover, featureCounts only counts when assignment is unambiguous to a single feature. So, a. and c. assigns one count, but b. assigns zero counts to both genes.
a. is basically always counted (unless you play with -P -d -D options and the paired reads are too close/too distant)
b. is not counted unless you specify the -O option
-O Assign reads to all their overlapping meta-features (or features if -f is specified).
c. is counted unless you specify the -B option (I think, but on second thoughts, perhaps I misinterpreted the description)
-B Count read pairs that have both ends successfully aligned only.
Edit: another possibility to enforce both reads to be mapped to the gene of interest it to play with the --minOverlap option:
integer giving the minimum number of overlapped bases required for
assigning a read to a feature (or a meta-feature). For assignment of
read pairs (fragments), numbers of overlapping bases from each read in
the same pair will be summed. If a negative value is provided, the
read will be extended from both ends. 1 by default.
featureCounts counts fragments, not reads, because both reads from a pair are supposed to have been originated from a single RNA fragment. Moreover, featureCounts only counts when assignment is unambiguous to a single feature. So, a. and c. assigns one count, but b. assigns zero counts to both genes.