Please help me find the number of mapped reads from a bam file. I was going through forums and tutorials. Looking at samtools flagstat
resulted the following:
My total read count is 413,033. So, I understand 453,800 to be number of alignments. Now, is it that 391,696 reads mapped? According to this tutorial, Yes.
1. samtools flagstat file.sorted.bam
453800 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 duplicates
391696 + 0 mapped (86.31%:-nan%) 0 + 0 paired in sequencing
0 + 0 read1
0 + 0 read2
0 + 0 properly paired (-nan%:-nan%)
0 + 0 with itself and mate mapped
0 + 0 singletons (-nan%:-nan%)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)
Found another explanation at this page. It says 391,696 is the number of locations that reads mapped. A number same as flagstat is giving us above and the number of mapped reads are 413,033 same as my original fasta sequence number. Check commands below.
2. Number of Mapped locations:
samtools view -F 0x04 -c file.sorted.bam
391696
3. Number of Mapped reads:
samtools view -F 0x40 file.sorted.bam | cut -f1 | sort | uniq | wc -l
413033
Could I please know, which one, should I follow to find the number of reads that mapped the reference from my original fasta file? Suppose the reads are to be single end. I would thankful to your explanations.
Hi!
I have run bowtie2 for the alignment of my chip-seq files, and then run samtools view to convert the sam files in bam. Also I have run samtools sort, to sort the bam file and samtools index to index the bam file.
Then I have run samtools flagstats and it resulted in an empty file, I mean, all the values are 0:
Could somebody help me with this issue?
The bowtie2 summary is correct and full of numbers of aligned and unaligned reads, so did I forget something when runing samtools? Some option or something? Because I used the default mode.
Thanks,
Iraia