{"id":402,"date":"2020-11-02T20:37:39","date_gmt":"2020-11-02T19:37:39","guid":{"rendered":"https:\/\/itrop.ird.fr\/wordpress\/?page_id=402"},"modified":"2022-04-06T14:50:44","modified_gmt":"2022-04-06T12:50:44","slug":"polymorphism-detection","status":"publish","type":"page","link":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/","title":{"rendered":"Tutorials &#8211; Polymorphism detection"},"content":{"rendered":"<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Polymorphism detection from fastq files on a linux terminal.<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Description<\/td>\n<td>This page describes a serie of tools and linux commands used to detect polymorphism from raw data (fastq files) to polymorphism file (vcf).<\/td>\n<\/tr>\n<tr>\n<td>Authors<\/td>\n<td>christine Tranchant-Dubreuil (christine.tranchant@ird.fr)<\/td>\n<\/tr>\n<tr>\n<td>Creation Date<\/td>\n<td>10\/03\/2017<\/td>\n<\/tr>\n<tr>\n<td>Last Modified Date<\/td>\n<td>06\/08\/2018<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We need, in this tutorial:<\/p>\n<ul>\n<li>2 fastq files paired<\/li>\n<li>a reference file used for the mapping step.<\/li>\n<\/ul>\n<h3>Keywords<\/h3>\n<p>fastq-stats, fastqc, cutadapt, bwa, samtools, gatk, picardtools<\/p>\n<h3>Files format<\/h3>\n<p>fastq, sam, bam, vcf<\/p>\n<h3>Summary<\/h3>\n<ul>\n<li><a href=\"#fastq-info\">Getting basic informations about FASTQ files<\/a>\n<ul>\n<li><a href=\"#fastq-files-size\">How to get <em>fastq<\/em> file size?  <code>du -sh<\/code><\/a><\/li>\n<li><a href=\"#fastq-seq\">How to get sequences number by <em>fastq<\/em> files (uncompressed files only)?<\/a><\/li>\n<li><a href=\"#ea-utils\">Getting quickly a report with various statistics about  file with <code>ea-utils<\/code> <\/a><\/li>\n<li><a href=\"#fastqc\">Getting various statistics about <em>fastq<\/em> and performing a quality control check with <code>fastqc<\/code><\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#fastq-cleaning\">FASTQ cleaning<\/a>\n<ul>\n<li><a href=\"#cutadapt\">Using <code>cutadapt<\/code> to remove adapters and to trim reads based on quality<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#mapping\">Mapping step with <code>bwa<\/code><\/a>\n<ul>\n<li><a href=\"#mapping-index\">Creating an index of the reference genome with <code>bwa index<\/code><\/a><\/li>\n<li><a href=\"#mapping-aln\">Performing mapping with <code>bwa aln<\/code> and <code>bwa sampe\/samse<\/code><\/a><\/li>\n<li><a href=\"#mapping-mem\">Performing mapping with <code>bwa mem<\/code><\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#picardtools-samtools\">Processing <em>sam<\/em> file with <code>picardtools<\/code> and <code>samtools<\/code><\/a>\n<ul>\n<li><a href=\"#picardtools-dictionary\">Creating Reference dictionary with <code>picardtools CreateSequenceDictionary<\/code><\/a><\/li>\n<li><a href=\"#samtools-faidx\">Creating Reference indexes with <code>samtools faidx<\/code><\/a><\/li>\n<li><a href=\"#picardtools-sortSam\">Converting the <em>sam<\/em> file into a <em>bam<\/em> file and sorting the <em>bam<\/em> file with <code>picardtools SortSam<\/code><\/a><\/li>\n<li><a href=\"#samtools-flagstat\">Getting some stats from <em>bam<\/em> file with <code>samtools flagstat<\/code><\/a><\/li>\n<li><a href=\"#samtools-idxstats\">Getting some stats from <em>bam<\/em> file with <code>samtools idxstats<\/code><\/a><\/li>\n<li><a href=\"#bedtools-coverage\">Getting coverage from <em>bam<\/em> file with <code>bedtools coverage<\/code><\/a><\/li>\n<li><a href=\"#samtools-view\">Remove multimapping and incorrectly mapping reads with <code>samtools view<\/code><\/a><\/li>\n<li><a href=\"#samtools-index\">Creating index of the last bam generated with <code>samtools index<\/code><\/a><\/li>\n<li><a href=\"#picardtools-rg\">Adding read group with <code>picardtools AddOrReplaceReadGroups<\/code><\/a><\/li>\n<li><a href=\"#picardtools-duplicate\">Marking duplicates with <code>picardtools MarkDuplicates<\/code><\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#gatk-indelrealigner\">Local realignment around INDELS using <code>GATK<\/code><\/a>\n<ul>\n<li><a href=\"#gatk-indelrealigner1\">Creating a target list of intervals which need to be realigned with <code>gatk realignerTargetCreator<\/code><\/a><\/li>\n<li><a href=\"#gatk-indelrealigner2\">Performing realignment of the target intervals with <code>gatk indelRealigner<\/code><\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#snp-calling\">SNP\/INDEL calling<\/a>\n<ul>\n<li><a href=\"#gatk-hc\">with <code>GATK haplotypeCaller<\/code><\/a> <\/li>\n<li><a href=\"#gatk-ug\">with <code>GATK unifiedGenotyper<\/code><\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#gatk-filters\">Basic Filtering vcf files using <code>GATK<\/code><\/a>\n<ul>\n<li><a href=\"#gatk-vf\">with <code>gatk variantFiltration<\/code><\/a><\/li>\n<li><a href=\"#gatk-sv\">with <code>gatk selectVariants<\/code><\/a><\/li>\n<\/ul>\n<\/li>\n<li>\n<h2><a href=\"#license\">License<\/a> <\/h2>\n<\/li>\n<\/ul>\n<p><a name=\"fastq-info\"><\/a><\/p>\n<h3>Getting basic informations about FASTQ files<\/h3>\n<p><a name=\"fastq-files-size\"><\/a><\/p>\n<h4>How to get <em>fastq<\/em> file size?  <code>du -sh<\/code><\/h4>\n<pre><code>[tranchant@master0 ~]$ du -sh *.fastq\n311M    C3KB2ACXX_5_12_11_debar.fastq\n525M    C3KB2ACXX_5_12_12_debar.fastq\n<\/code><\/pre>\n<p><a name=\"fastq-seq\"><\/a><\/p>\n<h4>How to get sequences number by <em>fastq<\/em> files  (uncompressed files only)?<\/h4>\n<pre><code>[tranchant@master0 ~]$ wc -l *.fastq | awk &#039;{ print $2&quot; \\t &quot;$1\/4}&#039;\nC3KB2ACXX_5_12_11_debar.fastq    1354891\nC3KB2ACXX_5_12_12_debar.fastq    2249353<\/code><\/pre>\n<hr \/>\n<p><a name=\"ea-utils\"><\/a><\/p>\n<h4>Getting quickly a report with various statistics about <em>fastq<\/em> file with <code>ea-utils<\/code><\/h4>\n<p>This software runs quickly, faster than fastqc and the output can be parsed and formatted with some basics linux command<br \/>\n<a href=\"https:\/\/code.google.com\/p\/ea-utils\/\">ea-utils website<\/a><\/p>\n<h6>How to use <code>fastq-stats<\/code> with one <em>fastq<\/em> file<\/h6>\n<pre><code>[tranchant@node11 FASTQ]$ fastq-stats -D PdFIE94_R1.fq.gz\nreads   15034838\nlen 144\nlen mean    144.0000\nlen stdev   0.0000\nlen min 144\nphred   33\nwindow-size 2000000\ncycle-max   35\nqual min    2\nqual max    42\nqual mean   40.2191\nqual stdev  4.8129\n%A  25.5314\n%C  26.3730\n%G  22.4570\n%T  25.6209\n%N  0.0178\ntotal bases 2165016672<\/code><\/pre>\n<h6>How to use <code>fastq-stats<\/code> on several <em>fastq<\/em> files<\/h6>\n<pre><code>[tranchant@node2 tranchant]$ ls\nDV.UNMAPPED_1.fastq              DV.UNMAPPED_2.fastq\nDT.UNMAPPED_1.fastq              DT.UNMAPPED_2.fastq\n\n# you can execute every fastq-stats command by using for loop (bash)\n[tranchant@node2 tranchant]$ for file in *fastq; do fastq-stats -D $file &gt; $file.fastq-stats ; done;\n\n#Check that the files have been created\n[tranchant@node2 tranchant]$ ls -l *stats\n-rw-r--r-- 1 tranchant ggr 246  8 juin  14:55 DT.UNMAPPED_1.fastq.fastq-stats\n-rw-r--r-- 1 tranchant ggr 247  8 juin  14:55 DT.UNMAPPED_2.fastq.fastq-stats\n-rw-r--r-- 1 tranchant ggr 246  8 juin  14:55 DV.UNMAPPED_1.fastq.fastq-stats\n-rw-r--r-- 1 tranchant ggr 246  8 juin  14:55 DV.UNMAPPED_2.fastq.fastq-stats\n\n#check one file\n[tranchant@node2 tranchant]$ cat DT.UNMAPPED_1.fastq.fastq-stats\nreads   11043989\nlen 101\nlen mean    99.3377\nlen stdev   7.4780\nlen min 30\nphred   33\nwindow-size 2000000\ncycle-max   35\nqual min    2\nqual max    41\nqual mean   37.7341\nqual stdev  3.8379\n%A  29.2366\n%C  20.8381\n%G  20.7269\n%T  29.1967\n%N  0.0017\ntotal bases 1097084447<\/code><\/pre>\n<h6>How to get a tab file from all files generated by the command <code>ls | cut | sed | sh<\/code><\/h6>\n<pre><code># To generate a header\n[tranchant@node11 FASTQ]$ cut -f1 PdFIE94_R1.fq.gz.fastq-stats | paste -s - - &gt; all.stats\n\n# To display header file\n[tranchant@node11 FASTQ]$ head all.stats\nreads   len len mean    len stdev   len min phred   window-size cycle-max   qual min    qual max    qual mean   qual stdev  %A  %C  %G  %T  %N  total bases\n\n# To parse every file and to create a tab-delimited file\n[tranchant@node11 FASTQ]$ awk &#039;BEGIN { num=0;  }  { num++; if (num == 1) { print FILENAME }  print $NF; if (num == 18) {print &quot;\\n&quot;; num=0; } } END {  } &#039; *fastq-stats   |   awk &#039; BEGIN { RS=&quot;\\n\\n&quot;; ;} { print $1,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19;}&#039; &gt;&gt; all.stats\n\n# Display 10 first lines of the file all.stats\n[tranchant@node11 FASTQ]$ head all.stats\nreads   len len mean    len stdev   len min phred   window-size cycle-max   qual min    qual max    qual mean   qual stdev  %A  %C  %G  %T  %N  total bases\nPdFIE94_R1.fq.gz.fastq-stats 144 144.0000 0.0000 144 33 2000000 35 2 42 40.2191 4.8129 25.5314 26.3730 22.4570 25.6209 0.0178 2165016672\nPdFIE94_R2.fq.gz.fastq-stats 151 151.0000 0.0000 151 33 2000000 35 2 42 34.8602 10.4600 26.6998 23.6108 22.8715 26.4631 0.3548 2270260538\nPdFIE95_R1.fq.gz.fastq-stats 143 143.0000 0.0000 143 33 2000000 35 2 42 40.1422 4.9354 25.2075 26.6116 22.5737 25.5869 0.0202 1873211197\nPdFIE95_R2.fq.gz.fastq-stats 151 151.0000 0.0000 151 33 2000000 35 2 42 35.0387 10.3787 26.5003 24.0084 23.0377 26.0990 0.3546 1978006229\nPdFIE96_R1.fq.gz.fastq-stats 143 143.0000 0.0000 143 33 2000000 35 2 42 40.1133 4.9931 25.0246 26.6680 22.6115 25.6756 0.0204 1488540911\nPdFIE96_R2.fq.gz.fastq-stats 151 151.0000 0.0000 151 33 2000000 35 2 42 34.9494 10.4096 26.5905 24.0838 23.1924 25.7780 0.3554 1571815927\nPdFIE98_R1.fq.gz.fastq-stats 143 143.0000 0.0000 143 33 2000000 35 2 42 40.2191 4.8173 25.3874 26.4649 22.4244 25.7031 0.0201 1443785200\nPdFIE98_R2.fq.gz.fastq-stats 151 151.0000 0.0000 151 33 2000000 35 2 42 35.0267 10.3824 26.6316 23.8662 22.8668 26.2791 0.3564 1524556400<\/code><\/pre>\n<hr \/>\n<p><a name=\"fastqc\"><\/a><\/p>\n<h4>Getting various statistics about <em>fastq<\/em> and performing a quality control check with <code>fastqc<\/code><\/h4>\n<ul>\n<li>to perform some simple quality control checks to ensure that the raw data looks good and there are no problems or biases in data which may affect how user can usefully use it. <a href=\"http:\/\/www.bioinformatics.babraham.ac.uk\/projects\/fastqc\/\">fastqc website<\/a><\/li>\n<\/ul>\n<pre><code>[tranchant@master0 ~]$ fastqc *.fastq -o .\n[tranchant@master0 ~]$ ls\ntotal 543577236\ndrwxr-xr-x 4 tranchant ggr                4096  9 mars  22:11 PdFIE94_R1.fq_fastqc\n-rw-r--r-- 1 tranchant ggr              225516  9 mars  22:11 PdFIE94_R1.fq_fastqc.zip\n<\/code><\/pre>\n<hr \/>\n<p><a name=\"fastq-cleaning\"><\/a><\/p>\n<h3>FASTQ cleaning<\/h3>\n<p><a name=\"cutadapt\"><\/a><\/p>\n<h4>Using <code>cutadapt<\/code> to remove adapters and to trim reads based on quality<\/h4>\n<ul>\n<li><a href=\"https:\/\/code.google.com\/p\/cutadapt\/\">cutadapt website<\/a><\/li>\n<\/ul>\n<pre><code>cutadapt  -q 30,30 -m 35  -B GATCGGAAGAGCACACGTCTGAACTCCAGTCACATCACGATCTCGTATGCCGTCTTCTGCTTG -B GTTCGTCTTCTGCCGTATGCTCTAGCACTACACTGACCTCAAGTCTGCACACGAGAAGGCTAG -b GATCGGAAGAGCACACGTCTGAACTCCAGTCACATCACGATCTCGTATGCCGTCTTCTGCTTG -b GTTCGTCTTCTGCCGTATGCTCTAGCACTACACTGACCTCAAGTCTGCACACGAGAAGGCTAG-o P1_R1.CUTADAPT.fastq.gz -p P1_R2.CUTADAPT.fastq.gz P1_R1.fq.gz P1_R2.fq.gz<\/code><\/pre>\n<ul>\n<li><code>Cutadapt<\/code> supports trimming of multiple types of adapters:<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">Adapter type<\/th>\n<th style=\"text-align: left;\">Command-line option<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">3\u2019 adapter<\/td>\n<td style=\"text-align: left;\">-a ADAPTER<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">5\u2019 adapter<\/td>\n<td style=\"text-align: left;\">-g ADAPTER<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">5\u2019 or 3\u2019 (both possible)<\/td>\n<td style=\"text-align: left;\">-b ADAPTER<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>-q 30, 30 : by default, only the 3\u2019 end of each read is quality-trimmed. If you want to trim the 5\u2019 end as well, use the -q option with two comma-separated cutoffs<\/p>\n<p>-p is the short form of --paired-output. The option -B is used here to specify an adapter sequence that cutadapt should remove from the second read in each pair.<\/p>\n<hr \/>\n<p><a name=\"mapping\"><\/a><\/p>\n<h3>Mapping step with <code>bwa<\/code><\/h3>\n<ul>\n<li><a href=\"http:\/\/bio-bwa.sourceforge.net\/\">bwa website<\/a><\/li>\n<\/ul>\n<p><a name=\"mapping-index\"><\/a><\/p>\n<h4>Creating an index of the reference genome with <code>bwa index<\/code><\/h4>\n<pre><code>bwa index -a is<\/code><\/pre>\n<blockquote>\n<p><code>is<\/code> for short genome<br \/>\n<code>bwtsw<\/code> for genome &gt;2Gb<\/p>\n<\/blockquote>\n<p><a name=\"mapping-aln\"><\/a><\/p>\n<h4>Performing mapping with <code>bwa aln<\/code> and <code>bwa sampe\/samse<\/code><\/h4>\n<h6>Getting <em>sai<\/em> files with <code>bwa aln<\/code><\/h6>\n<pre><code>bwa aln reference file_forward.fastq &gt; file_forward.sai\nbwa aln reference file_reverse.fastq &gt; file_reverse.sai<\/code><\/pre>\n<h6>Getting <em>sam<\/em> file with <code>bwa sampe<\/code> (paired)<\/h6>\n<p>Here is a description for the contents of the SAM file: <a href=\"https:\/\/samtools.github.io\/hts-specs\/SAMv1.pdf\">https:\/\/samtools.github.io\/hts-specs\/SAMv1.pdf<\/a><\/p>\n<pre><code>bwa sampe reference file_forward.sai file_reverse.sai  file_forward.fastq file_reverse.fastq -f file.sam  -r &#039;@RG        ID:RG  SM:RG  PL:Illumina&#039;<\/code><\/pre>\n<h6>Getting <em>sam<\/em> file with <code>bwa samse<\/code> (single)<\/h6>\n<pre><code>bwa samse reference file.sai file.fastq file_reverse.fastq -f file.sam  -r &#039;@RG        ID:RG  SM:RG  PL:Illumina&#039;<\/code><\/pre>\n<p><a name=\"mapping-mem\"><\/a><\/p>\n<h4>Performing mapping with <code>bwa mem<\/code><\/h4>\n<pre><code>bwa mem  reference file.fastq  file_reverse.fastq  -R &#039;@RG\\tID:RC3\\tSM:RC3\\tPL:Illumina&#039; &gt; file.sam<\/code><\/pre>\n<hr \/>\n<p><a name=\"picardtools-samtools\"><\/a><\/p>\n<h3>Processing sam file with <code>picardtools<\/code> and <code>samtools<\/code><\/h3>\n<ul>\n<li><a href=\"https:\/\/broadinstitute.github.io\/picard\/\">picard website<\/a><\/li>\n<li><a href=\"http:\/\/samtools.sourceforge.net\/\">samtools website<\/a><\/li>\n<\/ul>\n<p><a name=\"picardtools-dictionary\"><\/a><\/p>\n<h4>Creating Reference dictionary with <code>picardtools CreateSequenceDictionary<\/code><\/h4>\n<pre><code>\/usr\/bin\/java -Xmx8g  -jar \/us\/local\/picard-tools-2.5.0\/picard.jar CreateSequenceDictionary REFERENCE=Reference.fasta OUTPUT=Reference.dict<\/code><\/pre>\n<p><a name=\"samtools-faidx\"><\/a><\/p>\n<h4>Creating Reference indexes with <code>samtools faidx<\/code><\/h4>\n<pre><code>samtools faidx Rreference.fasta<\/code><\/pre>\n<p><a name=\"picardtools-sortSam\"><\/a><\/p>\n<h4>Converting the <em>sam<\/em> file into a <em>bam<\/em> file and sorting the <em>bam<\/em> file with <code>picardtools SortSam<\/code><\/h4>\n<pre><code>\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/picard-tools-2.5.0\/picard.jar SortSam  CREATE_INDEX=TRUE VALIDATION_STRINGENCY=SILENT SORT_ORDER=coordinate  INPUT=file.BWASAMPE.sam OUTPUT=file.PICARDTOOLSSORT.bam<\/code><\/pre>\n<p>The <em>bam<\/em> index (<em>.bai<\/em>) is created auomtically by <code>picardtools<\/code> (<code>samtools index<\/code> command unnecessary)<\/p>\n<p><a name=\"samtools-flagstat\"><\/a><\/p>\n<h4>Getting some stats from <em>bam<\/em> file with <code>samtools flagstat<\/code><\/h4>\n<pre><code>#command\n$samtools flagstat file.PICARDTOOLSSORT.bam\n\n#output\n14524094 + 0 in total (QC-passed reads + QC-failed reads)\n0 + 0 secondary\n0 + 0 supplimentary\n0 + 0 duplicates\n11219302 + 0 mapped (77.25%:-nan%)\n0 + 0 paired in sequencing\n0 + 0 read1\n0 + 0 read2\n0 + 0 prorubyy paired (-nan%:-nan%)\n0 + 0 with itself and mate mapped\n0 + 0 singletons (-nan%:-nan%)\n0 + 0 with mate mapped to a different chr\n0 + 0 with mate mapped to a different chr (mapQ&gt;=5)<\/code><\/pre>\n<p><a name=\"samtools-idxstats\"><\/a><\/p>\n<h4>Getting some stats from <em>bam<\/em> file with <code>samtools idxstats<\/code><\/h4>\n<pre><code>#command\n$samtools idxstats file.PICARDTOOLSSORT.bam\n\n#The output is TAB-delimited with each line consisting of reference sequence name, sequence length, # mapped reads and # unmapped reads. #It is written to stdout.\nChromosome_8.1  7978604 2274010 0\nChromosome_8.2  8319966 2274086 0\nChromosome_8.3  6606598 1774006 0\nChromosome_8.4  5546968 1483879 0\nChromosome_8.5  4490059 1217779 0\nChromosome_8.6  4133993 1132535 0\nChromosome_8.7  3415785 945505  0\nChromosome_8.8  535760  117502  0\n*   0   0   3304792<\/code><\/pre>\n<p><a name=\"bedtools-coverage\"><\/a><\/p>\n<h4>Getting coverage from <em>bam<\/em> file with <code>bedtools coverage<\/code><\/h4>\n<ul>\n<li><a href=\"http:\/\/bedtools.readthedocs.io\/en\/latest\/content\/tools\/genomecov.html\">bedtools coverage manual<\/a><\/li>\n<\/ul>\n<pre><code>#command\n# -bg option : reports in BEDGRAPH format only for those regions of the genome that actually have coverage. \n\n# This option produces genome-wide coverage output in BEDGRAPH format much more concise since consecutive positions with the same coverage are reported as a single output line describing the start and end coordinate of the interval having the coverage level, followed by the coverage level itself.\n\n# -bga option : a complete report including the regions with zero coverage.\n$bedtools genomecov -ibam AAOSW.PICARDTOOLSSORT.bam -g \/scratch\/tranchant\/referenceFiles\/OglaRS2ADWL02.fa -bga &gt; AAOSW.PICARDTOOLSSORT.bam.BEDTOOLSGENOMECOV\n\n#The output is TAB-delimited with each line consisting of reference sequence name, start position, end position,  coverage level\n$less AAOSW.PICARDTOOLSSORT.bam.BEDTOOLSGENOMECOV\nChr01   0       2       1\nChr01   2       7       3\nChr01   7       13      6\nChr01   13      14      8\nChr01   14      15      9\nChr01   15      16      11\nChr01   16      18      12\nChr01   18      19      13\nChr01   19      23      14\nChr01   23      29      16\nChr01   29      32      18\nChr01   32      33      19\nChr01   33      34      20\nChr01   34      36      21\nChr01   36      38      22\nChr01   38      39      24\nChr01   39      40      26\n<\/code><\/pre>\n<p><a name=\"samtools-view\"><\/a><\/p>\n<h4>Remove multimapping and incorrectly mapping reads with <code>samtools view<\/code><\/h4>\n<ul>\n<li><a href=\"https:\/\/broadinstitute.github.io\/picard\/explain-flags.html\">Defining flag value<\/a><\/li>\n<li><a href=\"https:\/\/ppotato.wordpress.com\/2010\/08\/25\/samtool-bitwise-flag-paired-reads\/\">more explanation<\/a><\/li>\n<\/ul>\n<pre><code># Reads correctly mapped extracted\nsamtools view -h -b -f=0*02 -o file.SAMTOOLSVIEW-MAPPED.bam file.PICARDTOOLSSORT.bam\n\n# Unmapped reads extracted\nsamtools view -h -b -F=0*02 -o file.SAMTOOLSVIEW-UNMAPPED.bam file.PICARDTOOLSSORT.bam\n<\/code><\/pre>\n<p><a name=\"samtools-index\"><\/a><\/p>\n<h4>Creating index of the last bam generated with <code>samtools index<\/code><\/h4>\n<pre><code>#Command\nsamtools index file.SAMTOOLSVIEW-MAPPED.bam<\/code><\/pre>\n<p><a name=\"picardtools-rg\"><\/a><\/p>\n<h4>Adding read group with <code>picardtools AddOrReplaceReadGroups<\/code><\/h4>\n<p>... if they haven't been added precedently<\/p>\n<pre><code>#Command\n\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/picard-tools-2.5.0\/picard.jar AddOrReplaceReadGroups INPUT=20135.SAMTOOLSVIEW-MAPPED.bam OUTPUT=20135.PICARDTOOLSADDORREPLACEREADGROUPS.bam RGPL=Illumina RGLB=20135 RGPU=20135 RGSM=20135 CREATE_INDEX=True VALIDATION_STRINGENCY=LENIENT &gt; 20135.PICARDTOOLSADDORREPLACEREADGROUPS.log<\/code><\/pre>\n<ul>\n<li>RGPL= Read Group Platform (i.e. Illumina)<\/li>\n<li>RGLB= Read Group Library (i.e. DNA preparation library identity i.e &quot;HG19&quot;)<\/li>\n<li>RGPU= Read Group Platform Unit (i.e Barcode)<\/li>\n<li>RGSM= Read Group Sample Name (i.e. Sample Name)<\/li>\n<\/ul>\n<p><a name=\"picardtools-duplicate\">&lt;\/a<\/p>\n<h4>Marking duplicates with <code>picardtools MarkDuplicates<\/code><\/h4>\n<p>... if it is necessary<\/p>\n<pre><code>#Command\n\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/picard-tools-2.5.0\/picard.jar MarkDuplicates INPUT=20135.SAMTOOLSVIEW-MAPPED.bam OUTPUT=20135.PICARDTOOLSMARKDUPLICATES.bam METRICS_FIL=metrics.txt CREATE_INDEX=True VALIDATION_STRINGENCY=LENIENT &gt; 20135.PICARDTOOLSADDORREPLACEREADGROUPS.log<\/code><\/pre>\n<hr \/>\n<p><a name=\"gatk-indelrealigner\"><\/a><\/p>\n<h3>Local realignment around INDELS using <code>GATK<\/code><\/h3>\n<ul>\n<li><a href=\"https:\/\/www.broadinstitute.org\/gatk\/\">gatk website<\/a><\/li>\n<\/ul>\n<p><a name=\"gatk-indelrealigner1\"><\/a><\/p>\n<h4>Creating a target list of intervals which need to be realigned with <code>gatk realignerTargetCreator<\/code><\/h4>\n<pre><code>#command\n\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/gatk-3.7\/GenomeAnalysisTK.jar -T RealignerTargetCreator  -R reference -I file.bam -o file.GATKREALIGNERTARGETCREATOR.intervals<\/code><\/pre>\n<p><a name=\"gatk-indelrealigner2\"><\/a><\/p>\n<h4>Performing realignment of the target intervals with <code>gatk indelRealigner<\/code><\/h4>\n<pre><code>#Command\n\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/gatk-3.7\/GenomeAnalysisTK.jar -T IndelRealigner  -R reference -I file.bam -targetIntervals file.GATKREALIGNERTARGETCREATOR.intervals -o file.GATKINDELREALIGNER.bam<\/code><\/pre>\n<hr \/>\n<p><a name=\"gatk-ug-hc\"><\/a><\/p>\n<h3>SNP\/INDEL calling<\/h3>\n<p><a name=\"gatk-hc\"><\/a><\/p>\n<h4>with <code>GATK haplotypeCaller<\/code><\/h4>\n<pre><code>\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/gatk-3.7\/GenomeAnalysisTK.jar -rf BadCigar  -T HaplotypeCaller  -R reference -I file-ind1.PICARDTOOLSMARKDUPLICATES.bam -I  file-ind2.PICARDTOOLSMARKDUPLICATES.bam  -o file.GATKHAPLOTYPECALLER.vcf<\/code><\/pre>\n<p><a name=\"gatk-ug\"><\/a><\/p>\n<h4>with <code>GATK unifiedGenotyper<\/code><\/h4>\n<pre><code>\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/gatk-3.7\/GenomeAnalysisTK.jar -rf BadCigar   -T UnifiedGenotyper -R reference -I file.bam  -o file.GATKUNIFIEDGENOTYPER.vcf<\/code><\/pre>\n<hr \/>\n<p><a name=\"gatk-filters\"><\/a><\/p>\n<h3>Basic Filtering vcf files using <code>GATK<\/code><\/h3>\n<h4>with <code>gatk variantFiltration<\/code><\/h4>\n<pre><code>\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/gatk-3.7\/GenomeAnalysisTK.jar -T VariantFiltration --filterName &#039;FILTER-DP&#039; --filterExpression &#039;DP&lt;10 || DP&gt;600&#039; --filterName &#039;LowQual&#039; --filterExpression &#039;QUAL&lt;30&#039;   -R \/reference -o file.GATKVARIANTFILTRATION.vcf --variant file.GATKHAPLOTYPECALLER.vcf<\/code><\/pre>\n<p><a name=\"gatk-sv\"><\/a><\/p>\n<h4>with <code>gatk selectVariants<\/code><\/h4>\n<pre><code>\/usr\/bin\/java -Xmx12g -jar \/usr\/local\/gatk-3.7\/GenomeAnalysisTK.jar -selectType SNP -T SelectVariants  -R reference --variant file.GATKVARIANTFILTRATION.vcf -o file.GATKSELECTVARIANT.vcf<\/code><\/pre>\n<hr \/>\n<h3>More informations<\/h3>\n<p><a href=\"https:\/\/southgreenplatform.github.io\/trainings\/\">NGS workflow Managers and linux trainings realized by the South Green Platform<\/a><\/p>\n<hr \/>\n<h3>License<\/h3>\n<p><a name=\"license\"><\/a><\/p>\n<div>\nThe resource material is licensed under the Creative Commons Attribution 4.0 International License (<a href=\"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/4.0\/\">here<\/a>).<br \/>\n<center><img decoding=\"async\" width=\"25%\" class=\"img-responsive\" src=\"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png\"\/><br \/>\n<\/center>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Name Polymorphism detection from fastq files on a linux terminal. Description This page describes a serie of tools and linux&hellip; <br \/> <a class=\"read-more\" href=\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/\">Lire la suite<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1325,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-402","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Tutorials - Polymorphism detection - itrop<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tutorials - Polymorphism detection - itrop\" \/>\n<meta property=\"og:description\" content=\"Name Polymorphism detection from fastq files on a linux terminal. Description This page describes a serie of tools and linux&hellip; Lire la suite\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/\" \/>\n<meta property=\"og:site_name\" content=\"itrop\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-06T12:50:44+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ItropBioinfo\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/\",\"url\":\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/\",\"name\":\"Tutorials - Polymorphism detection - itrop\",\"isPartOf\":{\"@id\":\"https:\/\/bioinfo.ird.fr\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png\",\"datePublished\":\"2020-11-02T19:37:39+00:00\",\"dateModified\":\"2022-04-06T12:50:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#primaryimage\",\"url\":\"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png\",\"contentUrl\":\"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/bioinfo.ird.fr\/index.php\/en\/front-page-2\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials &#8211; FR\",\"item\":\"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Tutorials &#8211; Polymorphism detection\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bioinfo.ird.fr\/#website\",\"url\":\"https:\/\/bioinfo.ird.fr\/\",\"name\":\"itrop\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/bioinfo.ird.fr\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bioinfo.ird.fr\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/bioinfo.ird.fr\/#organization\",\"name\":\"i-Trop\",\"url\":\"https:\/\/bioinfo.ird.fr\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/bioinfo.ird.fr\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/bioinfo.ird.fr\/wp-content\/uploads\/2021\/10\/i-tropTwt5.png\",\"contentUrl\":\"https:\/\/bioinfo.ird.fr\/wp-content\/uploads\/2021\/10\/i-tropTwt5.png\",\"width\":1356,\"height\":1356,\"caption\":\"i-Trop\"},\"image\":{\"@id\":\"https:\/\/bioinfo.ird.fr\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/ItropBioinfo\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Tutorials - Polymorphism detection - itrop","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/","og_locale":"fr_FR","og_type":"article","og_title":"Tutorials - Polymorphism detection - itrop","og_description":"Name Polymorphism detection from fastq files on a linux terminal. Description This page describes a serie of tools and linux&hellip; Lire la suite","og_url":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/","og_site_name":"itrop","article_modified_time":"2022-04-06T12:50:44+00:00","og_image":[{"url":"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@ItropBioinfo","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/","url":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/","name":"Tutorials - Polymorphism detection - itrop","isPartOf":{"@id":"https:\/\/bioinfo.ird.fr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#primaryimage"},"image":{"@id":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#primaryimage"},"thumbnailUrl":"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png","datePublished":"2020-11-02T19:37:39+00:00","dateModified":"2022-04-06T12:50:44+00:00","breadcrumb":{"@id":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#primaryimage","url":"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png","contentUrl":"http:\/\/creativecommons.org.nz\/wp-content\/uploads\/2012\/05\/by-nc-sa1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/polymorphism-detection\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/bioinfo.ird.fr\/index.php\/en\/front-page-2\/"},{"@type":"ListItem","position":2,"name":"Tutorials &#8211; FR","item":"https:\/\/bioinfo.ird.fr\/index.php\/tutorials-fr\/"},{"@type":"ListItem","position":3,"name":"Tutorials &#8211; Polymorphism detection"}]},{"@type":"WebSite","@id":"https:\/\/bioinfo.ird.fr\/#website","url":"https:\/\/bioinfo.ird.fr\/","name":"itrop","description":"","publisher":{"@id":"https:\/\/bioinfo.ird.fr\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bioinfo.ird.fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/bioinfo.ird.fr\/#organization","name":"i-Trop","url":"https:\/\/bioinfo.ird.fr\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/bioinfo.ird.fr\/#\/schema\/logo\/image\/","url":"https:\/\/bioinfo.ird.fr\/wp-content\/uploads\/2021\/10\/i-tropTwt5.png","contentUrl":"https:\/\/bioinfo.ird.fr\/wp-content\/uploads\/2021\/10\/i-tropTwt5.png","width":1356,"height":1356,"caption":"i-Trop"},"image":{"@id":"https:\/\/bioinfo.ird.fr\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/ItropBioinfo"]}]}},"_links":{"self":[{"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/pages\/402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/comments?post=402"}],"version-history":[{"count":2,"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/pages\/402\/revisions"}],"predecessor-version":[{"id":735,"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/pages\/402\/revisions\/735"}],"up":[{"embeddable":true,"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/pages\/1325"}],"wp:attachment":[{"href":"https:\/\/bioinfo.ird.fr\/index.php\/wp-json\/wp\/v2\/media?parent=402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}