Debian Codegraph @

pipelines/process_lane_v007.sh

raw symbols SCIP
1 #!/bin/bash
2
3 #Title: NovaSeq full-lane analysis script.
4 #Description: Gathers full-lane data for later per-library processing; does not modify any data.
5 # Should be run on every raw Illumina lane.
6 # The output files PHIX, TILEDUMP, QHIST, and COUNTS should be added to Jamo, linked to the lane.
7 # For easiest downstream processing, expected.txt (list of barcodes in the lane)
8 # should also be present in Jamo for the lane.
9 # Retaining qhist.txt would also be helpful.
10 # This script requires PhiX to be spiked in; 0.1% is sufficient but 1%+ is better.
11 #Author: Brian Bushnell
12 #Version: 0.07
13 #Date: Aug 17, 2024
14
15
16 #link dev version, or use a container with at least v39.09
17 #Perlmutter:
18 ##export PATH=$PATH:/global/cfs/cdirs/bbtools/jgi-bbtools/
19 #Dori:
20 ##export PATH=$PATH:/clusterfs/jgi/groups/gentech/homes/bbushnell/BBTools/
21
22
23 ###Set environment variables
24
25
26 #Lane ID (any lane-specific identifier)
27 LANEID=ABXYZ
28 #Lane fastq input name
29 RAW=ABXYZ.1.fq.gz
30 #Lane input path
31 RAWPATH=/foo/bar/"$RAW"
32 #Output path for large fastqs (temporary)
33 OUT="$PSCRATCH"/"$LANEID"
34 #Path for recalibrated reads file (temporary)
35 RECAL="$OUT"/"$LANEID"_recal.fq.gz
36 #Path for mapped phix (retained)
37 PHIX=phix.sam.gz
38 #Path for tile quality dump (retained)
39 TILEDUMP=tiledump.txt.gz
40 #Path for barcode counts (retained)
41 COUNTS=barcodecounts.txt.gz
42 #Quality histogram (retained)
43 QHIST=qhist.txt
44
45
46 ### BBTools variables
47
48 #Physical CPUs
49 CORES=64
50 #Compression level. If you don't have a working version of bgzip in the path set this to 4.
51 ZL=9
52 #Shared arguments for all steps
53 ARGS="t=$CORES zl=$ZL ow"
54
55 #Set this to 85% of physical RAM; 48 is for Perlmutter login nodes
56 MAXRAM=48g
57 #Keep this at 31
58 HIGHRAM=31g
59 #Keep this at 4
60 LOWRAM=4g
61
62 #Max memory flag
63 MAX="-Xmx$MAXRAM"
64 #High memory flag
65 HIGH="-Xmx$HIGHRAM"
66 #Low memory flag
67 LOW="-Xmx$LOWRAM"
68
69
70 ###Processing starts here
71
72 rm finished
73
74 #Filter phix reads
75 bbduk.sh "$LOW" "$ARGS" ref=phix k=25 hdist=2 in="$RAWPATH" outm=phix.fq.gz
76
77 #Clumpify reduces phix file size but can make the pipeline less stable when run incorrectly.
78 #clumpify.sh "$MAX" "$ARGS" in=phix.fq.gz out=clumped.fq.gz
79
80 #Adapter-trim phix reads
81 bbduk.sh "$LOW" "$ARGS" in=phix.fq.gz out=phix_trimmed.fq.gz ref=adapters k=23 mink=11 hdist=2 hdist2=0 tbo tpe ktrim=r minlen=100 ordered
82
83 #Align phix reads
84 #This sam file should be retained for future recalibration if desired
85 bbmap.sh "$HIGH" "$ARGS" ref=phix nodisk vslow maxindel=100 in=phix_trimmed.fq.gz outm=phix.sam.gz qhist="$QHIST" qahist=qahist.txt mhist=mhist.txt bhist=bhist.txt ordered
86
87 #Make recalibration matrices
88 calctruequality.sh "$HIGH" "$ARGS" in="$PHIX" usetiles callvars ref=phix
89
90 #Recalibrate quality
91 bbduk.sh "$LOW" "$ARGS" in="$RAWPATH" out="$RECAL" recalibrate usetiles
92
93 #Filter by tile - this step is best done on the whole lane, after quality recalibration
94 filterbytile.sh "$MAX" "$ARGS" in="$RECAL" dump="$TILEDUMP"
95
96 #Count barcodes
97 countbarcodes2.sh "$HIGH" "$ARGS" in="$RAWPATH" counts="$COUNTS"
98
99 touch finished
100
101 #At this point PHIX, DUMP, QHIST, and COUNTS files need to be put in Jamo, associated with the lane.
102 #Additionally, expected.txt (the file with a 1-per-line list of barcodes in the lane) should also be in Jamo associated with the lane. Or samplemap.txt (barcode tab sampleid per line).