Skip to contents

This function computes the codon distance matrix based on the weighted Manhattan distance between codons estimated with function codon_dist.

Usage

codon_dist_matrix(
  genetic_code = "1",
  group = c("Z4", "Z5"),
  weight = NULL,
  cube = c("ACGT", "AGCT", "TCGA", "TGCA", "CATG", "GTAC", "CTAG", "GATC", "ACTG",
    "ATCG", "GTCA", "GCTA", "CAGT", "TAGC", "TGAC", "CGAT", "AGTC", "ATGC", "CGTA",
    "CTGA", "GACT", "GCAT", "TACG", "TCAG"),
  output = c("list", "vector", "dist"),
  num.cores = 1L
)

Arguments

genetic_code

A single string that uniquely identifies the genetic code to extract. Should be one of the values in the id or name2 columns of GENETIC_CODE_TABLE.

group

A character string denoting the group representation for the given codon sequence as shown in reference (2-3).

weight

A numerical vector of weights to compute weighted Manhattan distance between codons. If \(weight = NULL\), then \(weight = (1/4,1,1/16)\) for \(group =\) "Z4" and \(weight = (1/5,1,1/25)\) for \(group =\) "Z5" (see codon_dist).

cube

A character string denoting one of the 24 Genetic-code cubes, as given in references (2-3).

output

Format of the returned lower triangular matrix: as a list of 63 elements (labeled) or as a labeled vector using codons as labels.

num.cores

An integer to setup the number of parallel workers via makeCluster.

Value

A lower triangular matrix excluding the diagonal.

Details

By construction, a distance matrix is a symmetric matrix. Hence, the knowledge of lower triangular matrix is enough for its application to any downstream analysis.

See also

Examples

## The distance matrix for codons for the Invertebrate Mitochondrial,
## cube "TGCA" with base-triplet represented on the group "Z5". Each 
## coordinate from each returned numerical vector corresponds to the 
## distance between codons given in the coordinate name. 
x <- codon_dist_matrix(genetic_code = "5", cube = "TGCA", group = "Z5",
                    output = "vector")
x[seq(61, 63)]
#> TTT.GGC TTT.GGA TTT.GGG 
#>    1.28    1.32    1.24