---
title: "01-bismark-init"
output: github_document
date: "2024-11-07"
author: Steven Roberts
---


```{bash}
wget -r \
--no-directories --no-parent \
-P ../data \
-A "*.fastp-trim.fq.gz" https://gannet.fish.washington.edu/Atumefaciens/gitrepos/project-mytilus-methylation/output/00.10-trimming-fastp-FastQC-MultiQC/trimmed-fastqs/
```






# align

```{bash}
# Set variables
reads_dir="../data/"
genome_folder="../data/"
output_dir="../output/01.1-bismark-min_score/"

# 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")
    
    # Loop through each score_min parameter manually
    for score_min in "L,0,-0.4" "L,0,-0.6" "L,0,-0.8" "L,0,-1.0" "L,-1,-0.6"; do
        echo "Running Bismark for sample ${sample_name} with score_min ${score_min}"
        
        # Define output directory for each parameter
        param_output_dir="${output_dir}${sample_name}_${score_min//,/}"
        mkdir -p ${param_output_dir}
        
        # Run Bismark alignment
        /home/shared/Bismark-0.24.0/bismark \
            --path_to_bowtie2 /home/shared/bowtie2-2.4.4-linux-x86_64 \
            -genome ../data/ \
            -p 8 \
            -u 10000 \
            -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 ${param_output_dir} \
            --basename ${sample_name}_${score_min//,/} \
            2> "${param_output_dir}/${sample_name}-bismark_summary.txt"
    done
done
```





```{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
```

