Alignment trimmer
Removes gappy columns, and ragged sequences, from an aligned FASTA. Nothing is uploaded.
Removes gappy columns, and ragged sequences, from an aligned FASTA. Nothing is uploaded.
Two filters, applied in this order:
Gaps count in the denominator of column identity, the same convention as the rest of this site, so a column that is half gaps can never be more than 50 % identical. Both- and . are read as gaps.
The default of 50 % removes only the columns that most of the alignment does not share, which is a safe starting point. Tighter settings are common for phylogenetics:
| Max gaps | trimAl | Effect |
|---|---|---|
| 0 % | -gt 1 | Only columns present in every sequence survive |
| 20 % | -gt 0.8 | Strict, typical for tree building |
| 50 % | -gt 0.5 | Removes the clearly gappy columns |
| 80 % | -gt 0.2 | Removes only near-empty columns |
Keep at least is the counterpart of trimAl's -cons: if the filters would leave less than that share of the original columns, the least gappy of the removed columns are put back until the share is reached. Set it when a threshold must not be allowed to destroy a short alignment.
The example is an alignment of 5 coding sequences, 54 columns wide, in which one record is a fragment covering half the alignment and three columns carry an insertion found in only one sequence.
The trimmed alignment is plain FASTA, ready to copy or download, and can be converted to PHYLIP, NEXUS or Clustal with thealignment format converter. To check how much the trimming changed the sequences, run the trimmed file through theidentity and similarity calculator, which reports every pair. To remove gap characters altogether rather than columns, use thegap cleaner, and to join several trimmed alignments into one supermatrix, use merge alignments.
It removes the columns that carry little usable signal, almost always the gappy ones created by a few long insertions or by ragged sequence ends. Every sequence loses the same columns, so the alignment stays an alignment; only its width shrinks. Phylogenetic and selection analyses often improve when those columns go, because a column that is mostly gaps contributes noise to every pair.
trimAl -gt takes the smallest fraction of sequences that must have a residue in a column, so -gt 0.8 keeps columns that are at most 20 percent gaps. This page asks for the same number the other way round, as the largest share of gaps a column may have, because that is how the question is usually phrased. Max gaps 20 percent is trimAl -gt 0.8.
It depends on the alignment. Trimming clearly helps when a few sequences are partial or carry long private insertions, which is common in a set pulled from a database. On a well-aligned, complete set, aggressive trimming can remove more signal than noise. Compare trees from the trimmed and untrimmed alignment before deciding, and report the threshold you used.
It drops whole sequences before any column is looked at. Occupancy is the share of alignment columns in which a sequence has a residue rather than a gap, so a fragment that covers a third of the alignment has an occupancy of 33 percent. Removing such fragments first is usually what makes the column statistics meaningful, since one ragged sequence can make many columns look gappy.
Yes. An alignment is a rectangle: every record must have the same number of columns once gaps are counted. If the lengths differ, the file is not an alignment, or lines were lost in copying, and the tool says which records are the odd ones out instead of guessing.