The ShortRead package in Bioconductor offers quality control for NGS data from base-calling to mapping. For mapping scores, ShortRead can read several formats, including BAM files generated from samtools. However, it cannot recognize the sorted BAM files.
The R code below plots alignment quality density distribution.
aln <- readAligned(getwd(), 'my.bam', type='BAM')
q <- quality(alignQuality(aln))
densityplot(q[q&bt;1], xlab=’Alignment quality’, plot.points=FALSE, log=’y’)
The plot looks like this: