| 1 | # `easel filter` : remove redundant seqs from alignment |
| 2 | |
| 3 | ## SYNOPSIS |
| 4 | |
| 5 | ``` |
| 6 | easel filter [-options] <maxid> <msafile> |
| 7 | ``` |
| 8 | |
| 9 | ## DESCRIPTION |
| 10 | |
| 11 | Given an input alignment `<msafile>`, remove sequences that are >= |
| 12 | `<maxid>` fractional identity to another aligned sequence, and output |
| 13 | the filtered alignment. `<maxid>` is a value between 0 and 1 |
| 14 | (inclusive); 0.90 means 90% pairwise identity, for example. |
| 15 | |
| 16 | When two sequences have >= `<maxid>` identity, by default we keep the |
| 17 | one with better "consensus coverage". Consensus coverage is defined by |
| 18 | the number of consensus columns covered by the "span" of the aligned |
| 19 | sequence, between its leftmost and rightmost aligned residues |
| 20 | (inclusive). Which columns are "consensus" is determined by |
| 21 | standardized HMMER/Infernal rules, based on counting (unweighted) |
| 22 | residue occupancy in each column (see `--symfrac`) after defining |
| 23 | sequence fragments (see `--fragthresh`). These rules, and options that |
| 24 | control them, are defined |
| 25 | [in a separate section, below](#options-for-determining-consensus). |
| 26 | |
| 27 | The purpose of the default "conscover" rule is to prefer a better |
| 28 | full-length representation of the sequence alignment (as opposed to |
| 29 | keeping a fragment, for example), without overly biasing |
| 30 | insertion/deletion statistics in the filtered alignment. The |
| 31 | preference rule can be changed to prefer sequences based on their |
| 32 | order in the alignment (favor the lower-indexed sequence), or to |
| 33 | prefer sequences randomly, using the `--origorder` or `--randorder` |
| 34 | options, respectively. |
| 35 | |
| 36 | Pairwise identity is defined using the minimum of the unaligned |
| 37 | sequence lengths as the denominator. Only canonical (nondegenerate) |
| 38 | residues are counted toward pairwise identities in the numerator and |
| 39 | to raw sequence lengths in the denominator. |
| 40 | |
| 41 | The file format of `<msafile>` is detected automatically. and so is |
| 42 | its residue alphabet (i.e. protein, DNA, or RNA). Several common |
| 43 | alignment file formats are recognized, including Stockholm, aligned |
| 44 | FASTA, Clustal (and Clustal-like formats like MUSCLE output), |
| 45 | PSIBLAST, A2M, and Phylip. To specify the format, see `--informat`; to |
| 46 | specify the alphabet, see `--dna`, `--rna`, `--amino`. |
| 47 | |
| 48 | If `<msafile>` is - (a single dash), the input alignment is read from |
| 49 | standard input. This lets you use `easel filter` in a pipe, in clever |
| 50 | command line incantations. |
| 51 | |
| 52 | If the `<msafile>` name ends in `.gz`, it is assumed to be gzip |
| 53 | compressed; we read it through `gunzip -c`. If your system doesn't |
| 54 | have `gunzip` installed and in your PATH, this will fail. |
| 55 | |
| 56 | The filtered output alignment is written to `stdout` by default, in |
| 57 | the same format that the input alignment was in. To redirect it to a |
| 58 | file, see the `-o` option; to change it to a different format, see the |
| 59 | `--outformat` option. |
| 60 | |
| 61 | |
| 62 | ## OPTIONS |
| 63 | |
| 64 | #### `-h` |
| 65 | |
| 66 | Print brief help, usage, and version information, including summary of |
| 67 | all options. |
| 68 | |
| 69 | #### `-o <outfile>` |
| 70 | |
| 71 | Output filtered MSA(s) to `<outfile>` instead of to `stdout`. |
| 72 | |
| 73 | #### `--informat <fmt>` |
| 74 | |
| 75 | Specify that input `<msafile>` is in format `<fmt>`, and bypass format |
| 76 | autodetection. Common choices for `<fmt>` include: `stockholm`, `a2m`, |
| 77 | `afa`, `psiblast`, `clustal`, `phylip`. For more information, and for |
| 78 | codes for some less common formats, see main documentation. The |
| 79 | string `<fmt>` is case-insensitive (`a2m` or `A2M` both work). |
| 80 | |
| 81 | #### `--outformat <fmt>` |
| 82 | |
| 83 | Write the filtered output MSA in alignment file format `<fmt>`. |
| 84 | Common choices for `<fmt>` include `stockholm`, `a2m`, `afa`, |
| 85 | `psiblast`, `clustal`, `phylip`; also, `pfam` is a one-block version |
| 86 | of `stockholm`. The string `<fmt>` is case-insensitive. Default is to |
| 87 | use the same format as the input `<msafile>`. |
| 88 | |
| 89 | #### `--dna` |
| 90 | |
| 91 | Specify that the input `<msafile>` contains DNA sequences, rather than |
| 92 | using autodetection. |
| 93 | |
| 94 | #### `--rna` |
| 95 | |
| 96 | Specify that the input `<msafile>` contains RNA sequences, rather than |
| 97 | using autodetection. |
| 98 | |
| 99 | #### `--amino` |
| 100 | |
| 101 | Specify that the input `<msafile>` contains protein sequences, rather |
| 102 | than using autodetection. |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | ## OPTIONS FOR DETERMINING CONSENSUS |
| 108 | |
| 109 | We use heuristic rules to decide which alignment columns are deemed to |
| 110 | be "consensus" columns versus insertions relative to consensus: |
| 111 | |
| 112 | 1. If a reference annotation line is provided (`#=GC RF`, in |
| 113 | Stockholm), use it. (Unless `--ignore-rf` is set.) |
| 114 | |
| 115 | 2. If it's a deep alignment (>50K sequences), subsample it and apply |
| 116 | fragthresh/symfrac rules to a sample of 10K sequences instead of |
| 117 | all seqs. (Unless `--no-sampling` is set). This is a speed |
| 118 | optimization: because the rules are based on frequencies, a |
| 119 | statistical subsample usually suffices. |
| 120 | |
| 121 | A pathological exception is when the alignment is dominated by |
| 122 | sequence fragments, with only a few sequences being representative |
| 123 | of the full-length consensus. This happens with some DNA repeat |
| 124 | families, for example. If the sample contains more than 5K |
| 125 | fragments, reject the sample and go to (3). |
| 126 | |
| 127 | To change the threshold for "deep" alignments, the size of the |
| 128 | sample, or the rejection threshold for too many fragments, see |
| 129 | `--sampthresh`, `--nsamp`, and `--maxfrag`. |
| 130 | |
| 131 | 3. The standard rule, applied to all seqs: define sequence fragments, |
| 132 | collect (unweighted) observed counts in each column (ignoring |
| 133 | external gaps in seq fragments), and define consensus columns as |
| 134 | those with residue occupancy $\geq 0.5$. The fragment definition |
| 135 | rule is to calculate the fractional "span" of the aligned sequence |
| 136 | as the aligned sequence length from its first to its last aligned |
| 137 | residue, divided by the total alignment length; the sequence is |
| 138 | called a fragment if this span is $<0.5$. To change the fragment |
| 139 | definition threshold or the residue occupancy threshold, see |
| 140 | `--fragthresh` and `--symfrac`. |
| 141 | |
| 142 | 4. If all else fails, define all columns as consensus. |
| 143 | |
| 144 | The options controlling consensus column determination are the |
| 145 | following: |
| 146 | |
| 147 | #### `--ignore-rf` |
| 148 | |
| 149 | Do not use reference annotation to determine consensus, even if a |
| 150 | reference annotation line is present. |
| 151 | |
| 152 | #### `--no-sampling` |
| 153 | |
| 154 | Do not use a statistical subsample when using the fragthresh/symfrac |
| 155 | rules; use all sequences. |
| 156 | |
| 157 | #### `--fragthresh <x>` |
| 158 | |
| 159 | Sets the fractional alignment span threshold for defining a sequence |
| 160 | fragment. For sequence fragments, external gaps are not counted. |
| 161 | The fractional alignment span `<aspan>` is the aligned |
| 162 | length from first to last aligned residue, divided by the total |
| 163 | alignment length. If `<aspan>` < `<x>`, define sequence as a |
| 164 | fragment. `<x>` is between 0 and 1, inclusive; default is 0.5. |
| 165 | |
| 166 | Note that the presence of all-gap columns in an alignment affects |
| 167 | fragthresh calculations, without affecting the alignment itself. |
| 168 | |
| 169 | The smaller `fragthresh` is, the fewer fragments are defined. |
| 170 | `--fragthresh 0` says no sequences are fragments. `--fragthresh 1` |
| 171 | says they all are, except for ones that span the entire alignment |
| 172 | (have their first residue in the first column, and their last residue |
| 173 | in the last column). |
| 174 | |
| 175 | #### `--symfrac <x>` |
| 176 | |
| 177 | Sets the residue occupancy threshold for defining a consensus column. |
| 178 | Occupancy is calculated as `<nres> / (<nres> + <ngap>)`, where |
| 179 | `<nres>` is the number of residues and `<ngap>` is the number of gaps. |
| 180 | External gaps in sequence fragments are ignored. "Missing data" |
| 181 | symbols (typically `~`) and "not a residue" symbols (typically `*`) |
| 182 | are ignored. If occupancy >= `<x>`, the column is called consensus. |
| 183 | `<x>` is between 0 and `, inclusive; default is 0.5. |
| 184 | |
| 185 | The smaller `symfrac` is, the more consensus columns are defined. |
| 186 | `--symfrac 0` calls all columns consensus. `--symfrac 1` calls only |
| 187 | the columns that contain no gaps. |
| 188 | |
| 189 | #### `--sampthresh <n>` |
| 190 | |
| 191 | If the number of sequences in the alignment is > `<sampthresh>`, the |
| 192 | alignment is "deep" enough that we switch to statistical subsampling. |
| 193 | `<n>` is >= 0; default is 50000. |
| 194 | |
| 195 | #### `--nsamp <n>` |
| 196 | |
| 197 | When using statistical subsampling, take a random sample of `<n>` |
| 198 | sequences. `<n>` is >= 1 (but should be large enough to calculate |
| 199 | `<symfrac>` occupancy frequencies with reasonable accuracy). Default |
| 200 | is 10000. |
| 201 | |
| 202 | #### `--maxfrag <n>` |
| 203 | |
| 204 | If the statistical sample contains > <n> sequence fragments, reject it |
| 205 | and use all sequences instead. `<n>` is >= 0; it should be < <nsamp> |
| 206 | (we don't check) and it doesn't make a lot of sense to make it very |
| 207 | small either. Default is 5000. |
| 208 | |
| 209 | #### `-s <n>` |
| 210 | |
| 211 | Set the random number generator seed to `<n>`. This affects random |
| 212 | subsampling, and it also affects the optional `randorder` preference |
| 213 | rule. The default is a fixed seed (42), so results are reproducible. |
| 214 | Selecting a different seed >0 creates a different reproducible stream |
| 215 | of random numbers. `-s 0` selects an arbitrary seed, so results can |
| 216 | vary from run to run. |
| 217 | |
| 218 | |
| 219 | |
| 220 | ## OPTIONS FOR SEQUENCE PREFERENCE RULE |
| 221 | |
| 222 | #### `--conscover` |
| 223 | |
| 224 | (Default.) When choosing which sequence to eliminate of a pair that |
| 225 | met the `<maxid>` pairwise identity threshold, prefer the one with |
| 226 | better consensus coverage. |
| 227 | |
| 228 | #### `--origorder` |
| 229 | |
| 230 | Alternative preference rule: prefer the sequence that came first in |
| 231 | the alignment. |
| 232 | |
| 233 | #### `--randorder` |
| 234 | |
| 235 | Alternative preference rule: assign random preferences. |
| 236 | |
| 237 |