-
Notifications
You must be signed in to change notification settings - Fork 0
/
RNA-seq_variant_calling_GATK_best_practice.sh
187 lines (153 loc) · 8.89 KB
/
RNA-seq_variant_calling_GATK_best_practice.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/bash
for sample in samp01 samp02 samp03 samp04 samp05 samp06 samp07 samp08 samp09 samp10
do
# star 1-pass align
mkdir -p /Test170300561/${sample}/Alignment
cd /Test170300561/${sample}/Alignment
/Software/STAR/STAR-2.5.2a/bin/Linux_x86_64/STAR --runThreadN 12 \
--genomeDir STAR_index \
--readFilesIn /Test170300561/${sample}/Remove_ribosome_data/${sample}_1.fq.gz /Test170300561/${sample}/Remove_ribosome_data/${sample}_2.fq.gz \
--readFilesCommand zcat \
--outFileNamePrefix /Test170300561/${sample}/Alignment/${sample}
# star 2-pass index
mkdir -p /Test170300561/${sample}/STAR2pass_index
cd /Test170300561/${sample}/STAR2pass_index
/Software/STAR/STAR-2.5.2a/bin/Linux_x86_64/STAR --runThreadN 12 \
--runMode genomeGenerate \
--genomeDir /Test170300561/${sample}/STAR2pass_index \
--genomeFastaFiles hg19.fa \
--sjdbFileChrStartEnd /Test170300561/${sample}/Alignment/${sample}SJ.out.tab
rm -rf /Test170300561/${sample}/Alignment/${sample}Aligned.out.sam
# star 2-pass align
mkdir -p /Test170300561/${sample}/Alignment_2pass
cd /Test170300561/${sample}/Alignment_2pass
/Software/STAR/STAR-2.5.2a/bin/Linux_x86_64/STAR --runThreadN 12 \
--genomeDir /Test170300561/${sample}/STAR2pass_index \
--readFilesIn /Test170300561/${sample}/Remove_ribosome_data/${sample}_1.fq.gz /Test170300561/${sample}/Remove_ribosome_data/${sample}_2.fq.gz \
--readFilesCommand zcat \
--outFileNamePrefix /Test170300561/${sample}/Alignment_2pass/${sample}
rm -rf /Test170300561/${sample}/STAR2pass_index/Genome
rm -rf /Test170300561/${sample}/STAR2pass_index/SA
rm -rf /Test170300561/${sample}/STAR2pass_index/SAindex
# picard Add read groups, sort, mark duplicates, and create index
java -jar /Software/picard_tools/picard-tools-2.2.4/picard.jar AddOrReplaceReadGroups \
I=/Test170300561/${sample}/Alignment_2pass/${sample}Aligned.out.sam \
O=/Test170300561/${sample}/Alignment_2pass/${sample}_rg_added_sorted.bam \
SO=coordinate \
RGID=${sample} \
RGLB=rna \
RGPL=illumina \
RGPU=hiseq \
RGSM=${sample}
java -jar /Software/picard_tools/picard-tools-2.2.4/picard.jar MarkDuplicates \
I=/Test170300561/${sample}/Alignment_2pass/${sample}_rg_added_sorted.bam \
O=/Test170300561/${sample}/Alignment_2pass/${sample}_dedup.bam \
CREATE_INDEX=true \
VALIDATION_STRINGENCY=SILENT \
M=/Test170300561/${sample}/Alignment_2pass/${sample}_dedup.metrics
rm -rf /Test170300561/${sample}/Alignment_2pass/${sample}Aligned.out.sam
rm -rf /Test170300561/${sample}/Alignment_2pass/${sample}_rg_added_sorted.bam
# RNA-seq specfic SplitNCigarReads
java -jar GenomeAnalysisTK.jar -T SplitNCigarReads \
-R hg19.fa \
-I /Test170300561/${sample}/Alignment_2pass/${sample}_dedup.bam \
-o /Test170300561/${sample}/Alignment_2pass/${sample}_dedup_split.bam \
-rf ReassignOneMappingQuality \
-RMQF 255 \
-RMQT 60 \
-U ALLOW_N_CIGAR_READS
rm -rf /Test170300561/${sample}/Alignment_2pass/${sample}_dedup.bam
# indel realign optional
# target_interval file must have file extentsion name likg .bed .list .interval
#java -jar GenomeAnalysisTK.jar \
# -T RealignerTargetCreator \
# -R hg19.fa \
# -known /database/human_db/Mills_and_1000G_gold_standard.indels.hg19.sites.vcf \
# -I /Test170300561/${sample}/Alignment_2pass/${sample}_dedup_split.bam \
# -o /Test170300561/${sample}/Alignment_2pass/${sample}_realign_interval.list
#java -jar GenomeAnalysisTK.jar -T IndelRealigner \
# -R hg19.fa \
# -I /Test170300561/${sample}/Alignment_2pass/${sample}_dedup_split.bam \
# -known /database/human_db/Mills_and_1000G_gold_standard.indels.hg19.sites.vcf \
# -o /Test170300561/${sample}/Alignment_2pass/${sample}_realign.bam \
# -targetIntervals /Test170300561/${sample}/Alignment_2pass/${sample}_realign_interval.list
# BQSR optional
#java -jar GenomeAnalysisTK.jar \
# -T BaseRecalibrator \
# -R hg19.fa \
# -I /Test170300561/${sample}/Alignment_2pass/${sample}_realign.bam \
# -knownSites /database/human_db/1000G_phase1.snps.high_confidence.hg19.sites.vcf \
# -knownSites /database/human_db/Mills_and_1000G_gold_standard.indels.hg19.sites.vcf \
# -o /Test170300561/${sample}/Alignment_2pass/${sample}_recal_data.table
#java -jar GenomeAnalysisTK.jar \
# -T PrintReads \
# -R hg19.fa \
# -I /Test170300561/${sample}/Alignment_2pass/${sample}_realign.bam \
# -BQSR /Test170300561/${sample}/Alignment_2pass/${sample}_recal_data.table \
# -o /Test170300561/${sample}/Alignment_2pass/${sample}_BQSR.bam
# variant calling
java -jar GenomeAnalysisTK.jar -T HaplotypeCaller \
-R hg19.fa \
-I /Test170300561/${sample}/Alignment_2pass/${sample}_dedup_split.bam \
-dontUseSoftClippedBases \
-stand_call_conf 20.0 \
-o /Test170300561/${sample}/Alignment_2pass/${sample}.vcf
# variant filter
# select SNP
java -jar GenomeAnalysisTK.jar \
-T SelectVariants \
-R hg19.fa \
-V /Test170300561/${sample}/Alignment_2pass/${sample}.vcf \
-selectType SNP \
-o /Test170300561/${sample}/Alignment_2pass/${sample}.SNP.vcf
# selec INDEL
java -jar GenomeAnalysisTK.jar \
-T SelectVariants \
-R hg19.fa \
-V /Test170300561/${sample}/Alignment_2pass/${sample}.vcf \
-selectType INDEL \
-o /Test170300561/${sample}/Alignment_2pass/${sample}.INDEL.vcf
# filter SNP
java -jar GenomeAnalysisTK.jar \
-T VariantFiltration \
-R hg19.fa \
-V /Test170300561/${sample}/Alignment_2pass/${sample}.SNP.vcf \
-window 35 \
-cluster 3 \
-filterName 'MY_SNP_Filter' -filter 'DP < 10.0 || QD < 2.0 || FS > 30.0 || MQ < 40.0 || MQRankSum < -12.5 || ReadPosRankSum < -8.0'\
-o /Test170300561/${sample}/Alignment_2pass/${sample}.SNP.filtered.vcf
rm /Test170300561/${sample}/Alignment_2pass/${sample}.SNP.vc*
# filter INDEL
java -jar GenomeAnalysisTK.jar \
-T VariantFiltration \
-R hg19.fa \
-V /Test170300561/${sample}/Alignment_2pass/${sample}.INDEL.vcf \
-window 35 \
-cluster 3 \
-filterName 'MY_INDEL_Filter' -filter 'DP < 10.0 || QD < 2.0 || FS > 60.0 || ReadPosRankSum < -20.0'\
-o /Test170300561/${sample}/Alignment_2pass/${sample}.INDEL.filtered.vcf
rm /Test170300561/${sample}/Alignment_2pass/${sample}.INDEL.vc*
# combine SNP and INDEL vcf
java -jar GenomeAnalysisTK.jar \
-T CombineVariants \
-R hg19.fa \
-V /Test170300561/${sample}/Alignment_2pass/${sample}.SNP.filtered.vcf \
-V /Test170300561/${sample}/Alignment_2pass/${sample}.INDEL.filtered.vcf \
-o /Test170300561/${sample}/Alignment_2pass/${sample}.ALL.filtered.vcf \
-genotypeMergeOptions UNSORTED
rm /Test170300561/${sample}/Alignment_2pass/${sample}.SNP.filtered.vc* /Test170300561/${sample}/Alignment_2pass/${sample}.INDEL.filtered.vc*
# filter only passed
vcftools --vcf /Test170300561/${sample}/Alignment_2pass/${sample}.ALL.filtered.vcf --remove-filtered-all --minQ 10 --recode --stdout > /Test170300561/${sample}/Alignment_2pass/${sample}.passed.vcf
rm /Test170300561/${sample}/Alignment_2pass/${sample}.ALL.filtered.vc*
# snpEff annotate
java -jar /home/software/snpEff/snpEff.jar hg19 /Test170300561/${sample}/Alignment_2pass/${sample}.passed.vcf > /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.vcf
java -jar /home/software/snpEff/SnpSift.jar annotate -noDownload -v /database/ClinVar/clinvar_20160802+papu.vcf /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.vcf > /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.vcf
java -jar /home/software/snpEff/SnpSift.jar annotate -noDownload -v /database/human_db/dbsnp_138.hg19.vcf /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.vcf > /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.dbsnp138.vcf
java -jar /home/software/snpEff/SnpSift.jar annotate -noDownload -v /database/human_db/dbsnp_142.hg19.vcf /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.dbsnp138.vcf > /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.dbsnp138.dbsnp142.vcf
java -jar /home/software/snpEff/SnpSift.jar annotate -noDownload -v /database/human_db/ESP6500SI-V2-SSA137.GRCh38-liftover.snps_indels.vcf /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.dbsnp138.dbsnp142.vcf > /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.dbsnp138.dbsnp142.esp6500.vcf
rm /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.vcf
rm /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.vcf
rm /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.dbsnp138.vcf
rm /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.dbsnp138.dbsnp142.vcf
mv /Test170300561/${sample}/Alignment_2pass/${sample}.passed.eff.clinvar.dbsnp138.dbsnp142.esp6500.vcf /Test170300561/${sample}/Alignment_2pass/${sample}.passed.ann.vcf
done