#' plot.taxonsampling
#'
#' S3 method for plotting _taxonsampling_ objects output by [run_TS()]).
#'
#' @param x list object of class _taxonsampling_
#' (generated by [run_TS()])
#' @param ... other parameters to be passed down to specific
#' plot functions (currently unused)
#'
#' @return Nothing (called for side effects)
#'
#' @method plot taxonsampling
#'
#' @export
#'
plot.taxonsampling <- function(x, ...)
{
if(!("outputIDs" %in% names(x))){
warning("outputIDs object not found in input list.")
invisible(FALSE)
}
nodes <- x$nodes[x$nodes$id %in% x$outputIDs, ]
nodes$pathString <- sapply(
as.list(nodes$id),
function(ppi){
y <- ppi
while(y != x$ts.params$taxon){
y <- x$nodes$parent[x$nodes$id == y]
ppi <- c(ppi, y)
}
paste(ppi[length(ppi):1], collapse = "|")
})
nodes <- data.tree::as.Node(nodes, pathDelimiter = "|")
nodes <- data.tree::ToListExplicit(nodes, unname = TRUE)
return(networkD3::radialNetwork(nodes, fontSize = 8,
nodeColour = "#00aaaa55",
nodeStroke = "#00aaaa55"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.