This repository has been archived by the owner on Dec 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make bash code safer by quoting expansions and enforcing locales. Add…
… utility script for coverage per sample.
- Loading branch information
cmdoret
committed
Aug 2, 2019
1 parent
d487439
commit bbbe4d9
Showing
3 changed files
with
49 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
GENOMESIZE=140734580 | ||
READLENGTH=93 | ||
REPORT="sample_coverage.tsv" | ||
|
||
echo -e "sample\tcoverage" > "$REPORT" | ||
n_samples=$(ls -1 data/mapped/aln-4/bam/*bam | wc -l) | ||
declare -i n_done=0 | ||
for sample_bam in data/mapped/aln-4/bam/*bam; do | ||
echo -e "Processed $n_done / $n_samples" | ||
COVERAGE=$(samtools depth -a "$sample_bam" \ | ||
| awk -v gsize="$GENOMESIZE" -v rlen="$READLENGTH" '{depth+=$3}END{print rlen*depth/gsize}') | ||
sample_name="$(basename $sample_bam)" | ||
echo -ne "${sample_name%%-BWA*}\t" >> "$REPORT" | ||
echo "$COVERAGE" >> "$REPORT" | ||
((n_done++)) | ||
done | ||
# Merge coverage file with sample metadata | ||
join -j 1 \ | ||
<( tail -n+2 sample_coverage.tsv | sort -k1,1) \ | ||
<( tail -n +2 data/ploidy/thresholds/fixed.tsv | sort -k1,1) |