File: samtools-split.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 (171 lines) | stat: -rw-r--r-- 5,997 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
'\" t
.TH samtools-split 1 "12 September 2024" "samtools-1.21" "Bioinformatics tools"
.SH NAME
samtools split \- splits a file by read group.
.\"
.\" Copyright (C) 2008-2011, 2013-2018,2023-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 split
.RI [ options ]
.IR merged.sam | merged.bam | merged.cram

.SH DESCRIPTION
.PP
Splits a file by read group, or a specified tag,
producing one or more output files
matching a common prefix (by default based on the input filename).

Unless the \fB-d\fR option is used, the file will be split according to the
.B @RG
tags listed in the header.
Records without an RG tag or with an RG tag undefined in the header will cause
the program to exit with an error unless the \fB-u\fR option is used.

RG values defined in the header but with no records will produce an output file
only containing a header.

If the
.BI "-d " TAG
option is used, the file will be split on the value in the given aux tag.
Only string (type \fBZ\fR) and integer (type \fBi\fR in SAM,
plus equivalents in BAM/CRAM) tags are currently supported.
Unless the \fB-u\fR option is used, the program will exit with an error if
it finds a record without the given tag.

Note that attempting to split on a tag with high cardinality may result
in the creation of a large number of output files.
To prevent this, the \fB-M\fR option can be used to set a limit on the
number of splits made.

Using
.B -d RG
behaves in a similar way to the default (without \fB-d\fR),
opening an output file for each \fB@RG\fR line in the header.
However, unlike the default,
new output files will be opened for any RG tags found in the alignment records
irrespective of if they have a matching header \fB@RG\fR line.

The \fB-u\fR option may be used to specify the output filename for any
records with a missing or unrecognised tag.  This option will always write
out a file even if there are no records.

Output format defaults to BAM.  For SAM or CRAM then either set the format with
\fB--output-fmt\fR or use \fB-f\fR to set the file extension e.g.
\fB-f %*_%#.sam\fR. 

.SH OPTIONS
.TP 14
.BI "-u " FILE1
.RI "Put reads with no tag or an unrecognised tag into " FILE1
.TP
.BI "-h " FILE2
.RI "Use the header from " FILE2 " when writing the file given in the " -u
option.
This header completely replaces the one from the input file.
It must be compatible with the input file header, which means it must
have the same number of references listed in the @SQ lines and the
references must be in the same order and have the same lengths.
.TP
.BI "-f " STRING
Output filename format string (see below)
["%*_%#.%."]
.TP
.BI "-d " TAG
Split reads by TAG value into distinct files. Only the TAG key must be 
supplied with the option. The value of the TAG has to be a string (i.e.
.BR key:Z:value ") or an integer (" key:i:value ")."

Using this option changes the default filename format string to "%*_%!.%.",
so that tag values appear in the output file names.
This can be overridden by using the \fB-f\fR option.
.TP
.BI "-p " NUMBER
Pad numeric values in \fB%#\fR and \fB%!\fR format expansions to this many
digits using leading zeros.
For \fB%!\fR, only integer tag values will be padded.
String tag values will be left unchanged,
even if the value only includes digits.
.TP
.BI "-M,--max-split " NUM
Limit the number of files created by the \fB-d\fR option to \fINUM\fR (default
100).
This prevents accidents where trying to split on a tag with high cardinality
could result in the creation of a very large number of output files.
Once the file limit is reached,
any tag values not already seen will be treated as unmatched and the program
will exit with an error unless the \fB-u\fR option is in use.

If desired, the limit can be removed using \fB-M -1\fR,
although in practice the number of outputs will still be restricted by
system limits on the number of files that can be open at once.

If splitting by read group, and the read group count in the header
is higher than the requested limit then the limit will be raised to match.
.TP
.B -v
Verbose output
.TP
.BI --no-PG
Do not add a @PG line to the header of the output file.
.PP
Format string expansions:
.TS
center;
lb l .
%%	%
%*	basename
%#	index (of @RG in the header, or count of TAG values seen so far)
%!	@RG ID or TAG value
%.	output format filename extension
.TE
.TP
.BI "-@, --threads " INT
Number of input/output compression threads to use in addition to main thread [0].

.SH AUTHOR
.PP
Written by Martin Pollard from the Sanger Institute.

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