Syntax for samtools flagstat on multiple .bam files outputting to .txt file
1
0
Entering edit mode
3.8 years ago
Ada ▴ 10

Hello,

I would like to know appropriate syntax for samtools flagstat on multiple .bam files outputting all to .txt file

alignment • 1.7k views
ADD COMMENT
0
Entering edit mode

What have you tried?

ADD REPLY
2
Entering edit mode
3.8 years ago
khorms ▴ 230

An easy way of doing it is to run samtools flagstat on multiple .bam files and then combine their output together using multiqc
So something like

samtools_stat_commands=()
samtools_stat_log_folder=''
multiqc_folder=''
for i in ${aligned_folder}/*.bam
do
    sample_name=$(basename $i .bam)
    log_file=${samtools_stat_log_folder}/${sample_name}_bamtools_stats.txt
    samtools_stat_command="samtools stats ${i} > ${log_file}"
    samtools_stat_commands[${#samtools_stat_commands[@]}]+=$samtools_stat_command

done

parallel -j 16 ::: "${samtools_stat_commands[@]}"

multiqc $samtools_stat_log_folder -o $multiqc_folder -n samtools_flagstat.html
ADD COMMENT

Login before adding your answer.

Traffic: 1973 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6