Skip to content

Genetic Distance

Compute pairwise genetic distances between samples for each alignment. The app writes a distance matrix for every alignment and a summary table across all alignments. It can also average the distances within and between populations or species.

  1. Select Alignments in the navigation bar A.
  2. Open Compute genetic distances from the tool list on wide windows, or select the tool name B at the top of the page to switch tools.
  3. Add the input files C with Browse files, Browse folder, or Open archive. SEGUI searches a folder and its subfolders for files that match the tool's input format. See file input for mobile options.
  4. Select the input format (optional) and the data type. The data type must be DNA or AA.
  5. Select the distance model, the matrix layout, and the diagonal value.
  6. Select how to group samples into populations or species (optional). See Groups.
  7. Select Browse under Select output directory to choose the output folder. On phones and tablets, enter a Directory name instead; SEGUI saves it in the app's own folder.
  8. Add a prefix for the output files (optional).
  9. Turn on Long-format tables to also write the distances of all alignments as one table (optional).
  10. Select the run button D, labeled Compute, to start the task.

For samples named Genus_species_ID, such as Rattus_rattus_FMNH1:

  1. In Group samples, select Detect from sample names, then click Detect groups. The app switches to Split sample names with _ as the delimiter and 2 fields to keep, and lists each species with its number of samples.
  2. Turn on Long-format tables in the output card.
  3. Click Compute. Open distance_group_mean.csv for the mean distances within and between species across all alignments, or distance_pairwise_long.csv for every pair of samples.
ModelData type
Uncorrected p-distanceDNA and AA
Jukes-Cantor (JC69)DNA and AA
Kimura 2-parameter (K2P)DNA only
Tamura-Nei (TN93)DNA only
PoissonAA only

The app shows an error if the model does not match the data type.

The distance matrix is symmetric, so each value appears twice. Select Lower triangle or Upper triangle to write only one half, as is common for tables in publications. The default is the full matrix.

The diagonal holds the distance of each sample to itself. Write Zero (the default), leave it Blank, or write NA.

With groups, the option also sets the diagonal of the group mean matrices and adds two choices:

  • Mean within the group (the default with groups): the mean distance within each group.
  • Highest within the group: the highest distance between two samples of the group.

Both are NA for a group with one sample, and the sample matrices hold zero on the diagonal. Zero, Blank, and NA apply to both the sample and group matrices.

When samples are individuals, group them into populations or species to also compute the mean distance within each group and between each pair of groups. Select a method in Group samples:

MethodGroups by
No groupingSamples are not grouped (the default).
Detect from sample namesA delimiter and number of fields found from the sample names.
Split sample namesThe first parts of each name split on a Delimiter. With _ and 2 in Fields to keep, Rattus_rattus_FMNH1 belongs to Rattus_rattus.
Regular expressionThe first capture group of the pattern, or the whole match if it has no capture group.
Group file (CSV or TSV)A .csv or .tsv file with a header row, followed by one sample and its group per row.

Click Preview groups to check the groups before computing. The preview lists each group with its number of samples, and warns about samples that match no group. These samples are left out of the group means.

With Detect from sample names, click Detect groups. The app picks the delimiter and number of fields that give the most groups while pooling at least 80% of samples with another sample, so Genus_species_ID names are grouped by species. It then switches to Split sample names with these values filled in, so you can adjust them. For example, for Genus_species_population_ID names, detection gives populations. Change Fields to keep to 2 to group by species. See the CLI guide for the detection rules.

The output directory contains a per_locus folder with one distance matrix per alignment, named after the input file, and a distance_summary.csv file with one row per alignment. With a prefix, the files start with the prefix instead of distance, such as <prefix>_summary.csv. See the CLI guide for the summary columns.

With groups, the app also writes:

  • per_locus_group/: one group matrix per alignment. By default, the diagonal holds the mean distance within each group, and the other cells hold the mean between two groups. A within-group mean is NA if the group has one sample in the alignment.
  • distance_group_mean.csv: group means pooled over every sample pair of every alignment, so alignments with more pairs count more.
  • distance_group_pairs.csv: the number of pairs behind each pooled mean.

The Matrix and Diagonal options apply to the group matrices too. The diagonal of distance_group_pairs.csv always holds the number of within-group pairs.

With Long-format tables on, the app also writes:

  • distance_pairwise_long.csv: one row per sample pair per alignment, with the locus, the two samples, their groups (with groups only), the number of compared sites, and the distance.
  • distance_group_long.csv (with groups only): one row per pair of groups per alignment, with the number of pairs, mean, standard deviation, minimum, and maximum. Rows with all as the locus hold the pooled values.

See the CLI guide for all columns.