File: samtools-markdup.1

package info (click to toggle)
samtools 1.21-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 21,804 kB
  • sloc: ansic: 33,931; perl: 7,702; sh: 452; makefile: 298; java: 158
file content (305 lines) | stat: -rw-r--r-- 9,725 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
'\" t
.TH samtools-markdup 1 "12 September 2024" "samtools-1.21" "Bioinformatics tools"
.SH NAME
samtools markdup \- mark duplicate alignments in a coordinate sorted file
.\"
.\" Copyright (C) 2008-2011, 2013-2024 Genome Research Ltd.
.\" Portions copyright (C) 2010, 2011 Broad Institute.
.\"
.\" Author: Heng Li <lh3@sanger.ac.uk>
.\" Author: Joshua C. Randall <jcrandall@alum.mit.edu>
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
.\" copy of this software and associated documentation files (the "Software"),
.\" to deal in the Software without restriction, including without limitation
.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
.\" and/or sell copies of the Software, and to permit persons to whom the
.\" Software is furnished to do so, subject to the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be included in
.\" all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
.\" THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
.\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
.\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
.\" DEALINGS IN THE SOFTWARE.
.
.\" For code blocks and examples (cf groff's Ultrix-specific man macros)
.de EX

.  in +\\$1
.  nf
.  ft CR
..
.de EE
.  ft
.  fi
.  in

..
.
.SH SYNOPSIS
.PP
samtools markdup
.RB [ -l
.IR length ]
.RB [ -r ]
.RB [ -T ]
.RB [ -S ]
.RB [ -s ]
.RB [ -f
.IR file ]
.RB [ --json ]
.RB [ -d
.IR distance ]
.RB [ -c ]
.RB [ -t ]
.RB [ ---duplicate-count ]
.RB [ -m ]
.RB [ --mode ]
.RB [ --include-fails ]
.RB [ --no-PG ]
.RB [ -u ]
.RB [ --no-multi-dup ]
.RB [ --read-coords ]
.RB [ --coords-order ]
.RB [ --barcode-tag ]
.RB [ --barcode-name ]
.RB [ --barcode-rgx ]
.RB [ --use-read-groups ]
.I in.algsort.bam out.bam

.SH DESCRIPTION
.PP
Mark duplicate alignments from a coordinate sorted file that
has been run through \fBsamtools fixmate\fR with the \fB-m\fR option.  This
program relies on the MC and ms tags that fixmate provides.

Duplicates are found by using the alignment data for each read (and its mate for
paired reads).  Position and orientation (which strand it aligns against and in
what direction) are used to to compare the reads against one another. If two (or
more) reads have the same values then the one with the highest base qualities is
held to be the original and the others are the duplicates.

It should be noted that \fBsamtools markdup\fR looks for duplication first and
then classifies the type of duplication afterwards. If your process does not
care whether duplication is PCR or optical then it is faster if you do not use
the optical duplicate option.

Duplicates are marked by setting the alignment's DUP flag.

For more details please see:

<http://www.htslib.org/algorithms/duplicate.html>

.SH OPTIONS
.TP 11
.BI "-l " INT
.RI "Expected maximum read length of " INT " bases."
[300]
.TP
.B -r
Remove duplicate reads.
.TP
.BI "-T " PREFIX
Write temporary files to
.IB PREFIX . samtools . nnnn . mmmm . tmp
.TP
.B -S
Mark supplementary reads of duplicates as duplicates.
.TP
.B -s
Print some basic stats. See STATISTICS.
.TP
.BI "-f " file
Write stats to named file.
.TP
.B --json
Output stats in JSON format.
.TP
.BI "-d " distance
The optical duplicate distance.  Suggested settings of 100 for HiSeq style
platforms or about 2500 for NovaSeq ones.  Default is 0 to not look for
optical duplicates.  When set, duplicate reads are tagged with \fBdt:Z:SQ\fR for
optical duplicates and \fBdt:Z:LB\fR otherwise.  Calculation of distance depends
on coordinate data embedded in the read names produced by the Illumina
sequencing machines.  Optical duplicate detection will not work on non standard
names without the use of \fB--read-coords\fR.
.TP
.B -c
Clear previous duplicate settings and tags.
.TP
.B -t
Mark duplicates with the name of the original in a \fBdo\fR tag.
.TP
.B --duplicate-count
Record the original primary read duplication count (including itself) in a
\fBdc\fR tag.
.TP
.BI "-m, --mode " TYPE
Duplicate decision method for paired reads.  Values are \fBt\fR or \fBs\fR.
Mode \fBt\fR measures positions based on template start/end (default).
Mode \fBs\fR measures positions based on sequence start.
While the two methods identify mostly the same reads as duplicates, mode 
\fBs\fR tends to return more results.  Unpaired reads are treated identically
by both modes.
.TP
.B -u
Output uncompressed SAM, BAM or CRAM.
.TP
.B --include-fails
Include quality checked failed reads.
.TP
.B --no-multi-dup
Stop checking duplicates of duplicates for correctness.  While still marking
reads as duplicates further checks to make sure all optical duplicates are found
are not carried out.  Also operates on \fB-t\fR tagging where reads may tagged
with a better quality read but not necessarily the best one.  Using this option
can speed up duplicate marking when there are a great many duplicates for each
original read. 
.TP
.BI "--read-coords " REGEX
This takes a POSIX regular expression for at least x and y to be used in
optical duplicate marking It can also include another part of the read name
to test for equality, eg lane:tile elements. Elements wanted are captured with
parentheses.  Examples below.
.TP
.BI "--coords-order " ORDER
The order of the elements captured in the regular expression. Default is txy
where t is a part of the read name selected for string comparison and x/y the
coordinates used for optical duplicate detection.  Valid orders are: txy, tyx,
xyt, yxt, xty, ytx, xy and yx.
.TP
.BI "--barcode-tag " TAG
Duplicates must now also match the barcode tag.
.TP
.B --barcode-name
Use the UMI/barcode embedded in the read name (eigth colon delimited part).
.TP
.BI "--barcode-rgx " REGEX
Regex for barcode in the readname (alternative to --barcode-name).
.TP
.B --use-read-groups
The @RG tags must now also match to be a duplicate.
.TP
.B --no-PG
Do not add a PG line to the output file.
.TP
.BI "-@, --threads " INT
Number of input/output compression threads to use in addition to main thread [0].

