|
| 1 | +#!/bin/bash |
| 2 | +#$ -cwd |
| 3 | +#$ -S /bin/bash |
| 4 | + |
| 5 | + |
| 6 | +# basic argument |
| 7 | +DIR=$1 |
| 8 | +SAMPLE=$2 |
| 9 | +REF=$3 |
| 10 | +DataPath=$4 |
| 11 | +FASTQ1=$5 |
| 12 | +FASTQ2=$6 |
| 13 | +PICARD=$7 |
| 14 | +OPT='' |
| 15 | + |
| 16 | + |
| 17 | +date |
| 18 | + |
| 19 | +# 1. Actual Alignment. -I option to use illumina 1.3+ quailities. For the latest version, we don't need -I option. |
| 20 | + |
| 21 | +bwa mem -t 4 -M $REF $DataPath$FASTQ1 $DataPath$FASTQ2 | java -jar $PICARD/picard.jar SortSam \ |
| 22 | +SORT_ORDER=coordinate \ |
| 23 | +INPUT=/dev/stdin \ |
| 24 | +OUTPUT=$AlignedPath$SAMPLE$OPT.bam \ |
| 25 | +VALIDATION_STRINGENCY=LENIENT \ |
| 26 | +CREATE_INDEX=true \ |
| 27 | +TMP_DIR=$DIR/out/tmp/ |
| 28 | + |
| 29 | +# 2.1. Add or replace read groups |
| 30 | +java -jar $PICARD/picard.jar AddOrReplaceReadGroups \ |
| 31 | +INPUT=$AlignedPath$SAMPLE$OPT.bam \ |
| 32 | +OUTPUT=$AlignedPath$SAMPLE$OPT.RGadded.bam \ |
| 33 | +SORT_ORDER=coordinate \ |
| 34 | +RGLB='MRS' \ |
| 35 | +RGPL='il' \ |
| 36 | +RGPU='WES' \ |
| 37 | +RGSM=$SAMPLE \ |
| 38 | +CREATE_INDEX=true \ |
| 39 | +VALIDATION_STRINGENCY=LENIENT \ |
| 40 | +TMP_DIR=$DIR/out/tmp/ |
| 41 | + |
| 42 | +# 3. Marking PCR duplicates |
| 43 | +java -jar $PICARD/picard.jar MarkDuplicates \ |
| 44 | +INPUT=$AlignedPath$SAMPLE$OPT.RGadded.bam \ |
| 45 | +OUTPUT=$AlignedPath$SAMPLE$OPT.RGadded.marked.bam \ |
| 46 | +METRICS_FILE=$AlignedPath$SAMPLE$OPT.metrics \ |
| 47 | +CREATE_INDEX=true \ |
| 48 | +REMOVE_DUPLICATES=true \ |
| 49 | +VALIDATION_STRINGENCY=LENIENT \ |
| 50 | +TMP_DIR=$DIR/out/tmp/ |
| 51 | + |
| 52 | +# 3-1. LeftAlignIndel |
| 53 | +/data/project/MRS/Resource/gatk-4.1.5.0/gatk LeftAlignIndels \ |
| 54 | +-R $REF \ |
| 55 | +-I $AlignedPath$SAMPLE$OPT.RGadded.marked.bam \ |
| 56 | +-O $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.bam |
| 57 | + |
| 58 | + |
| 59 | +# 4. Local realignment around indels |
| 60 | +#step1. To create a table of possible indels |
| 61 | +java -jar /opt/Yonsei/GATK/3.8-1/GenomeAnalysisTK.jar \ |
| 62 | +-T RealignerTargetCreator \ |
| 63 | +-R $REF \ |
| 64 | +-I $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.bam \ |
| 65 | +-o $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.forIndelRealigner.list \ |
| 66 | + |
| 67 | + |
| 68 | +# 5. [step2] To realign reads around indels targets |
| 69 | +java -jar /opt/Yonsei/GATK/3.8-1/GenomeAnalysisTK.jar \ |
| 70 | +-T IndelRealigner \ |
| 71 | +-R $REF \ |
| 72 | +-I $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.bam \ |
| 73 | +-targetIntervals $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.forIndelRealigner.list \ |
| 74 | +-o $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.bam \ |
| 75 | + |
| 76 | + |
| 77 | +# 6. The mate information must be fixed# |
| 78 | +java -jar $PICARD/picard.jar FixMateInformation \ |
| 79 | +INPUT=$AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.bam \ |
| 80 | +OUTPUT=$AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.fixed.bam \ |
| 81 | +SO=coordinate \ |
| 82 | +VALIDATION_STRINGENCY=LENIENT \ |
| 83 | +CREATE_INDEX=true \ |
| 84 | +TMP_DIR=$DIR/out/tmp/ |
| 85 | + |
| 86 | + |
| 87 | +#7. Base Quality score recalibration. |
| 88 | +# 7.1) BaseRecalibrator_1st pass |
| 89 | +gatk BaseRecalibrator \ |
| 90 | +-R $REF \ |
| 91 | +-I $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.fixed.bam \ |
| 92 | +--known-sites $dbSNP \ |
| 93 | +-O $AlignedPath$SAMPLE$OPT.recal_pass1.table \ |
| 94 | +--tmp-dir $DIR/out/tmp/ |
| 95 | + |
| 96 | +## 7.2) ApplyBQSR |
| 97 | +gatk ApplyBQSR \ |
| 98 | +-R $REF \ |
| 99 | +-I $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.fixed.bam \ |
| 100 | +--bqsr-recal-file $AlignedPath$SAMPLE$OPT.recal_pass1.table \ |
| 101 | +-O $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.fixed.pre_recal.bam \ |
| 102 | +--tmp-dir $DIR/out/tmp/ |
| 103 | + |
| 104 | +# 7.3) BaseRecalibrator_2st pass |
| 105 | +gatk BaseRecalibrator \ |
| 106 | +-R $REF \ |
| 107 | +-I $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.fixed.pre_recal.bam \ |
| 108 | +--known-sites $dbSNP \ |
| 109 | +-O $AlignedPath$SAMPLE$OPT.recal_pass2.table \ |
| 110 | +--tmp-dir $DIR/out/tmp/ |
| 111 | + |
| 112 | +# 7.4) ApplyBQSR |
| 113 | +gatk ApplyBQSR \ |
| 114 | +-R $REF \ |
| 115 | +-I $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.fixed.pre_recal.bam \ |
| 116 | +--bqsr-recal-file $AlignedPath$SAMPLE$OPT.recal_pass2.table \ |
| 117 | +-O $AlignedPath$SAMPLE$OPT.RGadded.marked.LA.realigned.fixed.recal.bam \ |
| 118 | +--tmp-dir $DIR/out/tmp/ |
| 119 | + |
| 120 | +# 8. Remove intermediate files |
| 121 | +rm $AlignedPath$SAMPLE$OPT.bam |
| 122 | +rm $AlignedPath$SAMPLE$OPT.RGadded.bam |
| 123 | +rm $AlignedPath$SAMPLE$OPT.RGadded.marked.bam |
| 124 | +rm $AlignedPath$SAMPLE$OPT.RGadded.marked.realigned.bam |
| 125 | +rm $AlignedPath$SAMPLE$OPT.RGadded.marked.realigned.fixed.bam |
| 126 | +rm $AlignedPath$SAMPLE$OPT.RGadded.marked.realigned.fixed.pre_recal.bam |
| 127 | + |
| 128 | + |
| 129 | +date |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
0 commit comments