-
-
Save muppetjones/98d85c8ad40d3325961d to your computer and use it in GitHub Desktop.
Examine Fastqc reports in aggregate; brings images, statistics, and summaries together. #fastq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run this script in project root--expected structure: `./fastqc/<sample>/*.zip` | |
# This script aggregates images of each type in individual folders | |
# o looking across data is quick. | |
zips=`ls fastqc/*/*.zip` | |
for i in $zips; do | |
unzip -oq -d "$(dirname "$i")" $i; | |
done | |
fastq_folders=${zips/.zip/} | |
aggregate_folder=fastqc/aggregated | |
rm -rf "$aggregate_folder" # Remove aggregate folder if present | |
mkdir "$aggregate_folder" | |
# Rename Files within each using folder name. | |
for folder in $fastq_folders; do | |
folder=${folder%.*} | |
img_files=`ls ${folder}/Images/*png`; | |
for img in $img_files; do | |
img_name=$(basename "$img"); | |
img_name=${img_name%.*} | |
new_name=${folder}; | |
new_name="$(basename "${folder/_fastqc/}")" | |
mkdir -p "${aggregate_folder}"/${img_name}; | |
mv $img "${aggregate_folder}"/${img_name}/${new_name}.png; | |
done; | |
done; | |
# Concatenate Summaries | |
for folder in $fastq_folders; do | |
folder=${folder%.*} | |
cat ${folder}/summary.txt >> "${aggregate_folder}"/summary.txt | |
done; | |
# Concatenate Statistics | |
for folder in $fastq_folders; do | |
folder=${folder%.*} | |
head -n 10 ${folder}/fastqc_data.txt | tail -n 7 | awk -v f=${folder/_fastqc/} '{ print $0 "\t" f }' >> "${aggregate_folder}"/statistics.txt | |
rm -rf ${folder} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modified for different directory structure and DRY aggregate folder