/total alignments.sh Secret
Created
June 13, 2014 20:16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################### | |
# Using samtools idxstats # # quickest approach | |
########################### | |
# Total Alignments | |
samtools idxstats filename.bam | awk '{s+=$3+$4} END {print s}' | |
# Mapped Alignments | |
samtools idxstats filename.bam | awk '{s+=$3} END {print s}' | |
# Unmapped Alignments | |
samtools idxstats filename.bam | awk '{s+=$4} END {print s}' | |
####################### | |
# Using samtools view # # more options | |
####################### | |
# Total Alignments | |
samtools view -c filename.bam | |
# Mapped Alignments | |
samtools view -c -F 4 filename.bam | |
# Unmapped Alignments | |
samtools view -c -f 4 filename.bam | |
# Mapped Alignment and its Mate Mapped | |
samtools view -c -f 1 -F 12 filename.bam | |
# Total Reads | |
samtools view filename.bam | cut -f 1 | sort | uniq | wc -l | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment