Skip to content

Alignment Trimming

Trim alignments based on the proportion of missing data or the number of parsimony informative sites. This feature will filter sites based on the specified parameters.

Assume we have an alignment file in FASTA format as follows:

>seq1
ATGCAT--A
>seq2
ATGCATA--
>seq3
ATGCAA-A-
>seq4
ATGCATA--

If we set the proportion of missing data to 0.5. It will generate an output without the last two sites using the following command:

Terminal window
segul align trim --dir alignments/ --missing-data 0.5

The output as follows. Note that the last two sites were removed because they had more than 50% missing data.

>seq1
ATGCAT-
>seq2
ATGCATA
>seq3
ATGCAA-
>seq4
ATGCATA

Filtering based on the proportion of missing data

Section titled “Filtering based on the proportion of missing data”

To trim alignments, use the align trim command with the following options:

Terminal window
segul align trim --dir <alignment-dir> --missing-data <value>

For example:

Terminal window
segul align trim --dir alignments/ --missing-data 0.5

Filtering based on parsimony informative sites

Section titled “Filtering based on parsimony informative sites”

To trim based on the minimum threshold of parsimony informative sites, use the --pinf option:

Terminal window
segul align trim --dir <alignment-dir> --pinf <value>

For example, this command will retain sites with at least 50 parsimony informative sites:

Terminal window
segul align trim --dir alignments/ --pinf 50

If the input is amino acid sequences, you need to use the --datatype aa option. For example:

Terminal window
segul align trim --dir alignments/ --missing-data 0.5 --datatype aa

Specifying the output directory and format

Section titled “Specifying the output directory and format”

By default, the output directory is Align-Trim. You can change the output directory name using the --output or -o option. For example, to name the output directory align-trim, use the command below:

Terminal window
segul align trim --dir alignments/ --output align-trim

To specify the output format, use the --output-format or -F option. The default output format is NEXUS. For example, to change the output format to FASTA, use the command below:

Terminal window
segul align trim --dir alignments/ --output-format fasta
Option Description
-d, --dir Directory with alignments
-i, --input Alignment files. Allows wildcards
-f, --input-format Input format: auto (default), fasta, nexus, or phylip
--datatype Data type: dna (default), aa, or ignore
--missing-data Remove sites with a higher proportion of missing data
--pinf Parsimony informative site threshold for keeping sites
-F, --output-format Output format: nexus (default), phylip, fasta, nexus-int, phylip-int, or fasta-int
-o, --output Output directory. Default: Align-Trim
--force Overwrite an existing output directory
--log Log file path. Default: segul.log