Step 2: Read Trimming and Filtering (fastp) - rsalani13/EPP622-2026-SNPCalling GitHub Wiki

WARNING: Because these reads are simulated, fastp fails to identify that they need poly-G tail trimming. Turn that on with a flag.

I missed this part at first and had to redo it... how sad...

Commands

cd ../

#this directory is named like this because i didn’t notice the polyG warning until after i had run it…
mkdir fastp2_withWARNING
cd fastp2_withWARNING

#this didn't want to work so we're just gonna use the original file location and move the outputs
#ln -s ../../rawdata/reads/*gz .

nano fastp_bash.sh

------------------------------------------------
## Run all files through fastp
for R1 in ../../rawdata/reads/*_R1.fastq.gz
do
    basename=(echo"R1" | sed 's/_R1.fastq.gz//')
    echo $R1
    echo $basename

    fastp   --in1 ${basename}_R1.fastq.gz \
        --out1 ${basename}_R1.trimmed.fastq.gz \
        --in2 ${basename}_R2.fastq.gz \
        --out2 ${basename}_R2.trimmed.fastq.gz \
        --detect_adapter_for_pe \
       --trim_poly_g \
        --thread 2 \
        --json ${basename}.fastp.json \
        --html ${basename}.fastp.html
    
done

------------------------------------------------

bash fastp_bash.sh

This is all outputting my new files into the /rawdata/reads file… So I moved them to the directory I actually want to be working in

mv ../../rawdata/reads/*trimmed* .
mv ../../rawdata/reads/*fastp* .

Run multiqc

multiqc .

I renamed all multiqc reports aside from the first one so I can download them to my computer without the risk of accidentally overwriting my previous reports

mv multiqc_report.html multiqc_report_for_fastp2.html

Getting multiqc stats:

nano loop_to_get_multiqc_stats.sh

----------------------------------------
for f in *.fastq.gz; do
  echo -ne "$f\t"
  zcat "$f" | awk 'NR%4==2{r++; b+=length($0)} END{printf "%d\t%d\t%.1f\n", r, b, b/r}'
done | column -t
----------------------------------------

bash loop_to_get_multiqc_stats.sh

This gives the total reads, then the total bases, then the average read length for each file.

Results

MultiQC report path and name: /lustre/isaac24/proj/UTK0505/rsalani/exam2/analyses/fastp2_withWARNING/multiqc_report_for_fastp2.html

Reference genome size: 12071326

Sample Reads before Reads after Mean length before Mean length after Coverage
A 1609300 1609300 150.0 150.0 20x
B 321860 321860 150.0 150.0 4x
C 1609300 1577258 150.0 125.85 16.4x
D 1609300 1609300 150.0 150.0 20x