From aab07b4e2f3b69df8961ffe7e1afced83fe940c5 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 13 Sep 2022 12:35:40 +0200 Subject: [PATCH] Add QC stuff --- Adapting_new_script_for_computing_cluster.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Adapting_new_script_for_computing_cluster.sh b/Adapting_new_script_for_computing_cluster.sh index 824e41b..ed687bd 100755 --- a/Adapting_new_script_for_computing_cluster.sh +++ b/Adapting_new_script_for_computing_cluster.sh @@ -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