calc_dmid: Calculates the Distance Matrix Information Density, which is...

Description Usage Arguments Value Examples

Description

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

Usage

1
calc_dmid(distance_matrix)

Arguments

distance_matrix

a distance matrix, a numeric matrix.

Value

the DMID

Examples

 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)

richelbilderbeek/wiritttea documentation built on May 27, 2019, 8:02 a.m.