| 1 |
.TH "easel downsample" 1 "@EASEL_DATE@" "Easel @EASEL_VERSION@" "Easel Manual" |
| 2 |
|
| 3 |
.SH NAME |
| 4 |
easel downsample \- select random subset of lines or sequences |
| 5 |
|
| 6 |
.SH SYNOPSIS |
| 7 |
.B easel downsample |
| 8 |
[\fIoptions\fR] |
| 9 |
.I M |
| 10 |
.I infile |
| 11 |
|
| 12 |
|
| 13 |
.SH DESCRIPTION |
| 14 |
|
| 15 |
.PP |
| 16 |
Given an |
| 17 |
.I infile |
| 18 |
that contains |
| 19 |
.I N |
| 20 |
things (lines, sequences...), |
| 21 |
.B easel downsample |
| 22 |
randomly selects a subset of |
| 23 |
.I M |
| 24 |
of those things (M <= N) and outputs them to |
| 25 |
.I stdout. |
| 26 |
|
| 27 |
|
| 28 |
.PP |
| 29 |
If |
| 30 |
.I infile |
| 31 |
is \- (a single dash) |
| 32 |
input is read from |
| 33 |
.I stdin. |
| 34 |
(The |
| 35 |
.B \-S |
| 36 |
option can't read from stdin.) |
| 37 |
|
| 38 |
.PP |
| 39 |
The default is to downsample individual lines from a text |
| 40 |
.I infile. |
| 41 |
With the |
| 42 |
.B -s |
| 43 |
or |
| 44 |
.B -S |
| 45 |
option, |
| 46 |
.I infile |
| 47 |
is a sequence file (in any format that Easel accepts), and |
| 48 |
it downsamples sequence records. |
| 49 |
|
| 50 |
.PP |
| 51 |
Uses an efficient reservoir sampling algorithm that only requires |
| 52 |
memory proportional to the sample size |
| 53 |
.I M, |
| 54 |
independent of the total input size |
| 55 |
.I N, |
| 56 |
and usually requires only a single pass through |
| 57 |
.I infile. |
| 58 |
Still, if |
| 59 |
.I M |
| 60 |
is large, memory usage could be a concern. The default line sampler |
| 61 |
holds |
| 62 |
.I M |
| 63 |
lines in memory, so it uses about |
| 64 |
.I ML |
| 65 |
bytes of memory, for mean line length |
| 66 |
.I L. |
| 67 |
The |
| 68 |
.B -s |
| 69 |
sequence sampler holds |
| 70 |
.I M |
| 71 |
sequence objects in memory, including metadata. The |
| 72 |
.B -S |
| 73 |
"big" sequence sampler is a more memory efficient version |
| 74 |
that only needs |
| 75 |
.I 8M |
| 76 |
bytes, but it has some restrictions on its use, described below. |
| 77 |
|
| 78 |
.PP |
| 79 |
Otherwise the magnitude of |
| 80 |
.I M |
| 81 |
is essentially unrestricted; it is a 64-bit integer. |
| 82 |
.B easel downsample |
| 83 |
is designed to handle samples of billions |
| 84 |
of sequences if necessary. |
| 85 |
|
| 86 |
|
| 87 |
.SH OPTIONS |
| 88 |
|
| 89 |
.TP |
| 90 |
.B \-h |
| 91 |
Print brief help; includes version number and summary of |
| 92 |
all options. |
| 93 |
|
| 94 |
.TP |
| 95 |
.B \-s |
| 96 |
Sequence sampling. |
| 97 |
.I infile |
| 98 |
is a sequence file, in any valid Easel sequence format |
| 99 |
(including multiple sequence alignment files). |
| 100 |
The sample of sequences needs to fit in memory, so |
| 101 |
.I M |
| 102 |
should not be outrageously large. |
| 103 |
Because the sequences pass through the Easel sequence |
| 104 |
data parser, there can be some metadata loss. |
| 105 |
When |
| 106 |
.I infile |
| 107 |
is a multi-MSA file (e.g. Pfam or Rfam), |
| 108 |
.I N |
| 109 |
includes all alignments, not just the first one. |
| 110 |
The output is in FASTA format. |
| 111 |
|
| 112 |
.TP |
| 113 |
.B \-S |
| 114 |
"Big" sequence sampling. |
| 115 |
.I M |
| 116 |
can be reasonably outrageous (a billion sequences |
| 117 |
will require about 8G RAM). |
| 118 |
.I infile |
| 119 |
needs to be an actual file (not a pipe or stream), because this option |
| 120 |
keeps only disk offsets to define the sample, then uses each offset to |
| 121 |
go and seek each sequence record in the file. |
| 122 |
Additionally, |
| 123 |
.I infile |
| 124 |
must be an unaligned sequence file format, not |
| 125 |
in a multiple sequence alignment format, because the mechanics |
| 126 |
of |
| 127 |
.B \-S |
| 128 |
assume that each |
| 129 |
sequence record is a contiguous chunk of the file. |
| 130 |
Each sampled sequence record is echoed to the output, so each |
| 131 |
record is exactly as it appeared in its native format; |
| 132 |
there is no metadata loss, and the output |
| 133 |
is in the same format that |
| 134 |
.I infile |
| 135 |
was in. |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
.SH EXPERT OPTIONS |
| 140 |
|
| 141 |
.TP |
| 142 |
.BI \-\-seed " <n>" |
| 143 |
Set the random number seed to |
| 144 |
.I <n>, |
| 145 |
an integer >= 0. The default is 0, which means to use |
| 146 |
a randomly selected seed. A seed > 0 will result |
| 147 |
in identical samples from different runs of the same |
| 148 |
.B easel downsample |
| 149 |
command. |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
.SH SEE ALSO |
| 154 |
|
| 155 |
.nf |
| 156 |
@EASEL_URL@ |
| 157 |
.fi |
| 158 |
|
| 159 |
.SH COPYRIGHT |
| 160 |
|
| 161 |
.nf |
| 162 |
@EASEL_COPYRIGHT@ |
| 163 |
@EASEL_LICENSE@ |
| 164 |
.fi |
| 165 |
|
| 166 |
.SH AUTHOR |
| 167 |
|
| 168 |
.nf |
| 169 |
http://eddylab.org |
| 170 |
.fi |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|