-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathperl_examples.html
More file actions
183 lines (166 loc) · 7.92 KB
/
perl_examples.html
File metadata and controls
183 lines (166 loc) · 7.92 KB
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>VCFtools</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/github-light.css">
<script src="javascripts/scale.fix.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper">
<header>
<h1 class="header">VCFtools</h1>
<p class="header">A set of tools written in Perl and C++ for working with VCF files.</p>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="examples.html">Documentation</a></li>
<li class="download"><a class="buttons" href="https://github.com/vcftools/vcftools/zipball/master">Download ZIP</a></li>
<li class="download"><a class="buttons" href="https://github.com/vcftools/vcftools/tarball/master">Download TAR</a></li>
<li><a class="buttons github" href="https://github.com/vcftools/vcftools">View On GitHub</a></li>
</ul>
</header>
<section>
<h2>The Perl modules examples</h2>
<p>This page provides usage examples for the Perl modules. Extended documentation <strong>for all of the options</strong> can be found in the <a href="perl_module.html">full documentation</a>.
<ul>
<li> <a href="#install">Installation</a>
<li> <a href="#annotate">Annotating</a>
<li> <a href="#compare">Comparing</a>
<li> <a href="#concat">Concatenating</a>
<li> <a href="#convert">Converting</a>
<li> <a href="#filter">Filtering</a>
<li> <a href="#isec">Intersections, complements</a>
<li> <a href="#merge">Merging</a>
<li> <a href="#query">Querying</a>
<li> <a href="#shuffle">Reordering columns</a>
<li> <a href="#stats">Stats</a>
<li> <a href="#subset">Stripping columns</a>
<li> <a href="#one-liners">Useful shell one-liners</a>
<li> <a href="#validator">Validating</a>
</ul>
<h2><a name="annotate" class="Q">Annotating</a></h2>
<p></p>
<p class="codebox">
# Add custom annotations <br>
cat in.vcf | vcf-annotate -a annotations.gz \ <br>
-d key=INFO,ID=ANN,Number=1,Type=Integer,Description='My custom annotation' \ <br>
-c CHROM,FROM,TO,INFO/ANN > out.vcf <br>
<br>
# Apply SnpCluster filter <br>
cat in.vcf | <a href="perl_module.html#vcf-annotate">vcf-annotate</a> --filter SnpCluster=3,10 > out.vcf <br>
</p>
<h2><a name="compare" class="Q">Comparing</a></h2>
<p></p>
<p class="codebox">
<a href="perl_module.html#vcf-compare">vcf-compare</a> A.vcf.gz B.vcf.gz C.vcf.gz <br>
<a href="htslib.html#check">vcf check</a> A.vcf.gz B.vcf.gz <br>
</p>
<h2><a name="concat" class="Q">Concatenating</a></h2>
<p></p>
<p class="codebox"><a href="perl_module.html#vcf-concat">vcf-concat</a> A.vcf.gz B.vcf.gz C.vcf.gz | bgzip -c > out.vcf.gz
</p>
<h2><a name="convert" class="Q">Converting</a></h2>
<p></p>
<p class="codebox">
# Convert between VCF versions <br>
zcat file.vcf.gz | <a href="perl_module.html#vcf-convert">vcf-convert</a> -r reference.fa | bgzip -c > out.vcf.gz <br>
<br>
# Convert from VCF format to tab-delimited text file <br>
zcat file.vcf.gz | <a href="perl_module.html#vcf-to-tab">vcf-to-tab</a> > out.tab <br>
</p>
<h2><a name="filter" class="Q">Filtering</a></h2>
<p></p>
<p class="codebox">
# Filter by QUAL and minimum depth <br>
<a href="perl_module.html#vcf-annotate">vcf-annotate</a> --filter Qual=10/MinDP=20
</p>
<h2><a name="isec" class="Q">Intersections, complements</a></h2>
<p></p>
<p class="codebox">
# Include positions which appear in at least two files <br>
<a href="perl_module.html#vcf-isec">vcf-isec</a> -o -n +2 A.vcf.gz B.vcf.gz C.vcf.gz | bgzip -c > out.vcf.gz <br>
<br>
# Exclude from A positions which appear in B and/or C <br>
<a href="perl_module.html#vcf-isec">vcf-isec</a> -c A.vcf.gz B.vcf.gz C.vcf.gz | bgzip -c > out.vcf.gz <br>
<br>
# Fast hstlib implementation
<a href="htslib.html#isec">vcf isec</a> -n =2 A.vcf.gz B.vcf.gz <br>
</p>
<h2><a name="merge" class="Q">Merging</a></h2>
<p></p>
<p class="codebox">
<a href="perl_module.html#vcf-merge">vcf-merge</a> A.vcf.gz B.vcf.gz | bgzip -c > C.vcf.gz <br>
<a href="htslib.html#merge">vcf merge</a> A.vcf.gz B.vcf.gz <br>
</p>
<h2><a name="isec" class="Q">Querying</a></h2>
<p></p>
<p class="codebox"><a href="perl_module.html#vcf-query">vcf-query</a> file.vcf.gz 1:10327-10330 -c NA0001
</p>
<h2><a name="shuffle" class="Q">Reordering columns</a></h2>
<p></p>
<p class="codebox"><a href="perl_module.html#vcf-shuffle-cols">vcf-shuffle-cols</a> -t template.vcf.gz file.vcf.gz > out.vcf
</p>
<h2><a name="stats" class="Q">Stats</a></h2>
<p></p>
<p class="codebox"><a href="perl_module.html#vcf-stats">vcf-stats</a> file.vcf.gz <br>
<a href="htslib.html#check">vcf check</a> file.vcf.gz > file.vchk && plot-vcfcheck file.vchk -p plot/<br>
</p>
<h2><a name="subset" class="Q">Stripping columns</a></h2>
<p></p>
<p class="codebox"><a href="perl_module.html#vcf-subset">vcf-subset</a> -c NA0001,NA0002 file.vcf.gz | bgzip -c > out.vcf.gz
</p>
<h2><a name="one-liners" class="Q">Useful shell one-liners</a></h2>
<p> This sections lists some usefull one line commands. Note that there are also dedicated convenience scripts
<a href="perl_module.html#vcf-sort">vcf-sort</a> and <a href="perl_module.html#vcf-concat">vcf-concat</a>
which do the same but also perform some basic sanity checks.
All examples in BASH.</p>
<p class="codebox">
# Replace VCF header. The file must be compressed by bgzip. <br>
tabix -r header.txt in.vcf.gz > out.vcf.gz <br>
<br>
# Sort VCF file keeping the header. The head command is for performance. <br>
(zcat file.vcf.gz | head -100 | grep ^#; <br>
zcat file.vcf.gz | grep -v ^# | sort -k1,1d -k2,2n;) \ <br>
| bgzip -c > out.vcf.gz <br>
<br>
# Merge (that is, concatenate) two VCF files into one, keeping the header <br>
# from first one only. <br>
(zcat A.vcf.gz | head -100 | grep ^#; \ <br>
zcat A.vcf.gz | grep -v ^#; \ <br>
zcat B.vcf.gz | grep -v ^#; ) \ <br>
| bgzip -c > out.vcf.gz
</p>
<h2><a name="validator" class="Q">VCF validation</a></h2>
<p> Both <span class="cmd">vcftools</span> and <span class="cmd">Vcf.pm</span> can be used for validation. The
first validates VCFv4.0, the latter is able to validate the older versions as well.
</p>
<p class="codebox">
perl -M<a href="perl_module.html#Vcf.pm">Vcf</a> -e validate example.vcf <br>
perl -I/path/to/the/module/ -M<a href="perl_module.html#Vcf.pm">Vcf</a> -e validate example.vcf <br>
<a href="perl_module.html#vcf-validator">vcf-validator</a> example.vcf
</p>
</section>
<footer>
<p><small>Hosted on <a href="https://pages.github.com">GitHub Pages</a></small></p>
<p>Copyright 2015 © VCFtools</p>
</footer>
</div>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-272183-4");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>