Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-06T10:16:10.630Z
Comments.Text: 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.
Comments.UserDisplayName: Community
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-07T03:15:50.213Z
Comments.Text: 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?
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-07T06:10:13.840Z
Comments.Text: 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?
Comments.UserDisplayName: Kam
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-09T06:38:42.027Z
Comments.Text: run it in a loop. something like `for f in bamfiles; do ...; done`
Comments.UserDisplayName: user3479780
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-16T15:42:21.267Z
Comments.Text: 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?
Comments.UserDisplayName: JRodrigoF
Tags: <phylogenetics><samtools><read-mapping>
Title: Mapping statistics from the bam files
ThreadText: # 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 @username_0 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
  
  