Sequence Transposition
Transpose locus alignments into per-sample sequence files. Locus alignments store one locus per file with a sequence for each sample. Transposing creates one file for each sample with a sequence for each locus. This is useful for creating sample-level reference sequences, for example, to map reads from each sample back to its own loci.
Quick example
Section titled “Quick example”Assume we have two alignment files in FASTA format. locus_1.fas:
>sample1AT-GC?>sample2ATTGCAAnd locus_2.fas, which does not have sample2:
>sample1--GGCCTo transpose the alignments, use the following command:
segul sequence transpose --dir alignments/SEGUL creates one file for each sample. Each sequence is named after the locus it comes from, and gaps (-) and missing data (?) are removed. Sequence-Transpose/sample1/sample1.fas:
>locus_1ATGC>locus_2GGCCSequence-Transpose/sample2/sample2.fas:
>locus_1ATTGCADetailed usage
Section titled “Detailed usage”Transposing sequences
Section titled “Transposing sequences”To transpose sequences, use the sequence transpose command:
segul sequence transpose --dir <alignment-dir>The locus name is the input file name without its extension. Samples missing from a locus are skipped for that locus, so each sample file only contains the loci where the sample is present.
For amino acid sequences, use the --datatype aa option:
segul sequence transpose --dir alignments/ --datatype aaSpecifying the output directory and format
Section titled “Specifying the output directory and format”By default, the output directory is Sequence-Transpose. Each sample is written to its own folder: Sequence-Transpose/<sample>/<sample>.fas. You can change the output directory name using the --output or -o option:
segul sequence transpose --dir alignments/ --output sample-referencesBecause gaps are removed, the output sequences are unaligned and are always in FASTA format. Use the --output-format or -F option to choose between sequential (fasta, the default) and interleaved (fasta-int) FASTA:
segul sequence transpose --dir alignments/ --output-format fasta-intMore ways to specify input files
Section titled “More ways to specify input files”You can also specify input files using the --input or -i option. For example:
segul sequence transpose --input alignments/*.fastaAll options
Section titled “All options”| 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 |
-F, --output-format |
Output format: fasta (default) or fasta-int |
-o, --output |
Output directory. Default: Sequence-Transpose |
--force |
Overwrite an existing output directory |
--log |
Log file path. Default: segul.log |
Copyright © 2026 H. Handika & J. A. Esselstyn.