| 1 |
|
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 6 |
<meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| 7 |
<meta name="generator" content="Doxygen 1.10.0"/> |
| 8 |
<meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 9 |
<meta name="description" content="iVar is a computational package that contains functions broadly useful for viral amplicon-based sequencing. Additional tools for metagenomic sequencing are actively being incorporated into iVar. While each of these functions can be accomplished using existing tools, iVar contains an intersection of functionality from multiple tools that are required to call iSNVs and consensus sequences from viral sequencing data across multiple replicates. We implemented the following functions in iVar: (1) trimming of primers and low-quality bases, (2) consensus calling, (3) variant calling - both iSNVs and insertions/deletions, and (4) identifying mismatches to primer sequences and excluding the corresponding reads from alignment files."/> |
| 10 |
<meta name="keywords" content="variants calling,consensus,htslib,primal,primer,trimming,amplicon sequencing,ivar"/> |
| 11 |
<meta name="author" content="Andersen Lab, The Scripps Research Institute"/> |
| 12 |
<title>iVar: Manual</title> |
| 13 |
<link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 14 |
<script type="text/javascript" src="jquery.js"></script> |
| 15 |
<script type="text/javascript" src="dynsections.js"></script> |
| 16 |
<script type="text/javascript" src="cookie.js"></script> |
| 17 |
<link href="search/search.css" rel="stylesheet" type="text/css"/> |
| 18 |
<script type="text/javascript" src="search/searchdata.js"></script> |
| 19 |
<script type="text/javascript" src="search/search.js"></script> |
| 20 |
<link href="customdoxygen.css" rel="stylesheet" type="text/css" /> |
| 21 |
</head> |
| 22 |
<body> |
| 23 |
<div id="top"> |
| 24 |
<div id="titlearea"> |
| 25 |
<table cellspacing="0" cellpadding="0"> |
| 26 |
<tbody> |
| 27 |
<tr style="height: 56px;"> |
| 28 |
<td id="projectalign" style="padding-left: 0.5em;"> |
| 29 |
<div id="projectname">iVar |
| 30 |
</div> |
| 31 |
</td> |
| 32 |
</tr> |
| 33 |
</tbody> |
| 34 |
</table> |
| 35 |
</div> |
| 36 |
|
| 37 |
|
| 38 |
<script type="text/javascript"> |
| 39 |
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ |
| 40 |
var searchBox = new SearchBox("searchBox", "search/",'.html'); |
| 41 |
/* @license-end */ |
| 42 |
</script> |
| 43 |
<script type="text/javascript" src="menudata.js"></script> |
| 44 |
<script type="text/javascript" src="menu.js"></script> |
| 45 |
<script type="text/javascript"> |
| 46 |
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ |
| 47 |
$(function() { |
| 48 |
initMenu('',true,false,'search.php','Search'); |
| 49 |
$(function() { init_search(); }); |
| 50 |
}); |
| 51 |
/* @license-end */ |
| 52 |
</script> |
| 53 |
<div id="main-nav"></div> |
| 54 |
|
| 55 |
<div id="MSearchSelectWindow" |
| 56 |
onmouseover="return searchBox.OnSearchSelectShow()" |
| 57 |
onmouseout="return searchBox.OnSearchSelectHide()" |
| 58 |
onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 59 |
</div> |
| 60 |
|
| 61 |
|
| 62 |
<div id="MSearchResultsWindow"> |
| 63 |
<div id="MSearchResults"> |
| 64 |
<div class="SRPage"> |
| 65 |
<div id="SRIndex"> |
| 66 |
<div id="SRResults"></div> |
| 67 |
<div class="SRStatus" id="Loading">Loading...</div> |
| 68 |
<div class="SRStatus" id="Searching">Searching...</div> |
| 69 |
<div class="SRStatus" id="NoMatches">No Matches</div> |
| 70 |
</div> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
</div> |
| 74 |
|
| 75 |
</div> |
| 76 |
<div><div class="header"> |
| 77 |
<div class="headertitle"><div class="title">Manual</div></div> |
| 78 |
</div> |
| 79 |
<div class="contents"> |
| 80 |
<div class="toc"><h3>Table of Contents</h3> |
| 81 |
<ul><li class="level1"><a href="#autotoc_md14">Available Commands</a></li> |
| 82 |
<li class="level1"><a href="#autotoc_md15">Description of commands</a><ul><li class="level2"><a href="#autotoc_md16">Trim primer sequences with iVar</a></li> |
| 83 |
<li class="level2"><a href="#autotoc_md17">Call variants with iVar</a></li> |
| 84 |
<li class="level2"><a href="#autotoc_md18">Filter variants across replicates with iVar</a></li> |
| 85 |
<li class="level2"><a href="#autotoc_md19">Generate a consensus sequences from an aligned BAM file</a></li> |
| 86 |
<li class="level2"><a href="#autotoc_md20">Get primers with mismatches to the reference sequence</a></li> |
| 87 |
<li class="level2"><a href="#autotoc_md21">Remove reads associated with mismatched primer indices</a></li> |
| 88 |
<li class="level2"><a href="#autotoc_md22">(Experimental) trimadapter</a></li> |
| 89 |
</ul> |
| 90 |
</li> |
| 91 |
</ul> |
| 92 |
</div> |
| 93 |
<div class="textblock"><p><a class="anchor" id="md_docs_2_m_a_n_u_a_l"></a></p> |
| 94 |
<h1><a class="anchor" id="autotoc_md14"></a> |
| 95 |
Available Commands</h1> |
| 96 |
<table class="markdownTable"> |
| 97 |
<tr class="markdownTableHead"> |
| 98 |
<th class="markdownTableHeadLeft">Command </th><th class="markdownTableHeadLeft">Description </th></tr> |
| 99 |
<tr class="markdownTableRowOdd"> |
| 100 |
<td class="markdownTableBodyLeft">trim </td><td class="markdownTableBodyLeft">Trim reads in aligned BAM </td></tr> |
| 101 |
<tr class="markdownTableRowEven"> |
| 102 |
<td class="markdownTableBodyLeft">variants </td><td class="markdownTableBodyLeft">Call variants from aligned BAM file </td></tr> |
| 103 |
<tr class="markdownTableRowOdd"> |
| 104 |
<td class="markdownTableBodyLeft">filtervariants </td><td class="markdownTableBodyLeft">Filter variants across replicates or multiple samples aligned using the same reference </td></tr> |
| 105 |
<tr class="markdownTableRowEven"> |
| 106 |
<td class="markdownTableBodyLeft">consensus </td><td class="markdownTableBodyLeft">Call consensus from aligned BAM file </td></tr> |
| 107 |
<tr class="markdownTableRowOdd"> |
| 108 |
<td class="markdownTableBodyLeft">getmasked </td><td class="markdownTableBodyLeft">Detect primer mismatches and get primer indices for the amplicon to be masked </td></tr> |
| 109 |
<tr class="markdownTableRowEven"> |
| 110 |
<td class="markdownTableBodyLeft">removereads </td><td class="markdownTableBodyLeft">Remove reads from trimmed BAM file </td></tr> |
| 111 |
<tr class="markdownTableRowOdd"> |
| 112 |
<td class="markdownTableBodyLeft">version </td><td class="markdownTableBodyLeft">Show version information </td></tr> |
| 113 |
<tr class="markdownTableRowEven"> |
| 114 |
<td class="markdownTableBodyLeft">trimadapter </td><td class="markdownTableBodyLeft">(EXPERIMENTAL) Trim adapter sequences from reads </td></tr> |
| 115 |
</table> |
| 116 |
<p>To view detailed usage for each command type <code>ivar <command></code> Note : Commands maked (EXPERIMENTAL) are still under active development.</p> |
| 117 |
<h1><a class="anchor" id="autotoc_md15"></a> |
| 118 |
Description of commands</h1> |
| 119 |
<h2><a class="anchor" id="autotoc_md16"></a> |
| 120 |
Trim primer sequences with iVar</h2> |
| 121 |
<p>iVar uses primer positions supplied in a BED file to soft clip primer sequences from an aligned and sorted BAM file. Following this, the reads are trimmed based on a quality threshold(Default: 20). To do the quality trimming, iVar uses a sliding window approach(Default: 4). The windows slides from the 5' end to the 3' end and if at any point the average base quality in the window falls below the threshold, the remaining read is soft clipped. If after trimming, the length of the read is greater than the minimum length specified(Default: 30), the read is written to the new trimmed BAM file.</p> |
| 122 |
<p>Please note that the strand is taken into account while doing the trimming so forward primers are trimmed only from forward strand and reverse primers are trimmed from reverse strand.</p> |
| 123 |
<p>To sort and index an aligned BAM file (OPTIONAL, if index is not present iVar will create one), the following command can be used,</p> |
| 124 |
<div class="fragment"><div class="line"># Input file - test.bam</div> |
| 125 |
<div class="line">samtools sort -o test.sorted.bam test.bam && samtools index test.sorted.bam.</div> |
| 126 |
</div><p><b>Note</b>: All the trimming in iVar is done by soft-clipping reads in an aligned BAM file. This information is lost if reads are extracted in fastq or fasta format from the trimmed BAM file.</p> |
| 127 |
<p>Command: </p><div class="fragment"><div class="line">ivar trim</div> |
| 128 |
<div class="line"> </div> |
| 129 |
<div class="line">Usage: ivar trim -i [<input.bam>] -b <primers.bed> [-p <prefix>] [-m <min-length>] [-q <min-quality>] [-s <sliding-window-width>]</div> |
| 130 |
<div class="line"> </div> |
| 131 |
<div class="line">Input Options Description</div> |
| 132 |
<div class="line"> -i Sorted bam file, with aligned reads, to trim primers and quality. If not specified will read from standard in</div> |
| 133 |
<div class="line"> -b (Required) BED file with primer sequences and positions</div> |
| 134 |
<div class="line"> -f Primer pair information file containing left and right primer names for the same amplicon separated by a tab</div> |
| 135 |
<div class="line"> If provided, reads will be filtered based on their overlap with amplicons prior to trimming</div> |
| 136 |
<div class="line"> -m Minimum length of read to retain after trimming (Default: 50% the average length of the first 1000 reads)</div> |
| 137 |
<div class="line"> -q Minimum quality threshold for sliding window to pass (Default: 20)</div> |
| 138 |
<div class="line"> -s Width of sliding window (Default: 4)</div> |
| 139 |
<div class="line"> -e Include reads with no primers. By default, reads with no primers are excluded</div> |
| 140 |
<div class="line"> -k Keep reads to allow for reanalysis: keep reads which would be dropped by</div> |
| 141 |
<div class="line"> alignment length filter or primer requirements, but mark them QCFAIL</div> |
| 142 |
<div class="line"> </div> |
| 143 |
<div class="line">Output Options Description</div> |
| 144 |
<div class="line"> -p Prefix for the output BAM file. If none is specified the output will write to standard out.</div> |
| 145 |
</div><p>Example Usage: </p><div class="fragment"><div class="line">ivar trim -b test_primers.bed -p test.trimmed -i test.bam -q 15 -m 50 -s 4</div> |
| 146 |
<div class="line">samtools view -h test.bam | ivar trim -b test_primers.bed -p test.trimmed </div> |
| 147 |
</div><p>The command above will produce a trimmed BAM file test.trimmed.bam after trimming the aligned reads in test.bam using the primer positions specified in test_primers.bed and a minimum quality threshold of <b>15</b>, minimum read length of <b>50</b> and a sliding window of <b>4</b>.</p> |
| 148 |
<p>Example Usage: </p><div class="fragment"><div class="line">bwa mem -t 32 reference.fa 1.fq 2.fq | ivar trim -b test_primers.bed -x 3 -m 30 | samtools sort - | samtools mpileup -aa -A -Q 0 -d 0 - | ivar consensus -p test_consensus -m 10 -n N -t 0.5</div> |
| 149 |
</div><p>The command above will allow you to go from alignment to consensus sequence in a single command using the bwa aligner.</p> |
| 150 |
<p>Example BED file</p> |
| 151 |
<div class="fragment"><div class="line">Puerto 28 52 400_1_out_L 60 +</div> |
| 152 |
<div class="line">Puerto 482 504 400_1_out_R 60 -</div> |
| 153 |
<div class="line">Puerto 359 381 400_2_out_L 60 +</div> |
| 154 |
<div class="line">Puerto 796 818 400_2_out_R 60 -</div> |
| 155 |
<div class="line">Puerto 658 680 400_3_out_L* 60 +</div> |
| 156 |
<div class="line">Puerto 1054 1076 400_3_out_R* 60 -</div> |
| 157 |
<div class="line">.</div> |
| 158 |
<div class="line">.</div> |
| 159 |
<div class="line">.</div> |
| 160 |
<div class="line">.</div> |
| 161 |
</div><h2><a class="anchor" id="autotoc_md17"></a> |
| 162 |
Call variants with iVar</h2> |
| 163 |
<p>iVar uses the output of the <code>samtools mpileup</code> command to call variants - single nucleotide variants(SNVs) and indels. In order to call variants correctly, the reference file used for alignment must be passed to iVar using the <code>-r</code> flag. The output of <code>samtools pileup</code> is piped into <code>ivar variants</code> to generate a .tsv file with the variants. There are two parameters that can be set for variant calling using iVar - minimum quality(Default: 20) and minimum frequency(Default: 0.03). Minimum quality is the minimum quality for a base to be counted towards the ungapped depth to canculate iSNV frequency at a given position. For insertions, the quality metric is discarded and the mpileup depth is used directly. Minimum frequency is the minimum frequency required for a SNV or indel to be reported.</p> |
| 164 |
<h4>Amino acid translation of iSNVs</h4> |
| 165 |
<p>iVar can identify codons and translate variants into amino acids using a GFF file in the <a href="https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md">GFF3</a> format containing the required coding regions (CDS). In absence of a GFF file, iVar will not perform the translation and "NA" will be added to the output file in place of the reference and alternate codons and amino acids. The GFF file in the GFF3 format can be downloaded via ftp from NCBI RefSeq/Genbank. They are usually the files with the extension ".gff.gz". For example, the GFF file for Zaire Ebolavirus can be found <a href="ftp://ftp.ncbi.nlm.nih.gov/genomes/refseq/viral/Zaire_ebolavirus/all_assembly_versions/GCF_000848505.1_ViralProj14703">here</a>. More details on GFF3 files hosted by NCBI can be found in their ftp <a href="https://www.ncbi.nlm.nih.gov/genome/doc/ftpfaq/">FAQs</a>.</p> |
| 166 |
<h4>Account for RNA editing through polymerase slippage</h4> |
| 167 |
<p>Some RNA viruses such as Ebola virus, might have polymerase slippage causing the insertion of a couple of nucleotides. More details can be found <a href="https://viralzone.expasy.org/857?outline=all_by_protein">here</a>. iVar can account for this editing and identify the correct open reading frames. The user will have to specify two additional parameters, <b>EditPosition</b>: Position at which edit occurs and <b>EditSequence</b>: The sequence tht is inserted at the given positon, in the "attributes" column of the GFF file to account for this. A test example is given below,</p> |
| 168 |
<div class="fragment"><div class="line">test Genbank CDS 2 292 . + . ID=id-testedit1;Note=PinkFloyd;EditPosition=100;EditSequence=A</div> |
| 169 |
<div class="line">test Genbank CDS 2 292 . + . ID=id-testedit2;Note=AnotherBrickInTheWall;EditPosition=102;EditSequence=AA</div> |
| 170 |
</div><p>If a certain base is present in multiple CDSs, iVar will add a new row for each CDS frame and distinguish the rows by adding the ID (specified in attributes of GFF) of the GFF feature used for the translation. This is shown for position 42 in the example output below. There are two rows with two different GFF features: id-test3 and id-test4.</p> |
| 171 |
<p>Command: </p><div class="fragment"><div class="line">Usage: samtools mpileup -aa -A -d 0 -B -Q 0 --reference [<reference-fasta] <input.bam> | ivar variants -p <prefix> [-q <min-quality>] [-t <min-frequency-threshold>] [-m <minimum depth>] [-r <reference-fasta>] [-g GFF file]</div> |
| 172 |
<div class="line"> </div> |
| 173 |
<div class="line">Note : samtools mpileup output must be piped into ivar variants</div> |
| 174 |
<div class="line"> </div> |
| 175 |
<div class="line">Input Options Description</div> |
| 176 |
<div class="line"> -q Minimum quality score threshold to count base (Default: 20)</div> |
| 177 |
<div class="line"> -t Minimum frequency threshold(0 - 1) to call variants (Default: 0.03)</div> |
| 178 |
<div class="line"> -m Minimum read depth to call variants (Default: 0)</div> |
| 179 |
<div class="line"> -G Count gaps towards depth. By default, gaps are not counted </div> |
| 180 |
<div class="line"> -r Reference file used for alignment. This is used to translate the nucleotide sequences and identify intra host single nucleotide variants</div> |
| 181 |
<div class="line"> -g A GFF file in the GFF3 format can be supplied to specify coordinates of open reading frames (ORFs). In absence of GFF file, amino acid translation will not be done.</div> |
| 182 |
<div class="line"> </div> |
| 183 |
<div class="line">Output Options Description</div> |
| 184 |
<div class="line"> -p (Required) Prefix for the output tsv variant file</div> |
| 185 |
</div><p>Example Usage: </p><div class="fragment"><div class="line">samtools mpileup -aa -A -d 600000 -B -Q 0 test.trimmed.bam | ivar variants -p test -q 20 -t 0.03 -r test_reference.fa -g test.gff</div> |
| 186 |
</div><p>The command above will generate a test.tsv file.</p> |
| 187 |
<p>Example of output .tsv file.</p> |
| 188 |
<div class="fragment"><div class="line">REGION POS REF ALT REF_DP REF_RV REF_QUAL ALT_DP ALT_RV ALT_QUAL ALT_FREQ TOTAL_DP PVAL PASS GFF_FEATURE REF_CODON REF_AA ALT_CODON ALT_AA</div> |
| 189 |
<div class="line">test 42 G T 0 0 0 1 0 49 1 1 1 FALSE id-test3 AGG R ATG M</div> |
| 190 |
<div class="line">test 42 G T 0 0 0 1 0 49 1 1 1 FALSE id-test4 CAG Q CAT H</div> |
| 191 |
<div class="line">test 320 A T 1 1 35 1 1 46 0.5 2 0.666667 FALSE NA NA NA NA NA</div> |
| 192 |
<div class="line">test 365 A T 0 0 0 1 1 27 1 1 1 FALSE NA NA NA NA NA</div> |
| 193 |
</div><p>Description</p> |
| 194 |
<table class="markdownTable"> |
| 195 |
<tr class="markdownTableHead"> |
| 196 |
<th class="markdownTableHeadLeft">Field </th><th class="markdownTableHeadLeft">Description </th></tr> |
| 197 |
<tr class="markdownTableRowOdd"> |
| 198 |
<td class="markdownTableBodyLeft">REGION </td><td class="markdownTableBodyLeft">Region from BAM file </td></tr> |
| 199 |
<tr class="markdownTableRowEven"> |
| 200 |
<td class="markdownTableBodyLeft">POS </td><td class="markdownTableBodyLeft">Position on reference sequence </td></tr> |
| 201 |
<tr class="markdownTableRowOdd"> |
| 202 |
<td class="markdownTableBodyLeft">REF </td><td class="markdownTableBodyLeft">Reference base </td></tr> |
| 203 |
<tr class="markdownTableRowEven"> |
| 204 |
<td class="markdownTableBodyLeft">ALT </td><td class="markdownTableBodyLeft">Alternate Base </td></tr> |
| 205 |
<tr class="markdownTableRowOdd"> |
| 206 |
<td class="markdownTableBodyLeft">REF_DP </td><td class="markdownTableBodyLeft">Ungapped depth of reference base </td></tr> |
| 207 |
<tr class="markdownTableRowEven"> |
| 208 |
<td class="markdownTableBodyLeft">REF_RV </td><td class="markdownTableBodyLeft">Ungapped depth of reference base on reverse reads </td></tr> |
| 209 |
<tr class="markdownTableRowOdd"> |
| 210 |
<td class="markdownTableBodyLeft">REF_QUAL </td><td class="markdownTableBodyLeft">Mean quality of reference base </td></tr> |
| 211 |
<tr class="markdownTableRowEven"> |
| 212 |
<td class="markdownTableBodyLeft">ALT_DP </td><td class="markdownTableBodyLeft">Ungapped depth of alternate base. </td></tr> |
| 213 |
<tr class="markdownTableRowOdd"> |
| 214 |
<td class="markdownTableBodyLeft">ALT_RV </td><td class="markdownTableBodyLeft">Ungapped deapth of alternate base on reverse reads </td></tr> |
| 215 |
<tr class="markdownTableRowEven"> |
| 216 |
<td class="markdownTableBodyLeft">ALT_QUAL </td><td class="markdownTableBodyLeft">Mean quality of alternate base </td></tr> |
| 217 |
<tr class="markdownTableRowOdd"> |
| 218 |
<td class="markdownTableBodyLeft">ALT_FREQ </td><td class="markdownTableBodyLeft">Frequency of alternate base </td></tr> |
| 219 |
<tr class="markdownTableRowEven"> |
| 220 |
<td class="markdownTableBodyLeft">TOTAL_DP </td><td class="markdownTableBodyLeft">Total depth at position </td></tr> |
| 221 |
<tr class="markdownTableRowOdd"> |
| 222 |
<td class="markdownTableBodyLeft">PVAL </td><td class="markdownTableBodyLeft">p-value of fisher's exact test </td></tr> |
| 223 |
<tr class="markdownTableRowEven"> |
| 224 |
<td class="markdownTableBodyLeft">PASS </td><td class="markdownTableBodyLeft">Result of p-value <= 0.05 </td></tr> |
| 225 |
<tr class="markdownTableRowOdd"> |
| 226 |
<td class="markdownTableBodyLeft">GFF_FEATURE </td><td class="markdownTableBodyLeft">ID of the GFF feature used for the translation </td></tr> |
| 227 |
<tr class="markdownTableRowEven"> |
| 228 |
<td class="markdownTableBodyLeft">REF_CODON </td><td class="markdownTableBodyLeft">Codong using the reference base </td></tr> |
| 229 |
<tr class="markdownTableRowOdd"> |
| 230 |
<td class="markdownTableBodyLeft">REF_AA </td><td class="markdownTableBodyLeft">Amino acid translated from reference codon </td></tr> |
| 231 |
<tr class="markdownTableRowEven"> |
| 232 |
<td class="markdownTableBodyLeft">ALT_CODON </td><td class="markdownTableBodyLeft">Codon using the alternate base </td></tr> |
| 233 |
<tr class="markdownTableRowOdd"> |
| 234 |
<td class="markdownTableBodyLeft">ALT_AA </td><td class="markdownTableBodyLeft">Amino acid translated from the alternate codon </td></tr> |
| 235 |
</table> |
| 236 |
<p><b>Note</b>: Please use the -B options with <code>samtools mpileup</code> to call variants and generate consensus. When a reference sequence is supplied, the quality of the reference base is reduced to 0 (ASCII: !) in the mpileup output. Disabling BAQ with -B seems to fix this. This was tested in samtools 1.7 and 1.8.</p> |
| 237 |
<h2><a class="anchor" id="autotoc_md18"></a> |
| 238 |
Filter variants across replicates with iVar</h2> |
| 239 |
<p>iVar can be used to get an intersection of variants(in .tsv files) called from any number of replicates or from different samples using the same reference sequence. This intersection will filter out any iSNVs that do not occur in a minimum fraction of the files supplied. This parameter can be changed using the <code>-t</code> flag which range from 0 to 1 (default). Fields that are different across replicates(fields apart from REGION, POS, REF, ALT, REF_CODON, REF_AA, ALT_CODON, ALT_AA) will have the filename added as a suffix. If there are a large number of files to be filtered, the <code>-f</code> flag can be used to supply a text file with one sample/replicate variant .tsv file per line.</p> |
| 240 |
<p>Command: </p><div class="fragment"><div class="line">Usage: ivar filtervariants -p <prefix> replicate-one.tsv replicate-two.tsv ... OR ivar filtervariants -p <prefix> -f <text file with one variant file per line> </div> |
| 241 |
<div class="line">Input: Variant tsv files for each replicate/sample</div> |
| 242 |
<div class="line"> </div> |
| 243 |
<div class="line">Input Options Description</div> |
| 244 |
<div class="line"> -t Minimum fration of files required to contain the same variant. Specify value within [0,1]. (Default: 1)</div> |
| 245 |
<div class="line"> -f A text file with one variant file per line.</div> |
| 246 |
<div class="line"> </div> |
| 247 |
<div class="line">Output Options Description</div> |
| 248 |
<div class="line"> -p (Required) Prefix for the output filtered tsv file</div> |
| 249 |
</div><p>Example Usage: The command below only retains those variants that are found in atleast 50% of the fiels supplied </p><div class="fragment"><div class="line">ivar filtervariants -t 0.5 -p test.filtered test.1.tsv test.2.tsv test.3.tsv</div> |
| 250 |
</div><p>The three replicates can also be supplied using a text file as shown below</p> |
| 251 |
<div class="fragment"><div class="line">ivar filtervariants -t 0.5 -p test.filtered -f filter_files.txt</div> |
| 252 |
</div><p>filter_files.txt </p><div class="fragment"><div class="line">./path/to/test.1.tsv</div> |
| 253 |
<div class="line">./path/to/test.2.tsv</div> |
| 254 |
<div class="line">./path/to/test.3.tsv</div> |
| 255 |
</div><p>The command above will prodoce an output .tsv file test.filtered.tsv.</p> |
| 256 |
<p>Example output of filtered .tsv file from three files test_rep1.tsv and test_rep2.tsv</p> |
| 257 |
<div class="fragment"><div class="line">REGION POS REF ALT GFF_FEATURE REF_CODON REF_AA ALT_CODON ALT_AA REF_DP_test.1.tsv REF_RV_test.1.tsv REF_QUAL_test.1.tsv ALT_DP_test.1.tsv ALT_RV_test.1.tsv ALT_QUAL_test.1.tsv ALT_FREQ_test.1.tsv TOTAL_DP_test.1.tsv PVAL_test.1.tsv PASS_test.1.tsv REF_DP_test.2.tsv REF_RV_test.2.tsv REF_QUAL_test.2.tsv ALT_DP_test.2.tsv ALT_RV_test.2.tsv ALT_QUAL_test.2.tsv ALT_FREQ_test.2.tsv TOTAL_DP_test.2.tsv PVAL_test.2.tsv PASS_test.2.tsv REF_DP_test.3.tsv REF_RV_test.3.tsv REF_QUAL_test.3.tsv ALT_DP_test.3.tsv ALT_RV_test.3.tsv ALT_QUAL_test.3.tsv ALT_FREQ_test.3.tsv TOTAL_DP_test.3.tsv PVAL_test.3.tsv PASS_test.3.tsv </div> |
| 258 |
<div class="line">test 139 T A id-test3 GCT A GCA A 1 0 32 1 0 55 0.5 2 0.666667 FALSE 1 0 32 1 0 55 0.5 2 0.666667 FALSE NA NA NA NA NA NA NA NA NA NA</div> |
| 259 |
<div class="line">test 320 A T NA NA NA NA NA 1 1 35 1 1 46 0.5 2 0.666667 FALSE NA NA NA NA NA NA NA NA NA NA 1 1 35 1 1 46 0.5 2 0.666667 FALSE</div> |
| 260 |
<div class="line">test 365 A T NA NA NA NA NA 0 0 0 1 1 27 1 1 1 FALSE 0 0 0 1 1 27 1 1 1 FALSE 0 0 0 1 1 27 1 1 1 FALSE</div> |
| 261 |
<div class="line">test 42 G T id-test4 CAG Q CAT H 0 0 0 1 0 49 1 1 1 FALSE 0 0 0 1 0 49 1 1 1 FALSE NA NA NA NA NA NA NA NA NA NA</div> |
| 262 |
<div class="line">test 42 G T id-testedit1 AGG R ATG M 0 0 0 1 0 49 1 1 1 FALSE 0 0 0 1 0 49 1 1 1 FALSE 0 0 0 1 0 49 1 1 1 FALSE</div> |
| 263 |
<div class="line">test 69 T G id-testedit2 TTG L TGG W 1 0 57 1 0 53 0.5 2 0.666667 FALSE 1 0 57 1 0 53 0.5 2 0.666667 FALSE 1 0 57 1 0 53 0.5 2 0.666667 FALSE</div> |
| 264 |
</div><p>Description of fields</p> |
| 265 |
<table class="markdownTable"> |
| 266 |
<tr class="markdownTableHead"> |
| 267 |
<th class="markdownTableHeadLeft">No </th><th class="markdownTableHeadLeft">Field </th><th class="markdownTableHeadNone">Description </th></tr> |
| 268 |
<tr class="markdownTableRowOdd"> |
| 269 |
<td class="markdownTableBodyLeft">1 </td><td class="markdownTableBodyLeft">REGION </td><td class="markdownTableBodyNone">Common region across all replicate variant tsv files </td></tr> |
| 270 |
<tr class="markdownTableRowEven"> |
| 271 |
<td class="markdownTableBodyLeft">2 </td><td class="markdownTableBodyLeft">POS </td><td class="markdownTableBodyNone">Common position across all variant tsv files </td></tr> |
| 272 |
<tr class="markdownTableRowOdd"> |
| 273 |
<td class="markdownTableBodyLeft">3 </td><td class="markdownTableBodyLeft">REF </td><td class="markdownTableBodyNone">Common reference base across all variant tsv files </td></tr> |
| 274 |
<tr class="markdownTableRowEven"> |
| 275 |
<td class="markdownTableBodyLeft">4 </td><td class="markdownTableBodyLeft">ALT </td><td class="markdownTableBodyNone">Common alternate base across all variant tsv files </td></tr> |
| 276 |
<tr class="markdownTableRowOdd"> |
| 277 |
<td class="markdownTableBodyLeft">5 </td><td class="markdownTableBodyLeft">GFF_FEATURE </td><td class="markdownTableBodyNone">GFF feature used for the translation </td></tr> |
| 278 |
<tr class="markdownTableRowEven"> |
| 279 |
<td class="markdownTableBodyLeft">6 </td><td class="markdownTableBodyLeft">REF_CODON </td><td class="markdownTableBodyNone">The codon using the reference base </td></tr> |
| 280 |
<tr class="markdownTableRowOdd"> |
| 281 |
<td class="markdownTableBodyLeft">7 </td><td class="markdownTableBodyLeft">REF_AA </td><td class="markdownTableBodyNone">Reference codon translated into amino acid </td></tr> |
| 282 |
<tr class="markdownTableRowEven"> |
| 283 |
<td class="markdownTableBodyLeft">8 </td><td class="markdownTableBodyLeft">ALT_CODON </td><td class="markdownTableBodyNone">Codon using the alternate base </td></tr> |
| 284 |
<tr class="markdownTableRowOdd"> |
| 285 |
<td class="markdownTableBodyLeft">9 </td><td class="markdownTableBodyLeft">ALT_AA </td><td class="markdownTableBodyNone">Alternate codon translated into amino acid </td></tr> |
| 286 |
<tr class="markdownTableRowEven"> |
| 287 |
<td class="markdownTableBodyLeft">10 </td><td class="markdownTableBodyLeft">REF_DP_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Depth of reference base in replicate 1 </td></tr> |
| 288 |
<tr class="markdownTableRowOdd"> |
| 289 |
<td class="markdownTableBodyLeft">11 </td><td class="markdownTableBodyLeft">REF_RV_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Depth of reference base on reverse reads in replicate 1 </td></tr> |
| 290 |
<tr class="markdownTableRowEven"> |
| 291 |
<td class="markdownTableBodyLeft">12 </td><td class="markdownTableBodyLeft">REF_QUAL_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Mean quality of reference base in replicate 1 </td></tr> |
| 292 |
<tr class="markdownTableRowOdd"> |
| 293 |
<td class="markdownTableBodyLeft">13 </td><td class="markdownTableBodyLeft">ALT_DP_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Depth of alternate base in replicate 1 </td></tr> |
| 294 |
<tr class="markdownTableRowEven"> |
| 295 |
<td class="markdownTableBodyLeft">14 </td><td class="markdownTableBodyLeft">ALT_RV_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Deapth of alternate base on reverse reads in replicate 1 </td></tr> |
| 296 |
<tr class="markdownTableRowOdd"> |
| 297 |
<td class="markdownTableBodyLeft">15 </td><td class="markdownTableBodyLeft">ALT_QUAL_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Mean quality of alternate base in replicate 1 </td></tr> |
| 298 |
<tr class="markdownTableRowEven"> |
| 299 |
<td class="markdownTableBodyLeft">16 </td><td class="markdownTableBodyLeft">ALT_FREQ_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Frequency of alternate base in replicate 1 </td></tr> |
| 300 |
<tr class="markdownTableRowOdd"> |
| 301 |
<td class="markdownTableBodyLeft">17 </td><td class="markdownTableBodyLeft">TOTAL_DP_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Total depth at position in replicate 1 </td></tr> |
| 302 |
<tr class="markdownTableRowEven"> |
| 303 |
<td class="markdownTableBodyLeft">18 </td><td class="markdownTableBodyLeft">PVAL_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">p-value of fisher's exact test in replicate 1 </td></tr> |
| 304 |
<tr class="markdownTableRowOdd"> |
| 305 |
<td class="markdownTableBodyLeft">19 </td><td class="markdownTableBodyLeft">PASS_<rep1-tsv-file-name> </td><td class="markdownTableBodyNone">Result of p-value <= 0.05 in replicate 1 </td></tr> |
| 306 |
<tr class="markdownTableRowEven"> |
| 307 |
<td class="markdownTableBodyLeft">20 </td><td class="markdownTableBodyLeft">Continue rows 10 - 19 for every replicate provided </td><td class="markdownTableBodyNone"></td></tr> |
| 308 |
</table> |
| 309 |
<h2><a class="anchor" id="autotoc_md19"></a> |
| 310 |
Generate a consensus sequences from an aligned BAM file</h2> |
| 311 |
<p>To generate a consensus sequence iVar uses the output of <code>samtools mpileup</code> command. The mpileup output must be piped into <code>ivar consensus</code>. There are five parameters that can be set - minimum quality(Default: 20), minimum frequency threshold(Default: 0), minimum depth to call a consensus(Default: 10), a flag to exclude nucleotides from regions with depth less than the minimum depth and a character to call in regions with coverage lower than the speicifed minimum depth(Default: 'N'). Minimum quality is the minimum quality of a base to be considered in calculations of variant frequencies at a given position. Minimum frequency threshold is the minimum frequency that a base must match to be called as the consensus base at a position. If one base is not enough to match a given frequency, then an ambigious nucleotide is called at that position. Minimum depth is the minimum required depth to call a consensus. If '-k' flag is set then these regions are not included in the consensus sequence. If '-k' is not set then by default, a 'N' is called in these regions. You can also specfy which character you want to add to the consensus to cover regions with depth less than the minimum depth. This can be done using -n option. It takes one of two values: '-' or 'N'.</p> |
| 312 |
<p>As an example, consider a position with 6As, 3Ts and 1C. The table below shows the consensus nucleotide called at different frequencies.</p> |
| 313 |
<table class="markdownTable"> |
| 314 |
<tr class="markdownTableHead"> |
| 315 |
<th class="markdownTableHeadLeft">Minimum frequency threshold </th><th class="markdownTableHeadNone">Consensus </th></tr> |
| 316 |
<tr class="markdownTableRowOdd"> |
| 317 |
<td class="markdownTableBodyLeft">0 </td><td class="markdownTableBodyNone">A </td></tr> |
| 318 |
<tr class="markdownTableRowEven"> |
| 319 |
<td class="markdownTableBodyLeft">0.5 </td><td class="markdownTableBodyNone">A </td></tr> |
| 320 |
<tr class="markdownTableRowOdd"> |
| 321 |
<td class="markdownTableBodyLeft">0.6 </td><td class="markdownTableBodyNone">A </td></tr> |
| 322 |
<tr class="markdownTableRowEven"> |
| 323 |
<td class="markdownTableBodyLeft">0.7 </td><td class="markdownTableBodyNone">W(A or T) </td></tr> |
| 324 |
<tr class="markdownTableRowOdd"> |
| 325 |
<td class="markdownTableBodyLeft">0.9 </td><td class="markdownTableBodyNone">W (A or T) </td></tr> |
| 326 |
<tr class="markdownTableRowEven"> |
| 327 |
<td class="markdownTableBodyLeft">1 </td><td class="markdownTableBodyNone">H (A or T or C) </td></tr> |
| 328 |
</table> |
| 329 |
<p>If there are two nucleotides at the same frequency, both nucleotides are used to call an ambigious base as the consensus. As an example, consider a position wiht 6 Ts, 2As and 2 Gs. The table below shows the consensus nucleotide called at different frequencies.</p> |
| 330 |
<table class="markdownTable"> |
| 331 |
<tr class="markdownTableHead"> |
| 332 |
<th class="markdownTableHeadLeft">Minimum frequency threshold </th><th class="markdownTableHeadNone">Consensus </th></tr> |
| 333 |
<tr class="markdownTableRowOdd"> |
| 334 |
<td class="markdownTableBodyLeft">0 </td><td class="markdownTableBodyNone">T </td></tr> |
| 335 |
<tr class="markdownTableRowEven"> |
| 336 |
<td class="markdownTableBodyLeft">0.5 </td><td class="markdownTableBodyNone">T </td></tr> |
| 337 |
<tr class="markdownTableRowOdd"> |
| 338 |
<td class="markdownTableBodyLeft">0.6 </td><td class="markdownTableBodyNone">T </td></tr> |
| 339 |
<tr class="markdownTableRowEven"> |
| 340 |
<td class="markdownTableBodyLeft">0.7 </td><td class="markdownTableBodyNone">D(A or T or G) </td></tr> |
| 341 |
<tr class="markdownTableRowOdd"> |
| 342 |
<td class="markdownTableBodyLeft">0.9 </td><td class="markdownTableBodyNone">D(A or T or G) </td></tr> |
| 343 |
<tr class="markdownTableRowEven"> |
| 344 |
<td class="markdownTableBodyLeft">1 </td><td class="markdownTableBodyNone">D(A or T or G) </td></tr> |
| 345 |
</table> |
| 346 |
<p>The output of the command is a fasta file with the consensus sequence and a .txt file with the average quality of every base used to generate the consensus at each position. <em>For insertions, the quality is set to be the minimum quality threshold since mpileup doesn't give the quality of bases in insertions.</em></p> |
| 347 |
<p>Command:</p> |
| 348 |
<div class="fragment"><div class="line">ivar consensus</div> |
| 349 |
<div class="line"> </div> |
| 350 |
<div class="line">Usage: samtools mpileup -aa -A -d 0 -Q 0 <input.bam> | ivar consensus -p <prefix> </div> |
| 351 |
<div class="line"> </div> |
| 352 |
<div class="line">Note : samtools mpileup output must be piped into ivar consensus</div> |
| 353 |
<div class="line"> </div> |
| 354 |
<div class="line">Input Options Description</div> |
| 355 |
<div class="line"> -q Minimum quality score threshold to count base (Default: 20)</div> |
| 356 |
<div class="line"> -t Minimum frequency threshold(0 - 1) to call consensus. (Default: 0)</div> |
| 357 |
<div class="line"> -c Minimum insertion frequency threshold(0 - 1) to call consensus. (Default: 0.8)</div> |
| 358 |
<div class="line"> Frequently used thresholds | Description</div> |
| 359 |
<div class="line"> ---------------------------|------------</div> |
| 360 |
<div class="line"> 0 | Majority or most common base</div> |
| 361 |
<div class="line"> 0.2 | Bases that make up atleast 20% of the depth at a position</div> |
| 362 |
<div class="line"> 0.5 | Strict or bases that make up atleast 50% of the depth at a position</div> |
| 363 |
<div class="line"> 0.9 | Strict or bases that make up atleast 90% of the depth at a position</div> |
| 364 |
<div class="line"> 1 | Identical or bases that make up 100% of the depth at a position. Will have highest ambiguities</div> |
| 365 |
<div class="line"> -m Minimum depth to call consensus(Default: 10)</div> |
| 366 |
<div class="line"> -k If '-k' flag is added, regions with depth less than minimum depth will not be added to the consensus sequence. Using '-k' will override any option specified using -n </div> |
| 367 |
<div class="line"> -n (N/-) Character to print in regions with less than minimum coverage(Default: N)</div> |
| 368 |
<div class="line"> </div> |
| 369 |
<div class="line">Output Options Description</div> |
| 370 |
<div class="line"> -p (Required) Prefix for the output fasta file and quality file</div> |
| 371 |
</div><p>Example Usage: </p><div class="fragment"><div class="line">samtools mpileup -d 1000 -A -Q 0 test.bam | ivar consensus -p test -q 20 -t 0</div> |
| 372 |
</div><p>The command above will produce a test.fa fasta file with the consensus sequence and a test.qual.txt with the average quality of each base in the consensus sequence.</p> |
| 373 |
<h2><a class="anchor" id="autotoc_md20"></a> |
| 374 |
Get primers with mismatches to the reference sequence</h2> |
| 375 |
<p>iVar uses a .tsv file with variants to get the zero based indices(based on the BED file) of mismatched primers. This command requires another .tsv file with each line containing the left and right primer names separated by a tab. This is used to get both the primers for an amplicon with a single mismatched primer. The output is a text file with the zero based primer indices delimited by a space. The output is written to a a text file using the prefix provided.</p> |
| 376 |
<p>Command: </p><div class="fragment"><div class="line">ivar getmasked</div> |
| 377 |
<div class="line">Usage: ivar getmasked -i <input-filtered.tsv> -b <primers.bed> -f <primer_pairs.tsv> -p <prefix></div> |
| 378 |
<div class="line">Note: This step is used only for amplicon-based sequencing.</div> |
| 379 |
<div class="line"> </div> |
| 380 |
<div class="line">Input Options Description</div> |
| 381 |
<div class="line"> -i (Required) Input filtered variants tsv generated from 'ivar filtervariants'</div> |
| 382 |
<div class="line"> -b (Required) BED file with primer sequences and positions</div> |
| 383 |
<div class="line"> -f (Required) Primer pair information file containing left and right primer names for the same amplicon separated by a tab</div> |
| 384 |
<div class="line">Output Options Description</div> |
| 385 |
<div class="line"> -p (Required) Prefix for the output text file</div> |
| 386 |
</div><p>Example BED file</p> |
| 387 |
<div class="fragment"><div class="line">Puerto 28 52 400_1_out_L 60 +</div> |
| 388 |
<div class="line">Puerto 482 504 400_1_out_R 60 -</div> |
| 389 |
<div class="line">Puerto 359 381 400_2_out_L 60 +</div> |
| 390 |
<div class="line">Puerto 796 818 400_2_out_R 60 -</div> |
| 391 |
<div class="line">Puerto 658 680 400_3_out_L* 60 +</div> |
| 392 |
<div class="line">Puerto 1054 1076 400_3_out_R* 60 -</div> |
| 393 |
<div class="line">.</div> |
| 394 |
<div class="line">.</div> |
| 395 |
<div class="line">.</div> |
| 396 |
<div class="line">.</div> |
| 397 |
</div><p>Example primer pair information file </p><div class="fragment"><div class="line">400_1_out_L 400_1_out_R</div> |
| 398 |
<div class="line">400_2_out_L 400_2_out_R</div> |
| 399 |
<div class="line">400_3_out_L 400_3_out_R</div> |
| 400 |
<div class="line">.</div> |
| 401 |
<div class="line">.</div> |
| 402 |
<div class="line">.</div> |
| 403 |
<div class="line">.</div> |
| 404 |
</div><p>Example Usage: </p><div class="fragment"><div class="line">ivar getmasked -i test.filtered.tsv -b primers.bed -f pair_information.tsv -p test.masked.txt</div> |
| 405 |
</div><p>The command above produces an output file - test.masked.txt.</p> |
| 406 |
<p>Example Output:</p> |
| 407 |
<div class="fragment"><div class="line">1 2 7 8</div> |
| 408 |
</div><h2><a class="anchor" id="autotoc_md21"></a> |
| 409 |
Remove reads associated with mismatched primer indices</h2> |
| 410 |
<p>This command accepts an aligned and sorted BAM file trimmed using <code>ivar trim</code> and removes the reads corresponding to the supplied primer indices, which is the output of <code>ivar getmasked</code> command. Under the hood, <code>ivar trim</code> adds the zero based primer index(based on the BED file) to the BAM auxillary data for every read. Hence, ivar removereads will only work on BAM files that have been trimmed using <code>ivar trim</code>.</p> |
| 411 |
<p>Command: </p><div class="fragment"><div class="line">ivar removereads</div> |
| 412 |
<div class="line"> </div> |
| 413 |
<div class="line">Usage: ivar removereads -i <input.trimmed.bam> -p <prefix> -t <text-file-with-primer-indices></div> |
| 414 |
<div class="line">Note: This step is used only for amplicon-based sequencing.</div> |
| 415 |
<div class="line"> </div> |
| 416 |
<div class="line">Input Options Description</div> |
| 417 |
<div class="line"> -i (Required) Input BAM file trimmed with ivar trim. Must be sorted and indexed, which can be done using sort_index_bam.sh</div> |
| 418 |
<div class="line"> -t (Required) Text file with primer indices separated by spaces. This is the output of getmasked command.</div> |
| 419 |
<div class="line"> </div> |
| 420 |
<div class="line">Output Options Description</div> |
| 421 |
<div class="line"> -p (Required) Prefix for the output filtered BAM file</div> |
| 422 |
</div><p>Example Usage: </p><div class="fragment"><div class="line">ivar trim -i test.bam -p test.trimmed</div> |
| 423 |
<div class="line">ivar removereads -i test.trimmed.bam -p test.trimmed.masked.bam -t test.masked.txt</div> |
| 424 |
</div><p>The <code>ivar trim</code> command above trims test.bam and produced test.trimmed.bam with the primer indice data added. The <code>ivar removereads</code> command produces an output file - test.trimmed.masked.bam after removing all the reads corresponding to primer indices - 1,2,7 and 8.</p> |
| 425 |
<h2><a class="anchor" id="autotoc_md22"></a> |
| 426 |
(Experimental) trimadapter</h2> |
| 427 |
<p><b>Note: This feature is under active development and not completely validated yet.</b></p> |
| 428 |
<p>trimadapter in iVar can be used to trim adapter sequences from fastq files using a supplied fasta file. </p> |
| 429 |
</div></div> |
| 430 |
</div> |
| 431 |
|
| 432 |
|
| 433 |
<hr class="footer"/><address class="footer"><small> |
| 434 |
Generated by  <a href="http://www.doxygen.org/index.html"> |
| 435 |
<img class="footer" src="doxygen.png" alt="doxygen"/> |
| 436 |
</a> 1.10.0 |
| 437 |
</small></address> |
| 438 |
</body> |
| 439 |
</html> |