Debian Codegraph @

pipelines/variantPipeline.sh

raw symbols SCIP
1 #!/bin/bash
2 set -e
3
4 #Written by Brian Bushnell
5 #Last updated January 29, 2020
6
7 #This script is designed to preprocess and map data for variation calling of 2x150bp reads from Illumina HiSeq 2500.
8 #Some numbers and steps may need adjustment for different data types or file paths.
9 #The commands assume single-ended reads, or paired reads are interleaved in a single file.
10 #For paired reads in 2 files "in1=" and "in2=" may be used.
11
12 # --------------- #
13
14 #Remove duplicates
15 #Optical deduplication requires standard Illumina read headers and will not work with renamed reads, such as most SRA data.
16 #To perform PCR-duplicate removal (of all duplicates regardless of location), omit the "optical" flag.
17 #Deduplication is generally not recommended for quantification experiments such as RNA-seq.
18 clumpify.sh in=reads.fq.gz out=clumped.fq.gz dedupe optical
19
20 #Remove low-quality regions
21 #This step requires standard Illumina read headers and will not work with renamed reads, such as most SRA data.
22 filterbytile.sh in=clumped.fq.gz out=filtered_by_tile.fq.gz
23
24 #Trim adapters
25 bbduk.sh in=filtered_by_tile.fq.gz out=trimmed.fq.gz ktrim=r k=23 mink=11 hdist=1 tbo tpe minlen=100 ref=bbmap/resources/adapters.fa ftm=5 ordered
26
27 #Remove synthetic artifacts and spike-ins. Add "qtrim=r trimq=8" to also perform quality-trimming at this point, but not if quality recalibration will be done later.
28 bbduk.sh in=trimmed.fq.gz out=filtered.fq.gz k=27 ref=bbmap/resources/sequencing_artifacts.fa.gz,bbmap/resources/phix174_ill.ref.fa.gz ordered
29
30 #Map to reference
31 bbmap.sh in=filtered.fq.gz out=mapped.sam.gz bs=bs.sh pigz unpigz ref=reference.fa
32
33 #Call variants
34 callvariants.sh in=mapped.sam.gz out=vars.vcf.gz ref=reference.fa ploidy=1 prefilter
35
36 #You can stop at this point; the remainder is optional.
37
38 # --------------- #
39
40 #Optional error-correction and recalibration for better quality:
41
42 #Generate recalibration matrices
43 calctruequality.sh in=mapped.sam.gz vcf=vars.vcf.gz
44
45 #Recalibrate. This can be done on the mapped reads instead of remapping, but if error-correction is desired it needs to be done on the unmapped reads.
46 bbduk.sh in=filtered.fq.gz out=recal.fq.gz recalibrate ordered
47
48 #Error-correct by overlap (for paired reads only)
49 bbmerge.sh in=recal.fq.gz out=ecco.fq.gz ecco strict mix ordered
50
51 #Quality-trim, if not already done earlier
52 bbduk.sh in=ecco.fq.gz out=qtrimmed.fq.gz qtrim=r trimq=8 ordered
53
54 #Re-map to the reference
55 bbmap.sh in=qtrimmed.fq.gz out=mapped2.sam.gz pigz unpigz
56
57 #Re-call variants
58 callvariants.sh in=mapped2.sam.gz out=vars2.vcf.gz ref=reference.fa ploidy=1 prefilter
59
60 # --------------- #
61
62 #Optional removal of reads with multiple substitutions unique to that read (an occasional Illumina error mode, particularly on Novaseq):
63 #If this step is performed, it may be advisable to do the initial variant-calling (prior to this step) with very liberal settings, e.g:
64 #callvariants.sh in=mapped.sam vcf=vars.vcf.gz ref=reference.fa clearfilters minreads=2 ploidy=1 prefilter
65
66 #Remove bad reads
67 filtersam.sh in=mapped.sam.gz out=clean.sam.gz outb=dirty.sam.gz vcf=vars.vcf.gz maxbadsubs=2 mbsad=2 mbsrd=2
68
69 #Re-call variants
70 callvariants.sh in=clean.sam.gz out=vars2.vcf.gz ref=reference.fa ploidy=1 prefilter
71
72 # --------------- #
73