I realized there aren't accessible resources that clearly explain what the different lines of the flagstat output mean (This answer was useful). Here is what I found based on some other answers on forums and playing around with my own files (paired-end reads mapped using bwa mem). Some of these lines may apply regardless of aligner but others may not.
total (QC-passed reads + QC-failed reads): Total number of reads including other such as supplementary
primary: Total number of reads that were provided as input for mapping
secondary: see here
supplementary: see here
duplicates: see here
primary duplicates: primary reads that were marked as duplicates
mapped: number of mapped reads including supplementary
mapped %: percentage of mapped reads including supplementary (denominator is the number of total reads)
primary mapped: number of mapped reads that are labelled primary (just the number of mapped reads out of the input reads). i.e. excludes the number of reads that are supplementary.
primary mapped %: percentage of mapped primary reads (denominator is number of primary reads)
paired in sequencing: This is the number of paired reads. If you used only paired reads after trimming, this will be the same as the number in the primary field
read1: This is the number of forward (R1) reads. If you used only paired reads after trimming, this will be half of the number in the primary field
read2: This is the number of reverse (R2) reads. If you used only paired reads after trimming, this will be the same as the read1 field.
properly paired: This is the number of reads that map in a way that makes sense (Not too far apart, on different chromosomes, R1 read maps to the forward strand and R2 to the reverse strand etc. depending on the aligner). See this for some more information. This is suitable if you want to be very conservative with the number of reads that you consider mapped.
properly paired %: percentage of properly paired reads (denominator is number of primary reads)
with itself and mate mapped: Number of reads with its corresponding reverse / forward read also mapped. This is less strict that properly paired but more that primary mapped.
singletons: This is the number of reads that are mapped but their corresponding reverse / forward read did not map. (primary mapped - with itself and mate mapped = singletons)
singletons %: percentage of singletons (denominator is number of primary reads)
with mate mapped to a different chr: This is the number of reads that are mapped but their corresponding reverse / forward read mapped to a different chromosome. Remove these from properly paired to get an even more conservative estimate of number of mapped reads.
with mate mapped to a different chr (mapQ>=5): This is the number of reads that are mapped but their corresponding reverse / forward read mapped to a different chromosome with good quality for the alignment. Remove these from properly paired to get a more conservative estimate of number of mapped reads.
What preprocessing steps have been applied to get this file ?
I wrote this command: samtools flagstat example.bam. Does this help?