Merge alignments
Concatenates aligned FASTA files by header and writes the partition table for RAxML or IQ-TREE.
Concatenates aligned FASTA files by header and writes the partition table for RAxML or IQ-TREE.
A supermatrix is several alignments of the same taxa, one per gene or locus, glued together side by side into one long alignment. Each gene keeps its own stretch of columns, called apartition, so a phylogenetic program can give it its own substitution model and its own rate while still building a single tree from all the data.
Building one by hand is where the mistakes happen: a taxon present in three genes and missing from the fourth, a name spelled two ways, a partition table counted off by one. This page does the bookkeeping. Records are matched on the first word of the header, a sequence missing from an alignment is filled with gaps across that partition, and the partition boundaries are counted from the widths actually merged.
Columns are numbered from 1 across the whole supermatrix, and each partition is written as a closed range, both ends included.
The model name in front of a RAxML line is the data type, DNA or AA. Replace it with the model you actually want, for example GTR+G or WAG+G, before passing the file to raxml-ng.
The example loads two alignments of the same four taxa: a 21 column fragment and an 18 column fragment. Merged they give a supermatrix of 4 sequences and 39 columns, withpart1 = 1-21 and part2 = 22-39, and no padding, because every taxon is present in both. Delete the Frog record from the second box and the merged Frog row keeps its first 21 columns and gains 18 gaps, while the warning names the taxon that was padded.
To join sequences head to tail into one long record rather than side by side across taxa, useconcatenate genes. To collect records from several FASTA files into one file without concatenating them, use combine FASTA.
Paste one aligned FASTA in each box. Records are matched by the first word of their header, joined in the order the alignments are given, and any sequence missing from an alignment is filled with gaps for the width of that partition. The result is one aligned FASTA plus a partition table that says where each gene starts and ends.
Because a supermatrix has to stay rectangular: every row must be the same width or it is no longer an alignment. Filling the missing partition with gaps is the standard treatment, and phylogenetic programs handle it as missing data. It is still worth knowing which taxa are padded, so the count and the names are reported.
Save it next to the alignment and pass it to the program with the flag that takes a partition file: raxml-ng --model partitions.txt, iqtree -p partitions.nex, or the equivalent. Each partition then gets its own substitution model and its own rates, which is the point of keeping the genes apart instead of treating the supermatrix as one long sequence.
On the first whitespace-separated word of the header, so ">Homo_sapiens COI gene" and ">Homo_sapiens 16S" match. Everything after that first word is dropped from the merged header. Matching is case sensitive and exact, so a trailing underscore or a different spelling makes two separate rows; the tool lists names that are not in every alignment so those mistakes are visible.
Yes. Use "Add an alignment" for a third, fourth and so on. They are concatenated left to right in the order shown, and the partition table follows that order.