Syntax for samtools flagstat on multiple .bam files outputting to .txt file
Hello,
I would like to know appropriate syntax for samtools flagstat on multiple .bam files outputting all to .txt file
• 2,447 views
•
link
1 answer
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
• 0 views
•
link
Log in to answer this question.
What have you tried?