]> git.donarmstrong.com Git - samtools.git/blob - samtools.1
Release samtools-0.1.4
[samtools.git] / samtools.1
1 .TH samtools 1 "21 May 2009" "samtools-0.1.4" "Bioinformatics tools"
2 .SH NAME
3 .PP
4 samtools - Utilities for the Sequence Alignment/Map (SAM) format
5 .SH SYNOPSIS
6 .PP
7 samtools view -bt ref_list.txt -o aln.bam aln.sam.gz
8 .PP
9 samtools sort aln.bam aln.sorted
10 .PP
11 samtools index aln.sorted.bam
12 .PP
13 samtools view aln.sorted.bam chr2:20,100,000-20,200,000
14 .PP
15 samtools merge out.bam in1.bam in2.bam in3.bam
16 .PP
17 samtools faidx ref.fasta
18 .PP
19 samtools pileup -f ref.fasta aln.sorted.bam
20 .PP
21 samtools tview aln.sorted.bam ref.fasta
22
23 .SH DESCRIPTION
24 .PP
25 Samtools is a set of utilities that manipulate alignments in the BAM
26 format. It imports from and exports to the SAM (Sequence
27 Alignment/Map) format, does sorting, merging and indexing, and
28 allows to retrieve reads in any regions swiftly.
29
30 .SH COMMANDS AND OPTIONS
31 .TP 10
32 .B import
33 samtools import <in.ref_list> <in.sam> <out.bam>
34
35 Since 0.1.4, this command is an alias of:
36
37 samtools view -bt <in.ref_list> -o <out.bam> <in.sam>
38
39 .TP
40 .B sort
41 samtools sort [-n] [-m maxMem] <in.bam> <out.prefix>
42
43 Sort alignments by leftmost coordinates. File
44 .I <out.prefix>.bam
45 will be created. This command may also create temporary files
46 .I <out.prefix>.%d.bam
47 when the whole alignment cannot be fitted into memory (controlled by
48 option -m).
49
50 .B OPTIONS:
51 .RS
52 .TP 8
53 .B -n
54 Sort by read names rather than by chromosomal coordinates
55 .TP
56 .B -m INT
57 Approximately the maximum required memory. [500000000]
58 .RE
59
60 .TP
61 .B merge
62 samtools merge [-n] <out.bam> <in1.bam> <in2.bam> [...]
63
64 Merge multiple sorted alignments. The header of
65 .I <in1.bam>
66 will be copied to
67 .I <out.bam>
68 and the headers of other files will be ignored.
69
70 .B OPTIONS:
71 .RS
72 .TP 8
73 .B -n
74 The input alignments are sorted by read names rather than by chromosomal
75 coordinates
76 .RE
77
78 .TP
79 .B index
80 samtools index <aln.bam>
81
82 Index sorted alignment for fast random access. Index file
83 .I <aln.bam>.bai
84 will be created.
85
86 .TP
87 .B view
88 samtools view [-bhHS] [-t in.refList] [-o output] [-f reqFlag] [-F
89 skipFlag] [-q minMapQ] <in.bam> [region1 [...]]
90
91 Extract/print all or sub alignments in SAM or BAM format. If no region
92 is specified, all the alignments will be printed; otherwise only
93 alignments overlapping with the specified regions will be output. An
94 alignment may be given multiple times if it is overlapping several
95 regions. A region can be presented, for example, in the following
96 format: `chr2', `chr2:1000000' or `chr2:1,000,000-2,000,000'.
97
98 .B OPTIONS:
99 .RS
100 .TP 8
101 .B -b
102 Output in the BAM format.
103 .TP
104 .B -h
105 Include the header in the output.
106 .TP
107 .B -H
108 Output the header only.
109 .TP
110 .B -S
111 Input is in SAM. If @SQ header lines are absent, the
112 .B `-t'
113 option is required.
114 .TP
115 .B -t FILE
116 This file is TAB-delimited. Each line must contain the reference name
117 and the length of the reference, one line for each distinct reference;
118 additional fields are ignored. This file also defines the order of the
119 reference sequences in sorting. If you run `samtools faidx <ref.fa>',
120 the resultant index file
121 .I <ref.fa>.fai
122 can be used as this
123 .I <in.ref_list>
124 file.
125 .TP
126 .B -o FILE
127 Output file [stdout]
128 .TP
129 .B -f INT
130 Only output alignments with all bits in INT present in the FLAG
131 field. INT can be in hex in the format of /^0x[0-9A-F]+/ [0]
132 .TP
133 .B -F INT
134 Skip alignments with bits present in INT [0]
135 .TP
136 .B -q INT
137 Skip alignments with MAPQ smaller than INT [0]
138 .RE
139
140 .TP
141 .B faidx
142 samtools faidx <ref.fasta> [region1 [...]]
143
144 Index reference sequence in the FASTA format or extract subsequence from
145 indexed reference sequence. If no region is specified,
146 .B faidx
147 will index the file and create
148 .I <ref.fasta>.fai
149 on the disk. If regions are speficified, the subsequences will be
150 retrieved and printed to stdout in the FASTA format. The input file can
151 be compressed in the
152 .B RAZF
153 format.
154
155 .TP
156 .B pileup
157 samtools pileup [-f in.ref.fasta] [-t in.ref_list] [-l in.site_list]
158 [-iscg] [-T theta] [-N nHap] [-r pairDiffRate] <in.alignment>
159
160 Print the alignment in the pileup format. In the pileup format, each
161 line represents a genomic position, consisting of chromosome name,
162 coordinate, reference base, read bases, read qualities and alignment
163 mapping qualities. Information on match, mismatch, indel, strand,
164 mapping quality and start and end of a read are all encoded at the read
165 base column. At this column, a dot stands for a match to the reference
166 base on the forward strand, a comma for a match on the reverse strand,
167 `ACGTN' for a mismatch on the forward strand and `acgtn' for a mismatch
168 on the reverse strand. A pattern `\\+[0-9]+[ACGTNacgtn]+' indicates
169 there is an insertion between this reference position and the next
170 reference position. The length of the insertion is given by the integer
171 in the pattern, followed by the inserted sequence. Similarly, a pattern
172 `-[0-9]+[ACGTNacgtn]+' represents a deletion from the reference. The
173 deleted bases will be presented as `*' in the following lines. Also at
174 the read base column, a symbol `^' marks the start of a read segment
175 which is a contiguous subsequence on the read separated by `N/S/H' CIGAR
176 operations. The ASCII of the character following `^' minus 33 gives the
177 mapping quality. A symbol `$' marks the end of a read segment.
178
179 If option
180 .B -c
181 is applied, the consensus base, consensus quality, SNP quality and RMS
182 mapping quality of the reads covering the site will be inserted between
183 the `reference base' and the `read bases' columns. An indel occupies an
184 additional line. Each indel line consists of chromosome name,
185 coordinate, a star, the genotype, consensus quality, SNP quality, RMS
186 mapping quality, # covering reads, the first alllele, the second allele,
187 # reads supporting the first allele, # reads supporting the second
188 allele and # reads containing indels different from the top two alleles.
189
190 .B OPTIONS:
191 .RS
192
193 .TP 10
194 .B -s
195 Print the mapping quality as the last column. This option makes the
196 output easier to parse, although this format is not space efficient.
197
198 .TP
199 .B -i
200 Only output pileup lines containing indels.
201
202 .TP
203 .B -f FILE
204 The reference sequence in the FASTA format. Index file
205 .I FILE.fai
206 will be created if
207 absent.
208
209 .TP
210 .B -t FILE
211 List of reference names ane sequence lengths, in the format described
212 for the
213 .B import
214 command. If this option is present, samtools assumes the input
215 .I <in.alignment>
216 is in SAM format; otherwise it assumes in BAM format.
217
218 .TP
219 .B -l FILE
220 List of sites at which pileup is output. This file is space
221 delimited. The first two columns are required to be chromosome and
222 1-based coordinate. Additional columns are ignored. It is
223 recommended to use option
224 .B -s
225 together with
226 .B -l
227 as in the default format we may not know the mapping quality.
228
229 .TP
230 .B -c
231 Call the consensus sequence using MAQ consensus model. Options
232 .B -T,
233 .B -N
234 and
235 .B -r
236 are only effective when
237 .B -c
238 is in use.
239
240 .TP
241 .B -g
242 Generate genotype likelihood in the binary GLFv3 format. This option
243 suppresses -c, -i and -s.
244
245 .TP
246 .B -T FLOAT
247 The theta parameter (error dependency coefficient) in the maq consensus
248 calling model [0.85]
249
250 .TP
251 .B -N INT
252 Number of haplotypes in the sample (>=2) [2]
253
254 .TP
255 .B -r FLOAT
256 Expected fraction of differences between a pair of haplotypes [0.001]
257
258 .RE
259
260 .TP
261 .B tview
262 samtools tview <in.sorted.bam> [ref.fasta]
263
264 Text alignment viewer (based on the ncurses library). In the viewer,
265 press `?' for help and press `g' to check the alignment start from a
266 region in the format like `chr10:10,000,000'. Note that if the region
267 showed on the screen contains no mapped reads, a blank screen will be
268 seen. This is a known issue and will be improved later.
269
270 .RE
271
272 .TP
273 .B fixmate
274 samtools fixmate <in.nameSrt.bam> <out.bam>
275
276 Fill in mate coordinates, ISIZE and mate related flags from a
277 name-sorted alignment.
278
279 .TP
280 .B rmdup
281 samtools rmdup <input.srt.bam> <out.bam>
282
283 Remove potential PCR duplicates: if multiple read pairs have identical
284 external coordinates, only retain the pair with highest mapping quality.
285 This command
286 .B ONLY
287 works with FR orientation and requires ISIZE is correctly set.
288
289 .RE
290
291 .TP
292 .B rmdupse
293 samtools rmdupse <input.srt.bam> <out.bam>
294
295 Remove potential duplicates for single-ended reads. This command will
296 treat all reads as single-ended even if they are paired in fact.
297
298 .RE
299
300 .TP
301 .B fillmd
302 samtools fillmd [-e] <aln.bam> <ref.fasta>
303
304 Generate the MD tag. If the MD tag is already present, this command will
305 give a warning if the MD tag generated is different from the existing
306 tag.
307
308 .B OPTIONS:
309 .RS
310 .TP 8
311 .B -e
312 Convert a the read base to = if it is identical to the aligned reference
313 base. Indel caller does not support the = bases at the moment.
314
315 .RE
316
317
318 .SH SAM FORFAM
319
320 SAM is TAB-delimited. Apart from the header lines, which are started
321 with the `@' symbol, each alignment line consists of:
322
323 .TS
324 center box;
325 cb | cb | cb
326 n | l | l .
327 Col     Field   Description
328 _
329 1       QNAME   Query (pair) NAME
330 2       FLAG    bitwise FLAG
331 3       RNAME   Reference sequence NAME
332 4       POS     1-based leftmost POSition/coordinate of clipped sequence
333 5       MAPQ    MAPping Quality (Phred-scaled)
334 6       CIAGR   extended CIGAR string
335 7       MRNM    Mate Reference sequence NaMe (`=' if same as RNAME)
336 8       MPOS    1-based Mate POSistion
337 9       ISIZE   Inferred insert SIZE
338 10      SEQ     query SEQuence on the same strand as the reference
339 11      QUAL    query QUALity (ASCII-33 gives the Phred base quality)
340 12      OPT     variable OPTional fields in the format TAG:VTYPE:VALUE
341 .TE
342
343 .PP
344 Each bit in the FLAG field is defined as:
345
346 .TS
347 center box;
348 cb | cb
349 l | l .
350 Flag    Description
351 _
352 0x0001  the read is paired in sequencing
353 0x0002  the read is mapped in a proper pair
354 0x0004  the query sequence itself is unmapped
355 0x0008  the mate is unmapped
356 0x0010  strand of the query (1 for reverse)
357 0x0020  strand of the mate
358 0x0040  the read is the first read in a pair
359 0x0080  the read is the second read in a pair
360 0x0100  the alignment is not primary
361 0x0200  the read fails platform/vendor quality checks
362 0x0400  the read is either a PCR or an optical duplicate
363 .TE
364
365 .SH LIMITATIONS
366 .PP
367 .IP o 2
368 Unaligned words used in bam_import.c, bam_endian.h, bam.c and bam_aux.c.
369 .IP o 2
370 CIGAR operation P is not properly handled at the moment.
371 .IP o 2
372 The text viewer mysteriously crashes in a very rare case.
373
374 .SH AUTHOR
375 .PP
376 Heng Li from the Sanger Institute wrote the C version of samtools. Bob
377 Handsaker from the Broad Institute implemented the BGZF library and Jue
378 Ruan from Beijing Genomics Institute wrote the RAZF library. Various
379 people in the 1000Genomes Project contributed to the SAM format
380 specification.
381
382 .SH SEE ALSO
383 .PP
384 Samtools website: http://samtools.sourceforge.net