mkdir -p Sig_18_Blood/Sig_18_Blood.md/
cat xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed altera_v3_targets_postQC_hg38.bed altera_v3_targets_coding_postQC_hg38.bed altera_v3_targets_noncoding_postQC_hg38.bed xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed FINAL_hotspot_list_07302025_hg38_sorted.bed foresight_clarity_targets_hg38.bed | cut -f 1-3 | bedtools sort -g Homo_sapiens_assembly38.fasta.fai | bedtools merge > Sig_18_Blood/Sig_18_Blood.md/full_bed.bed
seqtool depth -bam Sig_18_Blood.md.bam -bed Sig_18_Blood/Sig_18_Blood.md/full_bed.bed -threads 4 -bam_threads 2 | bgzip -c > Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz
saturation_plot -bams Sig_18_Blood.md.bam -region chr20 -output Sig_18_Blood/Sig_18_Blood.md/saturation_plot.png -threads 1
seqtool saturation_metric -at 1000000 -region chr20 -bam_threads 1 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/saturation_qc.tsv
fragment_size -bams Sig_18_Blood.md.bam -region chr20 -output_prefix Sig_18_Blood/Sig_18_Blood.md/fragsize -threads 1
samtools mpileup -B --min-MQ 60 --min-BQ 30 -f Homo_sapiens_assembly38.fasta -l dbsnp_hg38_contam_sites.bed Sig_18_Blood.md.bam > Sig_18_Blood.md.mpileup && contamination -input Sig_18_Blood.md.mpileup -dbsnp_vcf Homo_sapiens_assembly38.dbsnp138.vcf.gz > Sig_18_Blood/Sig_18_Blood.md/contamination.tsv
seqtool noise -bam Sig_18_Blood.md.bam -ref Homo_sapiens_assembly38.fasta -region chr20 -include_bed Sig_18_Blood/Sig_18_Blood.md/full_bed.bed -exclude_bed dbsnp138_hg38_common.bed -threads 1 > Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.noise_summary.tsv
tabix -s 1 -b 2 -e 2 Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz
seqtool depth_hist -nbins 500 Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz > Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth_hist.tsv
cat Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth_hist.tsv | plot -x 0 -xlabel Depth -ylabel "Number of Sites" -xlim 0 2000 -title Sig_18_Blood.md -output Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.png
seqtool read_qc -bed xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed -n_threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/read_qc.xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed.tsv
seqtool reads_per_target -bed xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/reads_per_target.xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed.tsv
seqtool depth_stats -bed xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz> Sig_18_Blood/Sig_18_Blood.md/depth_stats.xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed.tsv
seqtool gc_bias -reference Homo_sapiens_assembly38.fasta -bed xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed -bin_size 0.05 -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed.tsv
seqtool read_qc -bed xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed -n_threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/read_qc.xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed.tsv
seqtool reads_per_target -bed xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/reads_per_target.xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed.tsv
seqtool depth_stats -bed xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz> Sig_18_Blood/Sig_18_Blood.md/depth_stats.xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed.tsv
seqtool gc_bias -reference Homo_sapiens_assembly38.fasta -bed xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed -bin_size 0.05 -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed.tsv
seqtool read_qc -bed altera_v3_targets_postQC_hg38.bed -n_threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/read_qc.altera_v3_targets_postQC_hg38.bed.tsv
seqtool reads_per_target -bed altera_v3_targets_postQC_hg38.bed -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/reads_per_target.altera_v3_targets_postQC_hg38.bed.tsv
seqtool depth_stats -bed altera_v3_targets_postQC_hg38.bed Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz> Sig_18_Blood/Sig_18_Blood.md/depth_stats.altera_v3_targets_postQC_hg38.bed.tsv
seqtool gc_bias -reference Homo_sapiens_assembly38.fasta -bed altera_v3_targets_postQC_hg38.bed -bin_size 0.05 -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.altera_v3_targets_postQC_hg38.bed.tsv
seqtool read_qc -bed altera_v3_targets_coding_postQC_hg38.bed -n_threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/read_qc.altera_v3_targets_coding_postQC_hg38.bed.tsv
seqtool reads_per_target -bed altera_v3_targets_coding_postQC_hg38.bed -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/reads_per_target.altera_v3_targets_coding_postQC_hg38.bed.tsv
seqtool depth_stats -bed altera_v3_targets_coding_postQC_hg38.bed Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz> Sig_18_Blood/Sig_18_Blood.md/depth_stats.altera_v3_targets_coding_postQC_hg38.bed.tsv
seqtool gc_bias -reference Homo_sapiens_assembly38.fasta -bed altera_v3_targets_coding_postQC_hg38.bed -bin_size 0.05 -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.altera_v3_targets_coding_postQC_hg38.bed.tsv
seqtool read_qc -bed altera_v3_targets_noncoding_postQC_hg38.bed -n_threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/read_qc.altera_v3_targets_noncoding_postQC_hg38.bed.tsv
seqtool reads_per_target -bed altera_v3_targets_noncoding_postQC_hg38.bed -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/reads_per_target.altera_v3_targets_noncoding_postQC_hg38.bed.tsv
seqtool depth_stats -bed altera_v3_targets_noncoding_postQC_hg38.bed Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz> Sig_18_Blood/Sig_18_Blood.md/depth_stats.altera_v3_targets_noncoding_postQC_hg38.bed.tsv
seqtool gc_bias -reference Homo_sapiens_assembly38.fasta -bed altera_v3_targets_noncoding_postQC_hg38.bed -bin_size 0.05 -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.altera_v3_targets_noncoding_postQC_hg38.bed.tsv
seqtool read_qc -bed xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed -n_threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/read_qc.xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed.tsv
seqtool reads_per_target -bed xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/reads_per_target.xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed.tsv
seqtool depth_stats -bed xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz> Sig_18_Blood/Sig_18_Blood.md/depth_stats.xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed.tsv
seqtool gc_bias -reference Homo_sapiens_assembly38.fasta -bed xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed -bin_size 0.05 -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed.tsv
seqtool read_qc -bed FINAL_hotspot_list_07302025_hg38_sorted.bed -n_threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/read_qc.FINAL_hotspot_list_07302025_hg38_sorted.bed.tsv
seqtool reads_per_target -bed FINAL_hotspot_list_07302025_hg38_sorted.bed -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/reads_per_target.FINAL_hotspot_list_07302025_hg38_sorted.bed.tsv
seqtool depth_stats -bed FINAL_hotspot_list_07302025_hg38_sorted.bed Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz> Sig_18_Blood/Sig_18_Blood.md/depth_stats.FINAL_hotspot_list_07302025_hg38_sorted.bed.tsv
seqtool gc_bias -reference Homo_sapiens_assembly38.fasta -bed FINAL_hotspot_list_07302025_hg38_sorted.bed -bin_size 0.05 -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.FINAL_hotspot_list_07302025_hg38_sorted.bed.tsv
seqtool read_qc -bed foresight_clarity_targets_hg38.bed -n_threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/read_qc.foresight_clarity_targets_hg38.bed.tsv
seqtool reads_per_target -bed foresight_clarity_targets_hg38.bed -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/reads_per_target.foresight_clarity_targets_hg38.bed.tsv
seqtool depth_stats -bed foresight_clarity_targets_hg38.bed Sig_18_Blood/Sig_18_Blood.md/Sig_18_Blood.md.depth.gz> Sig_18_Blood/Sig_18_Blood.md/depth_stats.foresight_clarity_targets_hg38.bed.tsv
cat Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.FINAL_hotspot_list_07302025_hg38_sorted.bed.tsv | plot -x 0 -header infer -ylim 0 2 -title "Sig_18_Blood.md" -suptitle "FINAL_hotspot_list_07302025_hg38_sorted.bed" -output "Sig_18_Blood/Sig_18_Blood.md/gc_bias.FINAL_hotspot_list_07302025_hg38_sorted.bed.png" -ylabel "Fold enrichment / depletion" -xlabel "GC Quantile"
seqtool gc_bias -reference Homo_sapiens_assembly38.fasta -bed foresight_clarity_targets_hg38.bed -bin_size 0.05 -threads 1 -bam_threads 2 Sig_18_Blood.md.bam > Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.foresight_clarity_targets_hg38.bed.tsv
cat Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.altera_v3_targets_coding_postQC_hg38.bed.tsv | plot -x 0 -header infer -ylim 0 2 -title "Sig_18_Blood.md" -suptitle "altera_v3_targets_coding_postQC_hg38.bed" -output "Sig_18_Blood/Sig_18_Blood.md/gc_bias.altera_v3_targets_coding_postQC_hg38.bed.png" -ylabel "Fold enrichment / depletion" -xlabel "GC Quantile"
cat Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.altera_v3_targets_postQC_hg38.bed.tsv | plot -x 0 -header infer -ylim 0 2 -title "Sig_18_Blood.md" -suptitle "altera_v3_targets_postQC_hg38.bed" -output "Sig_18_Blood/Sig_18_Blood.md/gc_bias.altera_v3_targets_postQC_hg38.bed.png" -ylabel "Fold enrichment / depletion" -xlabel "GC Quantile"
cat Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.altera_v3_targets_noncoding_postQC_hg38.bed.tsv | plot -x 0 -header infer -ylim 0 2 -title "Sig_18_Blood.md" -suptitle "altera_v3_targets_noncoding_postQC_hg38.bed" -output "Sig_18_Blood/Sig_18_Blood.md/gc_bias.altera_v3_targets_noncoding_postQC_hg38.bed.png" -ylabel "Fold enrichment / depletion" -xlabel "GC Quantile"
cat Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.foresight_clarity_targets_hg38.bed.tsv | plot -x 0 -header infer -ylim 0 2 -title "Sig_18_Blood.md" -suptitle "foresight_clarity_targets_hg38.bed" -output "Sig_18_Blood/Sig_18_Blood.md/gc_bias.foresight_clarity_targets_hg38.bed.png" -ylabel "Fold enrichment / depletion" -xlabel "GC Quantile"
cat Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed.tsv | plot -x 0 -header infer -ylim 0 2 -title "Sig_18_Blood.md" -suptitle "xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed" -output "Sig_18_Blood/Sig_18_Blood.md/gc_bias.xgen-exome-hyb-panel-v2-targets-hg38_minus_altera_v3_targets_postQC_hg38.bed.png" -ylabel "Fold enrichment / depletion" -xlabel "GC Quantile"
cat Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed.tsv | plot -x 0 -header infer -ylim 0 2 -title "Sig_18_Blood.md" -suptitle "xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed" -output "Sig_18_Blood/Sig_18_Blood.md/gc_bias.xgen-exome-hyb-panel-v2-targets-hg38_AND_altera_v3_targets_postQC_hg38_AND_foresight_clarity.bed.png" -ylabel "Fold enrichment / depletion" -xlabel "GC Quantile"
cat Sig_18_Blood/Sig_18_Blood.md/gc_bias_qc.xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed.tsv | plot -x 0 -header infer -ylim 0 2 -title "Sig_18_Blood.md" -suptitle "xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed" -output "Sig_18_Blood/Sig_18_Blood.md/gc_bias.xgen-exome-hyb-panel-v2_AND_altera_v3_probes_short_hg38_AND_cdx_spike_custom30off4x_hg38_AND_foresight_clarity_footprint.bed.png" -ylabel "Fold enrichment / depletion" -xlabel "GC Quantile"
echo `date` > Sig_18_Blood/Sig_18_Blood.md/qc_complete.txt