<p>I would like to find the mapping statistics from the sorted bam files.
Samtools flagstat gives the output only for a single file. What is the easiest way to find the mapping statistics for all sequences? How do I find the mapping percentage for all sequences? Is it possible to use the samtools flagstat if I merge all the files in to a single bamfile?</p>

CC BY-SA 4.0
2023-05-06T10:16:10.630Z
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Community
CC BY-SA 4.0
2023-05-07T03:15:50.213Z
Hi @Kam and welcome. What sort of stats are you thinking of? E.g. coverage, average read length? Also what sort of sequence data is this?
M__
CC BY-SA 4.0
2023-05-07T06:10:13.840Z
I would like to find the mapping percentage for all the reads after mapping. I have around 300 bam files after mapping. Is it possible to find the mapping percentage for all the reads?
Kam
CC BY-SA 4.0
2023-05-09T06:38:42.027Z
run it in a loop. something like `for f in bamfiles; do ...; done`
user3479780
CC BY-SA 4.0
2023-05-16T15:42:21.267Z
Which mapper are you using? Have you checked the logs of your mapper to see if these metrics are already provided there? Are you sure you are retaining unmapped reads in the final BAMs in order to calculate such rate?
JRodrigoF
<phylogenetics><samtools><read-mapping>
Mapping statistics from the bam files
# Mapping statistics from the bam files

(Asked by: username_0 on 2023-05-06)

I would like to find the mapping statistics from the sorted bam files.
Samtools flagstat gives the output only for a single file. What is the easiest way to find the mapping statistics for all sequences? How do I find the mapping percentage for all sequences? Is it possible to use the samtools flagstat if I merge all the files in to a single bamfile?

**Tags:** phylogenetics, samtools, read-mapping
> **Comments:**
> **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
> **username_2**: Hi @Kam and welcome. What sort of stats are you thinking of? E.g. coverage, average read length? Also what sort of sequence data is this?  
> **username_0**: I would like to find the mapping percentage for all the reads after mapping. I have around 300 bam files after mapping. Is it possible to find the mapping percentage for all the reads?  
> **username_3**: run it in a loop. something like `for f in bamfiles; do ...; done`  
> **username_4**: Which mapper are you using? Have you checked the logs of your mapper to see if these metrics are already provided there? Are you sure you are retaining unmapped reads in the final BAMs in order to calculate such rate?  

---

## 0 answers

