- Preparing sequence alignments for phylogenetic and evolutionary analysis is a critical step in molecular biology and bioinformatics. Phylogenetic methods use similarities and differences among DNA, RNA, or protein sequences to infer evolutionary relationships, reconstruct common ancestry, and investigate the history of genes, species, populations, and organisms. The reliability of these analyses depends heavily on the quality and biological suitability of the sequence alignment. An alignment that contains incorrect residue correspondences, poorly aligned regions, sequencing errors, or inappropriate sequences can produce misleading evolutionary conclusions, even when sophisticated phylogenetic algorithms are used.
- The first step is to define the biological question and select an appropriate set of sequences. The analysis may aim to reconstruct relationships among species, investigate the evolutionary history of a gene family, identify population-level relationships, estimate divergence, or examine patterns of natural selection. The choice of sequences depends on the objective. For example, conserved protein-coding genes may be useful for studying deeper evolutionary relationships, whereas rapidly evolving genes or genomic regions may provide information about closely related populations or species. Mitochondrial genes, ribosomal RNA genes, nuclear genes, and whole-genome regions each have different evolutionary characteristics and are suitable for different research questions.
- Sequence selection should consider taxonomic coverage, sequence length, completeness, quality, and evolutionary relevance. Sequences should ideally represent the same homologous gene or genomic region. Homologous sequences share a common evolutionary origin, but they may represent orthologs or paralogs. Orthologs arise through speciation, whereas paralogs arise through gene duplication. Confusing these categories can lead to incorrect interpretations of gene and species relationships. In particular, a gene tree constructed from paralogous sequences may not represent the evolutionary relationships among the organisms from which they were obtained. Gene family analysis, domain architecture, genomic context, and orthology resources can help identify appropriate sequences before alignment.
- Sequence identifiers and metadata should be retained throughout the analysis. Each sequence should be associated with information such as organism name, taxonomic classification, gene identifier, accession number, sequence type, and database source. Duplicate sequences, incorrectly labelled records, contamination, partial sequences, and sequences from unexpected organisms should be investigated. Redundant sequences may distort some analyses by overrepresenting particular species or lineages. However, closely related sequences should not automatically be removed, because their variation may be important for population genetics and recent evolutionary studies. The appropriate level of redundancy depends on the biological question and the intended sampling strategy.
- The type of sequence used for alignment is also important. DNA and RNA alignments generally use nucleotide substitution models, while protein alignments use amino acid substitution models. Protein sequences can be more suitable than nucleotide sequences for studying deeply diverged coding genes because amino acid sequences often retain detectable evolutionary signals after synonymous nucleotide substitutions have accumulated. Nucleotide alignments, however, preserve information about synonymous and nonsynonymous substitutions and are essential for many analyses of codon evolution and selection. The choice between nucleotide and protein alignment should therefore reflect the evolutionary timescale and the type of information required.
- For protein-coding genes, a useful strategy is often to align the translated amino acid sequences and then project the alignment back onto the corresponding nucleotide sequences. Protein alignment can improve the identification of conserved regions and evolutionary correspondence because amino acid substitutions are constrained by protein structure and function. The resulting codon alignment preserves the original nucleotide triplets while maintaining the correspondence between amino acid positions. This is particularly important for estimating synonymous and nonsynonymous substitution rates, calculating dN/dS ratios, and investigating selection acting on protein-coding genes. Tools such as MAFFT, MUSCLE, MACSE, and PAL2NAL can support different stages of this process. MACSE is specifically designed to handle coding sequences, including cases involving frameshifts and stop codons, while PAL2NAL can convert a protein alignment and its corresponding coding sequences into a codon alignment.
- The selected sequences should be checked for completeness and consistency before alignment. Differences in sequence length may result from genuine insertions and deletions, alternative transcript structures, incomplete sequencing, or incorrect gene identification. Partial sequences may be retained when they contain reliable homologous regions, but their missing regions should be recognized during downstream analysis. Sequences containing many ambiguous nucleotides, unexplained stop codons, frameshifts, or unusually long insertions should be examined carefully. For protein sequences, unexpected stop symbols, extensive unknown residues, and inconsistent domain structures may indicate errors or non-homologous sequences. Sequence quality assessment helps prevent technical problems from being interpreted as evolutionary events.
- Multiple sequence alignment is generally performed using specialized algorithms that identify corresponding positions among homologous sequences. Commonly used programs include MAFFT, MUSCLE, Clustal Omega, and T-Coffee. These tools use different combinations of progressive alignment, iterative refinement, consistency-based information, and profile alignment. The choice depends on the number of sequences, their evolutionary divergence, sequence length, computational resources, and the importance of alignment accuracy. MAFFT provides several strategies, including fast methods for large datasets and more computationally intensive methods for difficult alignments. MUSCLE and Clustal Omega are also widely used for protein and nucleotide alignments.
- A basic protein alignment using MAFFT can be performed as follows:
mafft –auto protein_sequences.fasta > protein_alignment.fasta
- For a more computationally intensive alignment of relatively similar sequences, MAFFT’s L-INS-i strategy may be appropriate:
mafft –localpair –maxiterate 1000 protein_sequences.fasta > protein_alignment.fasta
- A nucleotide alignment can be generated using the same general approach:
mafft –auto nucleotide_sequences.fasta > nucleotide_alignment.fasta
- The resulting alignment should be inspected rather than accepted automatically. A high alignment score does not guarantee that all positions are biologically correct. Alignment quality assessment should examine conserved regions, gap placement, sequence coverage, ambiguous columns, and consistency among related sequences. Unexpectedly long gaps, poorly aligned terminal regions, isolated mismatches, and regions with extensive sequence ambiguity may indicate alignment uncertainty. However, gaps can represent genuine evolutionary insertions and deletions, so their presence alone is not evidence of poor alignment. Conserved functional motifs, known protein domains, structural information, and independent biological evidence can help evaluate whether the alignment is plausible.
- The treatment of gaps and ambiguous positions is particularly important in phylogenetic analysis. Gaps may represent insertions or deletions, while ambiguous nucleotides may indicate uncertain sequencing calls or incomplete information. Some phylogenetic programs treat gaps as missing data, whereas other approaches can model indel information explicitly. The treatment should be selected according to the evolutionary question and the capabilities of the analysis method. Automatically converting every gap into a missing character or deleting every gap-containing column may remove biologically meaningful information. Similarly, ambiguous nucleotide codes such as N, R, Y, and other IUPAC symbols should be handled consistently with the chosen software and evolutionary model.
- Alignment trimming is frequently performed to remove regions that are considered unreliable or difficult to align. Poorly aligned regions can introduce noise into phylogenetic reconstruction because the compared residues may not represent true evolutionary correspondences. Tools such as trimAl, Gblocks, ClipKIT, and BMGE can identify and remove or filter alignment positions according to different criteria. For example, trimAl can remove columns containing excessive gaps or low-quality alignment information.
trimal -in protein_alignment.fasta -out trimmed_alignment.fasta -automated1
- A gap-based trimming approach can also be applied using a specified gap threshold:
trimal -in protein_alignment.fasta -out trimmed_alignment.fasta -gt 0.8
- The -gt option uses a gap threshold, but its interpretation and effect should be checked against the software documentation and the intended filtering strategy. Trimming should not be excessively aggressive. Removing too many positions may eliminate informative evolutionary variation, especially in rapidly evolving genes or short alignments. Conversely, retaining highly uncertain regions may increase estimation error. It is often useful to compare phylogenetic results obtained from the original alignment and one or more carefully filtered versions to evaluate whether the conclusions are sensitive to alignment treatment.
- Alignment uncertainty can also be assessed using methods that evaluate the stability and consistency of residue correspondence. GUIDANCE2 and related approaches examine how alignment positions behave under changes in guide trees or sequence sampling. Transitive Consistency Score (TCS) evaluates consistency information supporting aligned residues. These methods provide useful confidence-related information, but their scores should not automatically be interpreted as probabilities that individual positions are correct. Alignment confidence is especially important for highly divergent sequences, repeat-rich regions, and regions containing extensive insertions and deletions.
- For protein-coding genes, codon-aware alignment is essential when the objective involves nucleotide-level evolutionary analysis. A conventional nucleotide alignment can sometimes place gaps in ways that disrupt codon boundaries, producing biologically implausible alignments. In a codon alignment, insertions and deletions are generally interpreted in relation to complete codons, while nucleotide positions remain grouped into triplets. Protein-guided alignment is a common strategy because amino acid sequences provide a more evolutionarily constrained basis for identifying homologous positions. Specialized tools such as MACSE are useful when frameshifts, premature stop codons, or disrupted coding sequences must be considered.
- An illustrative protein-guided codon alignment workflow may begin by translating coding sequences, aligning the resulting proteins, and projecting the protein alignment back onto the original coding sequences. The following commands illustrate the general approach with PAL2NAL:
mafft –auto protein_sequences.fasta > protein_alignment.fasta
pal2nal.pl protein_alignment.fasta coding_sequences.fasta \
-output fasta > codon_alignment.fasta
- The protein and nucleotide inputs must contain corresponding sequences with matching identifiers and compatible sequence content. The coding sequences should use the appropriate genetic code and be checked for frameshifts, internal stop codons, and incomplete codons. The output should be inspected to ensure that codon boundaries and sequence correspondence have been preserved.
- After alignment preparation, the data may need to be divided into biologically or statistically meaningful partitions. A partition is a subset of alignment positions that may have its own evolutionary model or parameters. For example, protein-coding genes can be divided into first, second, and third codon positions because these positions often evolve at different rates. Individual genes may also be treated as separate partitions in multilocus analyses. In mitochondrial genomes, protein-coding genes, ribosomal RNA genes, and transfer RNA genes may have different evolutionary characteristics. Partitioning allows these differences to be represented more appropriately, although excessive partitioning can increase model complexity and reduce the amount of information available for estimating parameters.
- Codon-position partitioning can be generated using software such as AMAS or custom scripts, while phylogenetic programs such as IQ-TREE and PartitionFinder-related tools can assist with partition selection and model assignment. Partitioning decisions should be biologically justified and reported clearly. A single alignment may be suitable for a simple analysis, while a large multilocus dataset may require separate alignments and partitions for individual genes or genomic regions.
- For phylogenetic reconstruction, alignment preparation should also consider the evolutionary model. A substitution model describes how nucleotide or amino acid characters change over evolutionary time. Common nucleotide models include JC69, K80, HKY, and GTR, while protein analyses may use models such as JTT, WAG, and LG. These models differ in their assumptions about substitution rates, base or amino acid frequencies, and evolutionary processes. Model selection can be performed using tools such as ModelFinder within IQ-TREE. The best-fitting model depends on the data and the model-selection criterion, and a more complex model is not necessarily better in every situation.
- An example of maximum-likelihood phylogenetic analysis using IQ-TREE is:
iqtree2 -s trimmed_alignment.fasta -m MFP -B 1000
- Here, -s specifies the alignment, -m MFP requests ModelFinder-based model selection, and -B 1000 requests ultrafast bootstrap approximation with 1,000 replicates. The exact options should be checked against the installed IQ-TREE version. Bootstrap support measures the stability of inferred branches under resampling of alignment sites; it does not directly measure the probability that a particular evolutionary relationship is true.
- Before phylogenetic reconstruction, it is important to assess whether the sequences are appropriate for the same evolutionary analysis. Recombination, gene conversion, horizontal gene transfer, hybridization, and incomplete lineage sorting can cause different regions or genes to have different evolutionary histories. A single concatenated alignment may therefore produce a tree that does not adequately represent the history of every locus. Recombination detection and gene-tree comparison can help identify such situations. In multilocus studies, individual gene trees should be examined alongside concatenated analyses, and species-tree methods may be appropriate when gene trees differ because of processes such as incomplete lineage sorting.
- Taxon sampling is another important factor. Including a broad and balanced selection of organisms can improve the representation of evolutionary diversity and reduce problems caused by missing intermediate lineages. However, adding many poorly characterized or non-homologous sequences may reduce alignment quality. Outgroups should be selected carefully because a highly divergent outgroup can make alignment and rooting difficult. Long-branch attraction is a potential problem in phylogenetic inference when rapidly evolving lineages are incorrectly grouped due to systematic error. Appropriate taxon sampling, evolutionary models, and alignment evaluation can help reduce this risk.
- Missing data should also be considered before analysis. Incomplete sequences can create large blocks of gaps, particularly when genes or genomic regions are concatenated across many organisms. Missing data do not always invalidate a phylogenetic analysis, but their distribution and extent can influence the information available for particular branches. It is useful to examine the proportion of missing characters for each sequence and alignment region. Taxa with extremely incomplete data may require further investigation, although removing them automatically can also discard valuable evolutionary information.
- For large phylogenomic datasets, separate gene alignments may be prepared first and then combined into a supermatrix. Each gene alignment should be checked for orthology, sequence quality, alignment reliability, and suitable evolutionary interpretation. The alignments can be concatenated while retaining information about gene boundaries and partition definitions. Tools such as AMAS and SequenceMatrix can support alignment concatenation and partition-file preparation. Concatenation should be performed carefully because different genes may have different evolutionary rates, substitution patterns, and histories. A partitioned model can account for some differences, while coalescent-based species-tree approaches may be more suitable when gene-tree discordance is biologically important.
- Evolutionary analyses based on prepared alignments include phylogenetic tree reconstruction, molecular-clock analysis, ancestral sequence reconstruction, estimation of evolutionary distances, detection of positive or purifying selection, and investigation of molecular adaptation. Codon alignments are particularly important for estimating synonymous and nonsynonymous substitution rates. The ratio dN/dS is commonly used to investigate selective pressures on protein-coding genes, but its interpretation depends on the model, sampling, alignment quality, and biological context. Misaligned codons can produce artificial substitutions and misleading estimates of selection. Similarly, poorly aligned protein regions can affect estimates of evolutionary distances and the placement of branches in a phylogenetic tree.
- Different software tools support different stages of the workflow. MAFFT, MUSCLE, and Clustal Omega are commonly used for multiple sequence alignment. MACSE and PAL2NAL support codon-aware alignment workflows. trimAl, Gblocks, ClipKIT, and BMGE assist with alignment filtering. GUIDANCE2 and TCS provide alignment reliability information. IQ-TREE, RAxML-NG, and PhyML support maximum-likelihood phylogenetic inference, while MrBayes and BEAST are used for Bayesian phylogenetic and evolutionary analyses. MEGA provides an integrated environment for sequence analysis and phylogenetics. AliView, Jalview, and SeaView can be used to inspect and edit alignments. The choice of software should reflect the data type, analytical objective, dataset size, and assumptions of the method.
- Reproducibility is essential when preparing alignments for phylogenetic and evolutionary analysis. Researchers should retain the original unaligned sequences, the final alignment, any trimmed or masked alignment, and the metadata used to identify each sequence. The software names, versions, command-line parameters, substitution models, trimming thresholds, genetic code, partition definitions, and sequence inclusion or exclusion decisions should be documented. Database accession numbers and retrieval dates should also be recorded when sequences are obtained from public resources. Scripts and workflow descriptions can help ensure that the analysis can be repeated and independently evaluated.
- Preparing alignments for phylogenetic and evolutionary analysis is therefore more than simply arranging sequences into columns. It requires careful sequence selection, confirmation of homology, appropriate alignment methods, evaluation of alignment reliability, treatment of gaps and missing data, codon-aware processing where necessary, and consideration of evolutionary models and biological processes. A well-prepared alignment provides a reliable foundation for reconstructing evolutionary relationships and investigating molecular evolution. The quality of the final conclusions depends not only on the phylogenetic software but also on the biological validity and statistical suitability of the alignment used as input.