Description Usage Arguments Value Examples
Calculates the Distance Matrix Information Density, which is the proportion of non-diagonal elements in a distance matrix having non-zero and non-NA values
1 | calc_dmid(distance_matrix)
|
distance_matrix |
a distance matrix, a numeric matrix. |
the DMID
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Create a random phylogeny
set.seed(43)
n_taxa <- 5
phylogeny <- ape::rcoal(n = n_taxa)
# Create a random DNA alignment from the phylogeny
sequence_length <- 20 # nucleotides
mutation_rate <- 0.5 # mutations per nucleotide per unit of time
alignment_phydat <- phangorn::simSeq(
phylogeny, l = sequence_length, rate = mutation_rate)
alignment_dnabin <- ape::as.DNAbin(alignment_phydat)
# Create a distance matrix from the alignment
distance_matrix <- ape::dist.dna(
x = alignment_dnabin, model = "JC69", as.matrix = TRUE)
# Because all non-diagonal elements of the matrix are non-zero and
# non-NA, the DMID is 1.0
testit::assert(wiritttea::calc_dmid(distance_matrix) > 0.999)
testit::assert(wiritttea::calc_dmid(distance_matrix) < 1.001)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.