Skip to contents

Computes a 20x20 symmetric matrix of pairwise Grantham distances between amino acids.

Usage

generate_grantham_matrix()

Value

A 20x20 numeric matrix with row and column names corresponding to the one-letter codes for amino acids (lowercase), where each cell contains the Grantham distance between the corresponding pair of amino acids.

Details

The matrix uses the amino acid order from the Grantham distance table on Wikipedia, based on Grantham (1984) [DOI:10.1126/science.185.4154.862]. These distances reflect differences in composition, polarity, and molecular volume between amino acid side chains.

This function is optimized for speed and runs quickly enough that regenerating the matrix on each call is faster than saving/loading from disk.

References

- Grantham (1984) [DOI:10.1126/science.185.4154.862]

Examples

grantham_matrix <- generate_grantham_matrix()
grantham_matrix["a", "v"]
#> [1] 64