Skip to content

Instantly share code, notes, and snippets.

@zkamvar
Created January 10, 2017 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zkamvar/309c201d623a73c997ea0f53d5668984 to your computer and use it in GitHub Desktop.
Save zkamvar/309c201d623a73c997ea0f53d5668984 to your computer and use it in GitHub Desktop.
Modify default aboot plotting function in R
# poppr.plot.phylo definition:
# https://github.com/grunwaldlab/poppr/blob/9170398f6552f27ab69b294172c97c8ee7a97ce0/R/internal.r#L1529-L1545
# You can also get it by simply typing poppr:::poppr.plot.phylo in your R console
library("ape")
library("phangorn")
poppr.plot.phylo <- function(tree, type = "nj", root = FALSE){
barlen <- min(median(tree$edge.length), 0.1)
if (barlen < 0.1) barlen <- 0.01
if (!root && type != "upgma"){
tree <- ladderize(tree)
}
nodelabs <- round(tree$node.label, 2)
plot.phylo(tree, cex = 1, font = 2, adj = 0, xpd = TRUE,
label.offset = 0.0125)
nodelabels(nodelabs, adj = c(1.3, -0.5), frame = "n", cex = 0.8,
font = 3, xpd = TRUE)
if (type != "upgma"){
add.scale.bar(lwd = 5, length = barlen)
} else {
axisPhylo(3)
}
}
assignInNamespace("poppr.plot.phylo", poppr.plot.phylo, ns = "poppr")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment