Entering edit mode
4.5 years ago
Ada
▴
10
Hello,
I would like to know appropriate syntax for samtools flagstat on multiple .bam files outputting all to .txt file
Hello,
I would like to know appropriate syntax for samtools flagstat on multiple .bam files outputting all to .txt file
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
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
What have you tried?