.SH STATISTICS
Entries are:
.br
\fBCOMMAND\fR: the command line.
.br
\fBREAD\fR: number of reads read in.
.br
\fBWRITTEN\fR: reads written out.
.br
\fBEXCLUDED\fR: reads ignored.  See below.
.br
\fBEXAMINED\fR: reads examined for duplication.
.br
\fBPAIRED\fR: reads that are part of a pair.
.br
\fBSINGLE\fR: reads that are not part of a pair.
.br
\fBDUPLICATE PAIR\fR: reads in a duplicate pair.
.br
\fBDUPLICATE SINGLE\fR: single read duplicates.
.br
\fBDUPLICATE PAIR OPTICAL\fR: optical duplicate paired reads.
.br
\fBDUPLICATE SINGLE OPTICAL\fR: optical duplicate single reads.
.br
\fBDUPLICATE NON PRIMARY\fR: supplementary/secondary duplicate reads.
.br
\fBDUPLICATE NON PRIMARY OPTICAL\fR: supplementary/secondary optical
duplicate reads.
.br
\fBDUPLICATE PRIMARY TOTAL\fR: number of primary duplicate reads.
.br
\fBDUPLICATE TOTAL\fR: total number of duplicate reads.
.br
\fBESTIMATED LIBRARY SIZE\fR: estimate of the number of unique fragments in the
sequencing library.


Estimated library size makes various assumptions e.g. the library consists of
unique fragments that are randomly selected (with replacement) with equal
probability.
This is unlikely to be true in practice.
However it can provide a useful guide into how many unique read pairs are likely 
to be available.
In particular it can be used to determine how much more data might be obtained
by further sequencing of the library.

Excluded reads are those marked as secondary, supplementary or unmapped.
By default QC failed reads are also excluded but can be included as an option.
Excluded reads are not used for calculating duplicates.
They can optionally be marked as duplicates if they have a primary that is also
a duplicate.    
.SH EXAMPLES
This first collate command can be omitted if the file is already name ordered or collated:
.EX 4
samtools collate -o namecollate.bam example.bam
.EE

Add ms and MC tags for markdup to use later:
.EX 4
samtools fixmate -m namecollate.bam fixmate.bam
.EE

Markdup needs position order:
.EX 4
samtools sort -o positionsort.bam fixmate.bam
.EE

Finally mark duplicates:
.EX 4
samtools markdup positionsort.bam markdup.bam
.EE

Typically the fixmate step would be applied immediately after sequence
alignment and the markdup step after sorting by chromosome and
position.  Thus no \fIadditional\fR sort steps are normally needed.

To use the regex to obtain coordinates from reads, two or three values have to
be captured.  To mimic the normal behaviour and match a read name of the format
\fImachine:run:flowcell:lane:tile:x:y\fR use:
.EX 4
--read-coords '([!-9;-?A-~]+:[0-9]+:[0-9]+:[0-9]+:[0-9]+):([0-9]+):([0-9]+)'
--coords-order txy
.EE

To match only the coordinates of \fIx:y:randomstuff\fR use:
.EX 4
--read-coords '^([[:digit:]]+):([[:digit:]]+)'
--coords-order xy
.EE

To use a barcode from the read name matching the Illumina example of
\fINDX550136:7:H2MTNBDXX:1:13302:3141:10799:AAGGATG+TCGGAGA\fR use:

.EX 4
--barcode-rgx '[0-9A-Za-z]+:[0-9]+:[0-9A-Za-z]+:[0-9]+:[0-9]+:[0-9]+:[0-9]+:([!-?A-~]+)'
.EE

It is possible that complex regular expressions may slow the running of the
program.  It would be best to keep them simple. 

.SH AUTHOR
.PP
Written by Andrew Whitwham from the Sanger Institute.

.SH SEE ALSO
.IR samtools (1),
.IR samtools-sort (1),
.IR samtools-collate (1),
.IR samtools-fixmate (1)
.PP
Samtools website: <http://www.htslib.org/>