R/pbray.R

Defines functions pbray

Documented in pbray

pbray <- function(allComm, subComm, tolower = TRUE) {
  allComm <- as.matrix(allComm)
  subComm <- as.matrix(subComm)
  nr <- nrow(allComm)
  mat <- matrix(0, nrow = nr, ncol = nr)
  dimnames(mat) <- list(rownames(allComm),rownames(allComm))
  rsum = rowSums(allComm)
  denominator = as.dist(outer(rsum, rsum, FUN="+"))
  numerator = dist(subComm, method = 'minkowski', p =1) ## will cal |xi -yi|
  mat = numerator/denominator
  
  distmatrix <- as.dist(mat)
  if(!tolower) distmatrix <- as.matrix(distmatrix)
  invisible(distmatrix)
}

Try the otuSummary package in your browser

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

otuSummary documentation built on Sept. 8, 2023, 6:05 p.m.