---
title: "09-meth-quant"
output: html_document
date: "2024-12-18"
---
with code 01.1
alignments done as
```{bash}
# Set variables
reads_dir="../data/"
genome_folder="../data/"
output_dir="../output/01.2-bismark"
score_min="L,0,-1.0" # Single value for score_min
# Get the list of sample files and corresponding sample names
for file in ${reads_dir}*_R1.fastp-trim.fq.gz; do
sample_name=$(basename "$file" "_R1.fastp-trim.fq.gz")
echo "Running Bismark for sample ${sample_name} with score_min ${score_min}"
# Run Bismark alignment
/home/shared/Bismark-0.24.0/bismark \
--path_to_bowtie2 /home/shared/bowtie2-2.4.4-linux-x86_64 \
-genome ${genome_folder} \
-p 8 \
-score_min ${score_min} \
-1 ${reads_dir}${sample_name}_R1.fastp-trim.fq.gz \
-2 ${reads_dir}${sample_name}_R2.fastp-trim.fq.gz \
-o ${output_dir} \
--basename ${sample_name} \
2> "${output_dir}/${sample_name}-bismark_summary.txt"
done
```
## missed sample (93)
```{bash}
cd ../data
curl -O https://gannet.fish.washington.edu/Atumefaciens/gitrepos/project-mytilus-methylation/output/00.10-trimming-fastp-FastQC-MultiQC/trimmed-fastqs/93M_R1.fastp-trim.fq.gz
```
```{bash}
cd ../data
curl -O https://gannet.fish.washington.edu/Atumefaciens/gitrepos/project-mytilus-methylation/output/00.10-trimming-fastp-FastQC-MultiQC/trimmed-fastqs/93M_R2.fastp-trim.fq.gz
```
```{bash}
# Set variables
reads_dir="../data/"
genome_folder="../data/"
output_dir="../output/01.2-bismark"
score_min="L,0,-1.0" # Single value for score_min
# Get the list of sample files and corresponding sample names
for file in ${reads_dir}93M_R1.fastp-trim.fq.gz; do
sample_name=$(basename "$file" "_R1.fastp-trim.fq.gz")
echo "Running Bismark for sample ${sample_name} with score_min ${score_min}"
# Run Bismark alignment
/home/shared/Bismark-0.24.0/bismark \
--path_to_bowtie2 /home/shared/bowtie2-2.4.4-linux-x86_64 \
-genome ${genome_folder} \
-p 8 \
-score_min ${score_min} \
-1 ${reads_dir}${sample_name}_R1.fastp-trim.fq.gz \
-2 ${reads_dir}${sample_name}_R2.fastp-trim.fq.gz \
-o ${output_dir} \
--basename ${sample_name} \
2> "${output_dir}/${sample_name}-bismark_summary.txt"
done
```
Besides reports this produced bam files that need to be deduplicated
```{bash}
ls ../output/01.2-bismark/*bam
```
```{bash}
pwd
```
```{bash}
find ../output/01.2-bismark/93*.bam | \
xargs -n 1 basename -s .bam | \
parallel -j 8 /home/shared/Bismark-0.24.0/deduplicate_bismark \
--bam \
--paired \
--output_dir ../output/09-meth-quant \
../output/01.2-bismark/{}.bam
```
# extraction
```
find ../output/09-meth-quant/*deduplicated.bam | xargs -n 1 -I{} /home/shared/Bismark-0.24.0/bismark_methylation_extractor --bedGraph --counts --comprehensive --merge_non_CpG --multicore 24 --buffer_size 75% --output ../output/09-meth-quant {}
```
```{bash}
find ../output/09-meth-quant/93*deduplicated.bam | xargs -n 1 -I{} /home/shared/Bismark-0.24.0/bismark_methylation_extractor --bedGraph --counts --comprehensive --merge_non_CpG --multicore 24 --buffer_size 75% --output ../output/09-meth-quant {}
```
```
find ../output/09-meth-quant/*deduplicated.bam | \
xargs -n 1 -I{} ${bismark_dir}/bismark_methylation_extractor \
--bedGraph \
--counts \
--comprehensive \
--merge_non_CpG \
--multicore 38 \
--buffer_size 75% \
--output ../output/09-meth-quant \
{}
```
# cov2 cyto
```{bash}
```
```{bash}
find ../output/09-meth-quant/*deduplicated.bismark.cov.gz | \
xargs -n 1 basename -s _pe.deduplicated.bismark.cov.gz | \
parallel -j 48 /home/shared/Bismark-0.24.0/coverage2cytosine \
--genome_folder ../data/ \
-o ../output/09-meth-quant/{} \
--merge_CpG \
--zero_based \
../output/09-meth-quant/{}_pe.deduplicated.bismark.cov.gz
```
```{bash}
find ../output/09-meth-quant/93*deduplicated.bismark.cov.gz | \
xargs -n 1 basename -s _pe.deduplicated.bismark.cov.gz | \
parallel -j 48 /home/shared/Bismark-0.24.0/coverage2cytosine \
--genome_folder ../data/ \
-o ../output/09-meth-quant/{} \
--merge_CpG \
--zero_based \
../output/09-meth-quant/{}_pe.deduplicated.bismark.cov.gz
```
```{bash}
cd ../output/09-meth-quant/
/home/shared/Bismark-0.24.0/bismark2report
/home/shared/Bismark-0.24.0/bismark2summary
```
```{bash}
find ../output/09-meth-quant/93*.bam | \
xargs basename -s .bam | \
xargs -I{} /home/shared/samtools-1.12/samtools \
sort --threads 48 {}.bam \
-o {}.sorted.bam
```
find *.bam | \
xargs basename -s .bam | \
xargs -I{} /home/shared/samtools-1.12/samtools \
sort --threads 48 {}.bam \
-o {}.sorted.bam