nodeplotboot: Generates a function for labeling bootstrap values on a...

Description Usage Arguments Value See Also Examples

View source: R/plot-methods.R

Description

Is not a labeling function itself, but returns one. The returned function is specialized for labeling bootstrap values. Note that the function that is returned has two completely different arguments from the four listed here: the plot object already built by earlier steps in plot_tree, and the data.frame that contains the relevant plotting data for the nodes (especially x, y, label), respectively. See nodeplotdefault for a simpler example. The main purpose of this and nodeplotdefault is to provide a useful default function generator for arbitrary and bootstrap node labels, respectively, and also to act as examples of functions that can successfully interact with plot_tree to add node labels to the graphic.

Usage

1
nodeplotboot(highthresh=95L, lowcthresh=50L, size=2L, hjust=-0.2)

Arguments

highthresh

(Optional). A single integer between 0 and 100. Any bootstrap values above this threshold will be annotated as a black filled circle on the node, rather than the bootstrap percentage value itself.

lowcthresh

(Optional). A single integer between 0 and 100, less than highthresh. Any bootstrap values below this value will not be added to the graphic. Set to 0 or below to add all available values.

size

(Optional). Numeric. Should be positive. The size parameter used to control the text size of taxa labels. Default is 2. These are ggplot2 sizes.

hjust

(Optional). The horizontal justification of the node labels. Default is -0.2.

Value

A function that can add a bootstrap-values layer to the tree graphic. The values are represented in two ways; either as black filled circles indicating very high-confidence nodes, or the bootstrap value itself printed in small text next to the node on the tree.

See Also

nodeplotdefault

nodeplotblank

plot_tree

Examples

1
2

Example output

function (p, nodelabdf) 
{
    try(boot <- as(as(nodelabdf$label, "character"), "numeric"), 
        TRUE)
    goodboot = boot[complete.cases(boot)]
    if (!is(goodboot, "numeric") & length(goodboot) > 0) {
        stop("The node labels, phy_tree(physeq)$node.label, are not coercable to a numeric vector with any elements.")
    }
    if (all(goodboot >= 0 & goodboot <= 1)) {
        boot = round(boot, 2) * 100L
    }
    nodelabdf$boot = boot
    boottop = subset(nodelabdf, boot >= highthresh)
    bootmid = subset(nodelabdf, boot > lowcthresh & boot < highthresh)
    if (nrow(boottop) > 0L) {
        p = p + geom_point(mapping = aes(x = x, y = y), data = boottop, 
            na.rm = TRUE)
    }
    if (nrow(bootmid) > 0L) {
        bootmid$label = bootmid$boot
        p = nodeplotdefault(size, hjust)(p, bootmid)
    }
    return(p)
}
<environment: 0xd2da888>
function (p, nodelabdf) 
{
    try(boot <- as(as(nodelabdf$label, "character"), "numeric"), 
        TRUE)
    goodboot = boot[complete.cases(boot)]
    if (!is(goodboot, "numeric") & length(goodboot) > 0) {
        stop("The node labels, phy_tree(physeq)$node.label, are not coercable to a numeric vector with any elements.")
    }
    if (all(goodboot >= 0 & goodboot <= 1)) {
        boot = round(boot, 2) * 100L
    }
    nodelabdf$boot = boot
    boottop = subset(nodelabdf, boot >= highthresh)
    bootmid = subset(nodelabdf, boot > lowcthresh & boot < highthresh)
    if (nrow(boottop) > 0L) {
        p = p + geom_point(mapping = aes(x = x, y = y), data = boottop, 
            na.rm = TRUE)
    }
    if (nrow(bootmid) > 0L) {
        bootmid$label = bootmid$boot
        p = nodeplotdefault(size, hjust)(p, bootmid)
    }
    return(p)
}
<bytecode: 0xc94dd68>
<environment: 0xd2d5c58>

phyloseq documentation built on Nov. 8, 2020, 6:41 p.m.