R/maxDist.R

maxDist <- function(s, tolerance = 0) {
  d <- dist.dna(s, model = "N", pairwise.deletion = TRUE,
                as.matrix = TRUE)
  diag(d) <- NA
  min.dist <- min(d, na.rm = TRUE)
  if ( min.dist > tolerance ) out <- min.dist
  else {
    diag(d) <- 0
    id <- which.min(apply(d, 2, sum, na.rm = TRUE))
    id <- d[, id] <= tolerance
    names(id) <- NULL
    out <- if ( any(id) ) s[id, ]
  }
  out
}

getMaxDist <- function(s, tolerance = 0) {
  d <- dist.dna(s, model = "N", pairwise.deletion = TRUE,
                as.matrix = TRUE)
  max(d, na.rm = TRUE)
}

Try the megaptera package in your browser

Any scripts or data that you put into this service are public.

megaptera documentation built on Jan. 15, 2017, 11:19 p.m.