# Values obtained from data-raw/sprDistances.R
nTrees <- 100L
nTip <- 50L

moves <- abs(outer(seq_len(nTrees), seq_len(nTrees), '-'))
distances <- TreeDistData::sprDistances
plotSequence <- TreeDistData::tdMethods[TreeDistData::tdMethods %in% names(distances)]

Plotter <- function (method) {
  dat <- as.matrix(distances[[method]])
  if (method %in% c('mast', 'masti')) dat <- nTip - dat
  dat.A <- dat[!is.na(dat)]
  moves.A <- moves[!is.na(dat)]
  col <- TreeDistData::TreeDistCol(method)
  boxplot(dat.A ~ moves.A, border = col, 
          ylab = TreeDistData::tdAbbrevs[method],
          xlab = 'SPR moves', axes= F)
  tau <- cor.test(dat.A, moves.A, method="kendall", use="pairwise")$estimate
  text(max(moves.A), min(dat.A), pos = 2, col = col,
       bquote(paste(tau['B']*' = ', .(signif(tau, 3)))))
legend('right', TreeDistData::tdAbbrevs[method], bty='n', col = col)
}

Figure

origPar <- par(mfrow = c(5, 5), mar = c(1, 0.1, 1, 0.1), oma = c(1, 1, 0, 0))
XX <- lapply(plotSequence, Plotter)
mtext("Tree distance \u2192", 2, outer = TRUE, cex = 0.8)
mtext("Number of SPR moves separating pair \u2192", 1, outer = TRUE, cex = 0.8)
par(origPar)

Tabulation

Tabler <- function (method) {
  dat <- as.matrix(distances[[method]])
  cor(dat[!is.na(dat)], moves[!is.na(dat)],
      method = "kendall", use = "pairwise")
}
tauB <- vapply(plotSequence, Tabler, double(1))
tauB <- abs(signif(tauB[order(abs(tauB), decreasing = TRUE)], 3))
tauB <- matrix(tauB, dimnames = list(TreeDistData::tdMdAbbrevs[names(tauB)], 
                                     "\u03c4<sub>B</sub>"))

TreeDistData::.TDDTable(DT::datatable, tauB)


ms609/TreeDistData documentation built on May 21, 2021, 6:53 a.m.