Learn R Programming

biogram (version 1.6.3)

calc_ed: Calculate encoding distance

Description

Computes the encoding distance between two encodings.

Usage

calc_ed(a, b, prop = NULL, measure)

Arguments

a

encoding (see validate_encoding for more information about the required structure of encoding).

b

encoding to which a should be compared. Must have equal number of groups or less than a. Both a and b must have the the same number of elements.

prop

matrix of physicochemical properties to normalize the encoding distance. Each column should represent properties of the single amino acid/nucleotide. If NULL, encoding distance is not normalized.

measure

character vector of length one specifying the measure. Currently avaible measures are "pi" (partition index) and "si" (similarity index). If the parameter prop is supplied, the encoding distance is normalized by the factor equal to the sum of distances for each group in a and the closest group in b. The position of a group is defined as the mean value of properties of amino acids or nucleotides belonging the group.

See the package vignette for more details.

Value

an encoding distance.

See Also

calc_si: compute the similarity index of two encodings. encoding2df: converts an encoding to a data frame. validate_encoding: validate a structure of an encoding.

Examples

Run this code
# NOT RUN {
# calculate encoding distance between two encodings of amino acids
aa1 = list(`1` = c("g", "a", "p", "v", "m", "l", "i"), 
           `2` = c("k", "h"), 
           `3` = c("d", "e"), 
           `4` = c("f", "r", "w", "y", "s", "t", "c", "n", "q"))

aa2 = list(`1` = c("g", "a", "p", "v", "m", "l", "q"), 
           `2` = c("k", "h", "d", "e", "i"), 
           `3` = c("f", "r", "w", "y", "s", "t", "c", "n"))
calc_ed(aa1, aa2, measure = "pi") 
    
# the encoding distance between two identical encodings is 0
calc_ed(aa1, aa1, measure = "pi") 
# }

Run the code above in your browser using DataLab