Skip to content

Commit

Permalink
Add QC stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Sep 13, 2022
1 parent e81560b commit aab07b4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Adapting_new_script_for_computing_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,36 @@ execute() {
--normalizeUsing CPM -ignore chrX chrY \
--numberOfProcessors $THREADS \

# Here I have no idea how to transfer this

: Generating QC files for the data

fragments=$(grep -Po -m 1 'Total reads processed.*' $id.trimmingStats.txt | grep -Po '[0-9,]*' | tr -d ,)
map=$(grep -Po '[0-9, /.]*% overall alignment rate' $id.mappingStats.txt | grep -Po '[0-9,/.]*')
mapFrac=$(printf "%.4f" $(echo $map / 100 | bc -l))
dedup=$(printf "%.4f" $(grep -Po 'Unknown Library.*' dedup/${id}_dedupMetric.txt | awk '{print $10}'))
filtered=$(expr $(samtools view -c dedup/${id}_dedup.bam) / 2)
ripReads=$(expr $(bedtools intersect -a dedup/${id}_dedup.bam -b dedup_peaks/${id}_dedup_peaks.narrowPeak -u -ubam | samtools view -c) / 2)
FRiP=$(printf "%.4f" $(echo $fripReads / $filtered | bc -l))
peaks=$(expr $(wc -l <"dedup_peaks/${id}_dedup_peaks.narrowPeak") - 1)
echo -e "$id\t$fragments\t$filtered\t$mapFrac\t$dedup\t$FRiP\t$peaks" >> cnt_gata_qc_metrics.txt

# Here I have no idea how to transfer this
: Generating pearson correlation between the samples


####################################

work_dir="$work_dir" flock $LOCK_FILE bash -c '
mkdir -p $work_dir/peaks $work_dir/bigwig $work_dir/final_bam $work_dir/fastqc $work_dir/dedup $work_dir/dedup_peaks
mkdir -p $work_dir/peaks $work_dir/bigwig $work_dir/final_bam $work_dir/fastqc $work_dir/dedup $work_dir/dedup_peaks \
$work_dir/qc
cp final_bam/* $work_dir/final_bam
cp peaks/* $work_dir/peaks/
cp bigwig/* $work_dir/bigwig/
cp fastqc/* $work_dir/fastqc
cp dedup/* $work_dir/dedup
cp dedup_peaks/* $work_dir/dedup_peaks
test -e $work_dir/qc/cnt_gata_qc_metrics.txt \
|| echo -e "Sample\tTotal\tFiltered\tMapped\tDuplicate\tFRiP\tPeaks"> $work_dir/qc/cnt_gata_qc_metrics.txt
cat cnt_gata_qc_metrics.txt >> $work_dir/qc/cnt_gata_qc_metrics.txt
'

ls -lR
Expand Down

0 comments on commit aab07b4

Please sign in to comment.