Introduction to phylorug

What problem does phylorug solve?

Phylogenetic studies routinely analyse the same group of taxa in several ways: with different inference methods (maximum likelihood, Bayesian inference, parsimony, multispecies coalescent) run in different programs (e.g. IQ-TREE, MrBayes, TNT, ASTRAL), different data types (UCEs, transcriptomes, whole genomes) and different models (site-homogeneous, site-heterogeneous). Each analysis yields its own tree. The trees may differ in topology, a problem known as phylogenomic incongruence (Steenwyk et al., 2023), and they report nodal support with different metrics and formats.

Comparing these trees side by side is tedious and time-consuming. For every clade, one has to find it in each tree, check whether it is there and read its support value. The work grows quickly with the size of the study: the Culicomorpha example below, with 43 taxa and 10 analyses, already needs 378 such checks (42 clades in nine comparison trees).

A convenient way to make such comparisons is the phylogenetic rug plot: a small grid drawn at a node of a reference tree, with one cell per analysis. It gives a node-level view of agreement among the analyses; at a glance, it shows whether the clade is recovered by every analysis or only by some and, when the cells are shaded, how strong the node support is in each. However, building rug plots by hand is slow and error-prone. Each cell has to be scored by checking the clade in one tree, and each grid has to be drawn and placed on its node. Earlier programs automated part of this process (see Brief history), but to our knowledge no current tool or R package draws rug plots directly on a phylogenetic tree.

phylorug fills this gap in R. It compares any number of phylogenetic trees clade by clade against one reference tree (the backbone), records whether each tree recovers each clade and with what support, and draws a rug plot at every internal node of the backbone. Each cell stands for one analysis; its colour shows whether that analysis recovered the clade and, in support mode, how strongly it supported it. Support values from different programs (UFBoot2, SH-aLRT, posterior probability, ASTRAL LPP) are each binned against thresholds for their own metric rather than forced onto one scale. Thus, a single figure shows node by node where the analyses agree and where they conflict (e.g. between concatenation and coalescent analyses). The figure is ready for publication: it carries its own legends and an optional scale bar, and can be written directly to a PDF file that stays editable in vector editors such as Inkscape or Adobe Illustrator. phylorug can also serve as a general-purpose tool for comparing phylogenetic trees, whatever method or program produced them.

Brief history

The history of phylogenetic rug plots dates back to Wheeler (1995). To test how sensitive a phylogenetic result is to the analysis parameters, Wheeler aligned and analysed the same data under 36 combinations of gap-change and transversion-transition cost ratios, which together form the “analysis space”. For each of 15 groups, he recorded whether the group was monophyletic, unresolved or non-monophyletic under each combination, and drew the result as a small grid with one cell per combination. Wheeler called these grids “analysis space plots” and presented them as a separate gallery, one plot per group, which served as a lookup summary of Table 2 rather than being drawn on the nodes of a tree. Giribet (2003) later named the plots “Navajo rugs” and distinguished nodal support from nodal stability.

Sanders (2010) automated the plots with Cladescan, and Machado (2015) reimplemented the same analysis in YBYRÁ, which runs faster and uses less memory on large trees. Both programs record whether each clade occurs in each tree, but write every rug plot as a separate SVG graphic that has to be placed on the tree by hand in a vector editor. Cladescan is no longer available, and YBYRÁ has been archived.

Nodal support versus nodal stability

Giribet (2003) drew a distinction worth keeping in mind when reading a rug plot. Nodal support is how confident a single analysis is in a clade: bootstrap values, posterior probabilities, local posterior probabilities. Nodal stability is whether the clade turns up across different analytical strategies, data types and inference methods. The two can come apart: a clade may get 100% bootstrap under one model and collapse under all others, or carry only moderate support everywhere yet appear in every tree. Support is not stability, and reporting both says more about the robustness of a clade than either one alone.

phylorug shows both. In presence mode, a node gets a black dot if every analysis recovers the clade, or a rug plot showing which analyses recover it and which do not. This is nodal stability. In support mode, the same rug plot shades each cell by how strongly that analysis supports the clade, adding nodal support on top of stability. A dot in support mode is stricter: it marks a clade that every analysis recovers and rates as high support. A clade recovered everywhere but not uniformly high is drawn as a full rug plot instead, so support and stability stay visible as separate facts.

This tutorial covers the full workflow with plot_phylorug(). To draw the tree yourself with ape or phytools (coloured branches, painted clades, stochastic character maps) and add the rug plots on top, see the second tutorial, phylorug with ape and phytools (vignette("phylorug-phytools")).

Quick start

The fastest way to see phylorug in action is with the built-in sample_trees dataset, a 15-taxon subset of the beetle data (Montanaro et al., 2026), already rooted, pruned, and with tip labels translated to scientific names. Let’s start with attaching the package :

library(phylorug)

Load the data

sample_trees is a named list of five phylo objects, all sharing the same 15 taxa. Pick one as the backbone and use the rest as comparisons. In the original study 70p_uce is used as a backbone tree.

names(sample_trees)
#> [1] "70p_ASTRAL_partition_entropy" "70p_ASTRAL_uce"              
#> [3] "70p_ghost"                    "70p_partition_entropy"       
#> [5] "70p_uce"

backbone <- sample_trees[["70p_uce"]]
others   <- sample_trees[names(sample_trees) != "70p_uce"]

Check taxon consistency

check_taxa() compares the tip labels of the backbone against every comparison tree and reports any mismatches, missing taxa, extra taxa, or spelling differences. Running it before node_presence_matrix() is good practice, especially the first time you work with a new dataset. That said, node_presence_matrix() will stop with a clear error if a comparison tree is missing a backbone taxon, so if you already know your trees share the same taxa you can skip straight to building the matrix :

check_taxa(backbone, others)
#> All 4 comparison trees share the same 15 taxa as the backbone.
#> [1] TRUE
#> attr(,"diagnostics")
#>                     comparison    status n_taxa missing extra
#> 1 70p_ASTRAL_partition_entropy identical     15              
#> 2               70p_ASTRAL_uce identical     15              
#> 3                    70p_ghost identical     15              
#> 4        70p_partition_entropy identical     15

All trees share the same 15 taxa, so we can proceed. If a mismatch is reported the helper function prune_to_shared() can be used to get identical taxa set.

Build the node presence matrix

node_presence_matrix() is the core function of the pipeline. It walks every internal node of the backbone, checks whether each comparison tree recovered that clade, and records its support value.

It returns a named list: a presence matrix (1 = clade recovered, 0 = absent), plus one or more support matrices holding the support values pulled from each tree’s node labels. By default it reads the first value in each label. If your trees carry compound labels like 100/98 (SH-aLRT/UFBoot2 from IQ-TREE, for example), support_col picks which one to use: support_col = 1 for the first, support_col = 2 for the second, or support_col = c(1, 2) to pull both at once and makes two support matrices.

Two more arguments belong here. support_type is a named character vector telling node_presence_matrix() which support metric each comparison tree uses ("ufboot", "lpp", "sh_alrt", "posterior"). It gets stored with the result and plot_phylorug() reads it automatically in support mode, so you only declare it once, here.

pool_threshold matters when a comparison tree file holds several equally optimal trees (a pool) instead of one. It sets how many of them need to recover a clade before it counts as present: 1.0 (the default) a strict consensus; 0.5 needs just a majority; 0 skips the cutoff entirely and records the raw fraction that recovered it. sample_trees is all single phylo objects, no pools, so pool_threshold doesn’t come into play here.

We declare support_type now so plot_phylorug() can bin each tree’s support values against the right thresholds for its own metric. The IQ-TREE trees carry labels like 98.9/98 (SH-aLRT/UFBoot2). The figure uses the first value (support_idx = 1, the default), which is SH-aLRT, so the IQ-TREE trees are declared "sh_alrt". The ASTRAL trees carry local posterior probabilities ("lpp"):

support_type <- c(
  "70p_ASTRAL_partition_entropy" = "lpp",
  "70p_ASTRAL_uce"               = "lpp",
  "70p_ghost"                    = "sh_alrt",
  "70p_partition_entropy"        = "sh_alrt"
)
npm <- node_presence_matrix(backbone, others, support_col = c(1, 2), support_type = support_type)

The result is a named list. npm$presence is a matrix of 1s and 0s. npm$support_1 and npm$support_2 hold the raw support values. The list also carries support_type as an attribute, and all of these are what plot_phylorug() uses to draw the rug plots: presence determines whether a cell is filled or empty; support determines its colour.

Plot the rug plots

With the node presence matrix ready, plot_phylorug() draws the rug plots on the backbone. In its simplest form, all arguments are defaults: mode = "presence", dot_identical = TRUE (unanimous nodes get a black dot), legend = TRUE, show_support = TRUE (the backbone’s own support values are shown alongside the rug plots), and rug_position = "inside". phylorug fits the tree, the rug plots and both legends into the figure automatically. Here show_support = FALSE keeps this first figure to presence and absence only.

plot_phylorug(backbone, npm, show_support = FALSE)

For publication-quality output, setting file, width, and height is strongly recommended. All other arguments are worth exploring to fine-tune your figure, but these three matter most.

plot_phylorug(backbone, npm, file = "presence.pdf", width = 12, height = 8)

Support mode

Now switch to support mode to see how strongly each tree supports each clade. Cells are shaded by binned support strength, darker means stronger. Support values are binned against thresholds specific to their own metric: a tree with LPP 0.95 and a tree with LPP 0.65 are compared to LPP thresholds, while a tree carrying UFBoot2 values is binned against UFBoot2 thresholds independently. phylorug never cross-compares values from different support metrics, because LPP 0.95 and UFBoot2 95 do not measure the same thing despite looking numerically similar.

Since we already declared support_type when building the node presence matrix, plot_phylorug() reads it automatically from the stored attribute and applies the correct metric-specific thresholds.

If support_type is not declared, plot_phylorug() falls back to a universal threshold scale: values greater than 1 are divided by 100 to bring them onto a 0–1 scale, and all trees are binned against the same set of thresholds regardless of metric. This is a reasonable starting point for quick exploration, but declaring support_type is always preferred because it ensures each value is evaluated against the thresholds published for its own method.

plot_phylorug(
  backbone, npm,
  mode         = "support")

In support mode a dot carries more information than in presence mode. It marks a clade that every comparison analysis recovers and rates high support against its own metric’s thresholds. A clade recovered by every analysis but weaker in even one, or with no usable support value, is drawn as a rug plot instead, so a dot never hides uneven support. Because the rule uses the same thresholds that shade the cells, changing thresholds also changes which nodes earn a dot (see Customisation).

Reading the rug plot

The rug plot carries two legends. The position legend (top-left) maps each numbered cell to a tree. For example, cell 1 is the first tree, cell 2 the second, and so on. The threshold legend (top-right, support mode only) shows what each shade means.

At each node you will see one of these patterns:

In support mode, filled cells are coloured by how strongly each analysis supports the clade, in three tiers. With the default palette = "grey" these are black (high), mid grey (moderate) and pale grey (low), so a lighter cell always means weaker support. White means the clade was not recovered, and red means it was recovered but no support value could be parsed. Other palettes change the colours but not the tiers (see Colour palettes below). The thresholds shown below are the package defaults. Different fields and journals apply different cutoffs, so we recommend defining your own via the thresholds argument (see the Customisation section below):

Fine-tuning the figure

Dots in support mode follow the high-support rule described above (dot_on_high; see Customisation to turn them off). hide_unsupported = FALSE would draw all-white rug plots at nodes unique to the backbone; the default (TRUE) leaves them bare. cell_scale adjusts the size of each rug cell, rug_position controls whether rug plots sit toward the root ("inside"), toward the tips ("outside"), or on the node itself ("centre"). dot_cex scales the dot, and show_support = TRUE with support_label_cex and support_label_col overlays the backbone’s own support labels on the tree; each label is placed in the closest free spot around its node (support_label_pos = "auto") or under its branch (support_label_pos = "under"). cex and font are passed directly to the tree plotter. For publication output, add file = "output.pdf" along with width and height to produce a properly scaled figure.

# For publication output, add:
# file = "my_support_plot.pdf"
plot_phylorug(
  backbone, npm,
  width             = 6.5,
  height            = 5.8,
  mode              = "support",
  rug_position      = "inside",
  cell_scale        = 0.45,
  cex               = 0.90,
  font              = 3,
  dot_cex           = 1.3,
  show_support      = TRUE,
  support_label_col = "red",
  support_label_cex = 1
)

Working with real data: Culicomorpha

The built-in Culicomorpha dataset contains 10 phylogenomic analyses of 43 culicomorph taxa from eight families, plus three outgroups (Fu et al., 2025). The analyses cover partitioned IQ-TREE, PMSF, LG+C20+F+R and ASTRAL strategies on two data matrices.

Read the trees

read_trees() scans a directory for tree files and returns a named list:

tree_dir <- system.file("extdata", "culicomorpha", package = "phylorug")
trees    <- read_trees(tree_dir)
#> Read 10 analyses (10 trees) from: C:/Users/1/AppData/Local/Temp/RtmpOc1EzJ/Rinstd78597574cf/phylorug/extdata/culicomorpha
names(trees)
#>  [1] "Matrix1-kpi_ASTRAL"           "Matrix1-kpi_PMSF(H1.guide)"  
#>  [3] "Matrix1-kpi_PMSF(H2.guide)"   "Matrix1-kpi_partitioning"    
#>  [5] "Matrix1-smart_ASTRAL"         "Matrix1-smart_PMSF(H1.guide)"
#>  [7] "Matrix1-smart_PMSF(H2.guide)" "Matrix1-smart_partitioning"  
#>  [9] "Matrix1_LG_C20_F_R"           "Matrix2_partitioning"

Root and remove the outgroups

The Culicomorpha trees include three outgroup taxa from outside the infraorder: Phlebotomus chinensis and Clogmia albipunctata (Psychodidae) and Coboldia fuscipes (Scatopsidae). Root on all three, then drop them. The order matters, you must root while the outgroup tips are still present, because ape::root() needs to find them in the tree. Always add edgelabel = TRUE: it tells ape that the node labels are support values for branches, so they move with their branches when the tree is rerooted. Without it, support values end up on the wrong nodes, and the node that used to be the root gets an empty label (drawn as not computed):

trees <- lapply(trees, function(tr) {
  tr <- ape::root(tr, outgroup = c("Coboldia_fuscipes",
                                   "Phlebotomus_chinensis",
                                   "Clogmia_albipunctata"),
                  resolve.root = TRUE, edgelabel = TRUE)
  ape::drop.tip(tr, c("Coboldia_fuscipes",
                      "Phlebotomus_chinensis",
                      "Clogmia_albipunctata"))
})

The Culicomorpha trees already carry species names as tip labels, so no translation is needed here. For trees with specimen codes, see translate_tips() in the beetles example below.

Choose a backbone

Pick one analysis as the backbone. The remaining trees are comparisons:

backbone <- trees[["Matrix1-kpi_PMSF(H1.guide)"]]
others   <- trees[names(trees) != "Matrix1-kpi_PMSF(H1.guide)"]

Check taxon consistency

check_taxa(backbone, others)
#> All 9 comparison trees share the same 43 taxa as the backbone.
#> [1] TRUE
#> attr(,"diagnostics")
#>                     comparison    status n_taxa missing extra
#> 1           Matrix1-kpi_ASTRAL identical     43              
#> 2   Matrix1-kpi_PMSF(H2.guide) identical     43              
#> 3     Matrix1-kpi_partitioning identical     43              
#> 4         Matrix1-smart_ASTRAL identical     43              
#> 5 Matrix1-smart_PMSF(H1.guide) identical     43              
#> 6 Matrix1-smart_PMSF(H2.guide) identical     43              
#> 7   Matrix1-smart_partitioning identical     43              
#> 8           Matrix1_LG_C20_F_R identical     43              
#> 9         Matrix2_partitioning identical     43

Build the matrix and plot

support_type <- c(
  "Matrix1-kpi_ASTRAL"            = "lpp",
  "Matrix1-smart_ASTRAL"          = "lpp",
  "Matrix1-kpi_partitioning"      = "sh_alrt",
  "Matrix1-kpi_PMSF(H2.guide)"    = "sh_alrt",
  "Matrix1_LG_C20_F_R"            = "sh_alrt",
  "Matrix1-smart_partitioning"    = "sh_alrt",
  "Matrix1-smart_PMSF(H1.guide)"  = "sh_alrt",
  "Matrix1-smart_PMSF(H2.guide)"  = "sh_alrt",
  "Matrix2_partitioning"          = "sh_alrt"
)
npm <- node_presence_matrix(backbone, others, support_type = support_type)

Presence mode

plot_phylorug(backbone, npm, show_support = FALSE)

With 9 comparison trees, phylorug automatically arranges the rug grid (3 columns by 3 rows in this case). The position legend maps each cell position to an analysis name.

Support mode

Here we use show_support = TRUE to overlay the backbone’s own node labels in red for cross-referencing, with show_support_idx = 1 to display only the first support metric instead of the full compound label (e.g. showing 100 rather than 100/100). All-white rug plots are hidden by default, so only contested and stable nodes remain visible.

plot_phylorug(backbone, npm,
              mode               = "support",
              show_support       = TRUE,
              show_support_idx   = 1,
              support_label_cex  = 1,
              support_label_col  = "red",
              cell_scale         = 0.45,
              legend_cex         = 1,
              rug_position       = "centre",
              align.tip.label    = TRUE)

What the rug plots reveal

The rug plots immediately separate stable from contested regions of the Culicomorpha tree. Most nodes carry black dots, meaning every comparison analysis recovered the clade and rated it high support. All family-level groupings such as Culicidae, Chironomidae, Ceratopogonidae, and the Simuliidae + Thaumaleidae clade, show complete agreement across every inference method and dataset.

The clearest conflict is at the node uniting Chironomidae and Ceratopogonidae, the most contentious relationship in culicomorph systematics. Eight of the nine comparison analyses recover this clade: six with high support and two (the ASTRAL and PMSF(H2) analyses of the kpi-trimmed matrix) with moderate support. The partitioned site-homogeneous analysis of the same matrix (Matrix1-kpi_partitioning) does not recover it. Fu et al. (2025) report this topology as their hypothesis H2, which their topology tests rejected. The rug plot shows the pattern without opening a single tree file.

The same analysis is also the only one that does not recover Culicoidea (Dixidae plus the other three culicoid families). A second pattern comes from Matrix2_partitioning, the only analysis of the second data matrix: it does not recover six clades within Chironomidae, nor the clade uniting Culicoidea with Simuliidae + Thaumaleidae, although every analysis of the first matrix recovers them. Near the tips, Nilodorum + Dicrotendipes (backbone SH-aLRT 75.9) is recovered by only five of the nine analyses, and one of them (Matrix1_LG_C20_F_R) gives it low support.

This is the core value of phylorug: patterns that required opening 10 separate tree files side by side in the original study are condensed onto a single figure. A reader can immediately see which nodes are robust to analytical choice and which deserve further investigation.

Full pipeline: beetles with tip translation

The beetle dataset ships with phylorug in inst/extdata/. It contains two sets of trees, a 43-taxon subset of Montanaro et al. (2026) representing the subtribe Onthophagina sensu lato: beetles_50p/ and beetles_70p/, each with 5 independent analyses (45 tips including 2 outgroups) built from UCE loci retained at different completeness thresholds (50% and 70%). The two datasets produce slightly different topologies, making them a good test case for exploring how data filtering affects clade recovery. For this vignette we use the 70p set, but users are encouraged to try both. Unlike the Culicomorpha trees, these trees store specimen codes as tip labels (e.g., "OntauST002" rather than a species name), so this example adds one extra step: translating tip labels using a lookup table before building the rug plots.

Read the trees

tree_dir <- system.file("extdata", "beetles_70p", package = "phylorug")
trees    <- read_trees(tree_dir)
#> Read 5 analyses (5 trees) from: C:/Users/1/AppData/Local/Temp/RtmpOc1EzJ/Rinstd78597574cf/phylorug/extdata/beetles_70p
names(trees)
#> [1] "70p_ASTRAL_partition_entropy" "70p_ASTRAL_uce"              
#> [3] "70p_ghost"                    "70p_partition_entropy"       
#> [5] "70p_uce"

Root and drop outgroups

The beetle trees include two outgroup taxa, NicorbUCE and NicvesUCE. We will root on them first, then drop them. As before, rooting must happen while the outgroup tips are still in the tree, with edgelabel = TRUE.

trees <- lapply(trees, function(tr) {
  tr <- ape::root(tr, outgroup = c("NicorbUCE", "NicvesUCE"),
                  resolve.root = TRUE, edgelabel = TRUE)
  ape::drop.tip(tr, c("NicorbUCE", "NicvesUCE"))
})

Translate tip labels

The trees still carry specimen codes at this point. A CSV file biogeo.csv included with the package maps each code to its species name. Let’s load it and check the first few rows:

biogeo_path <- system.file("extdata", "beetles_70p", "biogeo.csv",
                           package = "phylorug")
biogeo <- read.csv(biogeo_path)
head(biogeo)
#>   specimen_code                                    species_name
#> 1   STL10208208                    Amietina_larrochei__STL10208
#> 2     AmppriUCE              Amphistomus_primonactus_Amppri_UCE
#> 3    STL1009595                   Anonychonitis_freyi__STL10095
#> 4   Anop1COL892                         Anoplostethus_sp_COL892
#> 5    ApimmST003                         Aphodius_immundus_ST003
#> 6   STL10140140 Apotolamprus_aff_ambohitsitondronensi__STL10140

Now let’s translate. The ordering rule from earlier applies here. First root and drop outgroups before translating, because translate_tips() replaces the original codes and ape::root() would no longer find "NicorbUCE" after translation.

trees <- translate_tips(trees, biogeo,
                        from_col = "specimen_code",
                        to_col   = "species_name")
#> 70p_ASTRAL_partition_entropy: 43 tips translated, 0 unchanged
#> 70p_ASTRAL_uce: 43 tips translated, 0 unchanged
#> 70p_ghost: 43 tips translated, 0 unchanged
#> 70p_partition_entropy: 43 tips translated, 0 unchanged
#> 70p_uce: 43 tips translated, 0 unchanged

Choose a backbone and check taxa

backbone <- trees[["70p_uce"]]
others   <- trees[names(trees) != "70p_uce"]
check_taxa(backbone, others)
#> All 4 comparison trees share the same 43 taxa as the backbone.
#> [1] TRUE
#> attr(,"diagnostics")
#>                     comparison    status n_taxa missing extra
#> 1 70p_ASTRAL_partition_entropy identical     43              
#> 2               70p_ASTRAL_uce identical     43              
#> 3                    70p_ghost identical     43              
#> 4        70p_partition_entropy identical     43

Build the node presence matrix

The beetle trees carry compound node labels (SH-aLRT/UFBoot2 for IQ-TREE trees). Extract both support values with support_col = c(1, 2). As before, the rug plots use the first value, SH-aLRT:

support_type <- c(
  "70p_partition_entropy"        = "sh_alrt",
  "70p_ghost"                    = "sh_alrt",
  "70p_ASTRAL_uce"               = "lpp",
  "70p_ASTRAL_partition_entropy" = "lpp"
)
npm <- node_presence_matrix(backbone, others, support_col = c(1, 2),
                            support_type = support_type)

Presence mode

At 43 taxa the tree is comfortably readable. All-white rug plots are hidden by default, and writing to a file with explicit width and height is strongly recommended to avoid the distortion that GUI windows introduce.

plot_phylorug(backbone, npm, show_support = FALSE, legend =2)

Support mode

With 43 taxa, the canvas still fits a single page. The backbone tree carries compound IQ-TREE labels in the format SH-aLRT/UFBoot2 (e.g., 99.9/97). The show_support_idx argument controls which part of that label appears on the tree: show_support_idx = 1 shows only SH-aLRT, show_support_idx = 2 shows only UFBoot2, and a named vector like c("1" = "sh_alrt", "2" = "ufboot") shows both and names them in the legend. Here we use the named form so the legend identifies each metric. We also use the colour palette "classic" and centre the rug plots on the nodes; each support label is then placed in the free space next to its node, so it never covers a cell:

# For publication output, add:
# file = "beetles_support.pdf"
# height = 12 
# width = 10
plot_phylorug(
  backbone,
  npm,
  mode               = "support",
  show_support       = TRUE,
  show_support_idx   = c("1" = "sh_alrt", "2" = "ufboot"),
  support_label_cex  = 0.8,
  cell_scale         = 0.5,
  cex                = 0.7,
  legend_cex         = 2,
  palette            = "classic",
  rug_position       = "centre",
  align.tip.label    = TRUE
)

What the rug plots reveal

The 43-taxon subset corresponds exactly to the subtribe Onthophagina sensu lato as defined by Montanaro et al. (2026, Fig. 2). Above we applied both presence mode and support mode to the same dataset. Presence mode shows which analyses recovered each clade; support mode goes further by showing how strongly each analysis backs each node.

Half of the 42 nodes carry black dots: all four comparison analyses recover the clade and rate it high support. Support mode adds most at the other half, where not all analyses recover the clade or they support it unevenly. It also shows that support is not stability: 11 of the 36 clades with full backbone support (SH-aLRT/UFBoot2 100/100) are missing from at least one comparison analysis.

The clade containing species of Caccobius, Cleptocaccobius, and Onthophagus (backbone support 43.7/64 SH-aLRT/UFBoot2) is the most weakly supported node in the entire subtribe. No dot or rug plot appears at this node, meaning none of the comparison analyses recovered this clade. This confirms that the placement of Caccobius relative to Onthophagus is unresolved across methods.

Weak support and partial recovery are also visible deeper within the Onthophagus radiation. The node uniting O. giraffa + O. pilosus with O. bicavifrons + O. quadrimaculatus (backbone support 59.8/66) is recovered only by the two ASTRAL analyses, both with low support; the two IQ-TREE analyses do not recover it. Within this group the sister pair O. quadrimaculatus + O. bicavifrons is recovered with strong support only by the backbone and the partitioned IQ-TREE analysis; the GHOST analysis supports it weakly, while both ASTRAL trees fail to recover the clade entirely. This is a clear coalescent-versus-concatenation disagreement that support mode makes visible. In presence mode alone, this node would look the same as any other partially recovered clade.

The Phalops group (Kurtops, Hamonthophagus, Digitonthophagus, Phalops, and O. probus) at the base of Onthophagina is recovered as a clade by all five analyses. However, the relationships inside the group tell a different story. The rug plot at the node uniting Hamonthophagus with Digitonthophagus + Phalops + O. probus (backbone support 63.8/73) is not recovered by the partitioned IQ-TREE analysis and is only moderately supported by the partitioned ASTRAL analysis. One step deeper, the node grouping Digitonthophagus, Phalops, and O. probus (backbone support 99.9/97) also shows disagreement, high backbone support does not guarantee agreement across methods. Even the Digitonthophagus + Phalops pair (backbone support 100/100) is not recovered by the ASTRAL partitioned analysis. The Phalops group itself is stable, but the relationships among its members depend on the method.

These three cases: complete absence, partial weak recovery, and unanimous recovery with uncertain relationships within the group - capture different levels of conflict that support mode makes visible.

In support mode a black dot is a complete summary: the clade was recovered everywhere and every analysis has high support values. Nodes recovered everywhere but support is not uniformly high are drawn as rug plots. To draw the grid at every node, including those that would otherwise get a dot, set dot_on_high = FALSE.

Customisation

The remaining examples use the compact sample_trees dataset to demonstrate optional arguments. Reload the backbone and rebuild the node presence matrix:

backbone <- sample_trees[["70p_uce"]]
others   <- sample_trees[names(sample_trees) != "70p_uce"]
support_type <- c(
  "70p_ASTRAL_partition_entropy" = "lpp",
  "70p_ASTRAL_uce"               = "lpp",
  "70p_ghost"                    = "sh_alrt",
  "70p_partition_entropy"        = "sh_alrt"
)
npm <- node_presence_matrix(backbone, others, support_col = c(1, 2),
                            support_type = support_type)

Dots in support mode

By default a dot marks only the nodes that every analysis recovers and rates high. To draw the full grid at every node instead, set dot_on_high = FALSE. This is the most conservative option, since no dot can stand in for detail. It affects support mode only; in presence mode, dot_identical controls dots.

plot_phylorug(backbone, npm, mode = "support", dot_on_high = FALSE)

Colour palettes

palette sets the colours of the three support tiers. The default, "grey", prints well in black and white. "classic" uses green (high), blue (moderate), light grey (low) and yellow (not computed):

plot_phylorug(backbone, npm, mode = "support", palette = "classic")

Ten palettes are available: "grey", "classic", "okabe_ito" (safe for colour-blind readers), "brewer_set1", "brewer_paired", "brewer_dark2" (from RColorBrewer), "npg", "lancet", "nejm" (from ggsci) and "ggplot2_hue". In every palette, white means not recovered. Palettes only change colours in support mode; presence mode stays black and white.

plot_phylorug(backbone, npm, mode = "support", palette = "okabe_ito")

Rug plot position

rug_position = "centre" draws each rug plot on its node. With show_support = TRUE, each backbone support label takes the closest free spot around its node, clear of branches, rug plots, dots, tip labels and other labels (support_label_pos = "auto", the default). Set support_label_pos = "under" to put every label under its branch, just left of the node, without the collision check:

plot_phylorug(backbone, npm, mode = "support", palette = "classic",
              rug_position = "centre", show_support = TRUE,
              show_support_idx = 1)

Legend size and scale bar

legend_cex makes both legends larger (legend_cex = 1.5) or smaller (legend_cex = 0.8). scale_bar adds a branch-length scale bar in the bottom-left corner; its value is a length in the units of the tree’s branch lengths (substitutions per site for most trees):

plot_phylorug(backbone, npm, mode = "support", palette = "classic",
              rug_position = "centre", scale_bar = 0.02)

Universal thresholds (no support_type)

If support_type is not declared when building the node presence matrix, plot_phylorug() falls back to universal thresholds. Values greater than 1 (such as UFBoot2 scores on the 0-100 scale) are divided by 100 internally so that all trees are binned against the same 0-1 cutoffs (high >= 0.95, moderate >= 0.50) regardless of metric. The legend shows them as percentages (>=95, 50-94, <50):

npm_universal <- node_presence_matrix(backbone, others, support_col = c(1, 2))

plot_phylorug(
  backbone, npm_universal,
  mode = "support"
)
#> No `support_type` declared: values >1 are divided by 100 and binned against universal thresholds (0.95/0.50). To use metric-specific thresholds, pass `support_type` to `node_presence_matrix()`. To customise the universal thresholds, use the `thresholds` argument, e.g. `thresholds = list(universal = c(high = 0.95, moderate = 0.50))`.

Grid dimensions

By default, phylorug chooses a roughly square grid. Override with n_rows and n_cols:

# rug plots with a flattened grid
plot_phylorug(backbone, npm, n_rows = 1, n_cols = 4)

Tree appearance

plot_phylorug() passes additional arguments through ... to ape::plot.phylo(). Common options are cex (tip label size), font (3 for italic species names), and edge.width (branch thickness):

plot_phylorug(backbone, npm, cex = 0.6, font = 3, edge.width = 1.5)

On phylograms with unequal branch lengths, align.tip.label = TRUE lines up all tip labels in one column, joined to their branches by dotted lines. Rug plots, dots and support labels are unaffected:

plot_phylorug(backbone, npm, font = 3, align.tip.label = TRUE)

Large trees: draw a cladogram

In large trees (roughly 100 taxa or more), many internal branches are very short, so neighbouring nodes sit almost on top of each other and their rug plots and support labels crowd together. Drawing the backbone as a cladogram gives every node its own space. Pass two ape::plot.phylo() arguments: use.edge.length = FALSE ignores the branch lengths, and node.depth = 2 spaces the nodes evenly from root to tips. Rug plots compare clades, not branch lengths, so nothing is lost. The scale bar is left out automatically, because a cladogram has no branch-length scale. The same call on the sample data:

plot_phylorug(backbone, npm, mode = "support",
              show_support_idx = 1, use.edge.length = FALSE,
              support_label_cex = 1,
              cell_scale = 0.65,
              node.depth = 2)

Including the backbone

By default, the backbone does not occupy a cell in the rug plot (it trivially recovers every clade, since it defines the topology). Set include_backbone = TRUE to add it as cell 1:

plot_phylorug(backbone, npm, include_backbone = TRUE)

In support mode, pass the backbone’s support metric directly to include_backbone so it gets binned against the correct thresholds. The backbone is an IQ-TREE tree, and its first value is SH-aLRT:

plot_phylorug(backbone, npm,
              mode             = "support",
              include_backbone = "sh_alrt")

Custom thresholds

Override the default support bins with your own cutoffs:

my_thresholds <- list(
  sh_alrt = c(high = 90, moderate = 60),
  lpp     = c(high = 0.99, moderate = 0.70)
)

plot_phylorug(
  backbone, npm,
  mode       = "support",
  thresholds = my_thresholds
)

Each entry gives two cutoffs, high and moderate; a missing one stops early with an error naming it. Values at or above high are drawn as High, values from moderate up to high as Moderate, and values below moderate as Low. The high cutoff also decides which nodes earn a dot in support mode: lowering SH-aLRT’s from 80 to 75, for example, lets a node keep its dot when its only sub-threshold analysis scores 77.

Selecting which nodes to visualize

Sometimes you only want to look at a few clades, not the whole tree. nodes restricts the rug plots to just those, using the tip labels that define each clade:

plot_phylorug(
  backbone, npm,
  mode = "support",
  nodes = list(
    c("Gyronotus_pumilus_STL10003", "Scarabaeus_westwoodi_STL10034"),
    c("Nanos_dubitatus_STL5001", "Catharsius_sp._STL10033")
  )
)

Only these two clades get a dot or rug plot, every other node is left bare. If you already know the internal node ID, pass it directly as a numeric vector instead:

plot_phylorug(backbone, npm, nodes = 18)

But how do you find the right node ID in the first place? To find the nodes where analyses disagree, filter the presence matrix for rows with at least one 0, then look up the tips at each one:

disagree_ids <- as.integer(rownames(npm$presence))[
  apply(npm$presence, 1, function(row) any(row == 0))
]
disagree_ids
#> [1] 17 18 19 20 21 22 23

lapply(disagree_ids, function(id) ape::extract.clade(backbone, id)$tip.label)
#> [[1]]
#>  [1] "Gyronotus_pumilus_STL10003"        "Epactoides_hanski__STL29"         
#>  [3] "Nesosisyphus_pygmaeus__STL3"       "Sisyphus_muricatus__STL5"         
#>  [5] "Sisyphus_schaefferi_STL44"         "Nanos_dubitatus_STL5001"          
#>  [7] "Scarabaeus_westwoodi_STL10034"     "Kheper_nigroaeneus_STL10036"      
#>  [9] "Circellium_bacchus__STL10270"      "Epilissus_cuprarius_STL5011"      
#> [11] "Helictopleurus_fissicollis__STL28" "Catharsius_sp._STL10033"          
#> [13] "Copris_fidius_ST005"              
#> 
#> [[2]]
#> [1] "Gyronotus_pumilus_STL10003"        "Nanos_dubitatus_STL5001"          
#> [3] "Scarabaeus_westwoodi_STL10034"     "Kheper_nigroaeneus_STL10036"      
#> [5] "Circellium_bacchus__STL10270"      "Epilissus_cuprarius_STL5011"      
#> [7] "Helictopleurus_fissicollis__STL28" "Catharsius_sp._STL10033"          
#> [9] "Copris_fidius_ST005"              
#> 
#> [[3]]
#> [1] "Nanos_dubitatus_STL5001"           "Scarabaeus_westwoodi_STL10034"    
#> [3] "Kheper_nigroaeneus_STL10036"       "Circellium_bacchus__STL10270"     
#> [5] "Epilissus_cuprarius_STL5011"       "Helictopleurus_fissicollis__STL28"
#> [7] "Catharsius_sp._STL10033"           "Copris_fidius_ST005"              
#> 
#> [[4]]
#> [1] "Epilissus_cuprarius_STL5011"       "Helictopleurus_fissicollis__STL28"
#> [3] "Catharsius_sp._STL10033"           "Copris_fidius_ST005"              
#> 
#> [[5]]
#> [1] "Epilissus_cuprarius_STL5011"       "Helictopleurus_fissicollis__STL28"
#> [3] "Catharsius_sp._STL10033"          
#> 
#> [[6]]
#> [1] "Helictopleurus_fissicollis__STL28" "Catharsius_sp._STL10033"          
#> 
#> [[7]]
#> [1] "Nanos_dubitatus_STL5001"       "Scarabaeus_westwoodi_STL10034"
#> [3] "Kheper_nigroaeneus_STL10036"   "Circellium_bacchus__STL10270"

That shows you exactly which taxa sit at each disagreeing node, so you can pick the one you actually want to zoom in on with nodes, rather than guessing from a bare number.

Tips and best practices

Reroot with edgelabel = TRUE. ape::root(tree, outgroup, resolve.root = TRUE, edgelabel = TRUE) keeps each support value on its own branch. Without edgelabel = TRUE the values shift to other nodes.

Root and prune before translating. translate_tips() replaces specimen codes with species names. Once translated, you cannot match outgroup names for rooting. Always: (1) root, (2) drop outgroup, (3) translate.

One file = one analysis. read_trees() treats each file as one analysis. A single-tree file returns a phylo; a file with multiple equally optimal trees (as POY, TNT, or PAUP* write them) returns a multiPhylo scored as a pool.

Pool scoring in presence mode. By default (pool_threshold = 1.0), a clade counts as present only if every tree in the pool recovers it equivalent to a strict consensus. Set pool_threshold = 0.5 for majority rule, or pool_threshold = 0 to record the raw proportion (e.g., 2 out of 3 gives 0.67). A single-tree analysis always records 1 or 0.

Support mode is not available for pools. Node labels on tied optima are not independent support values. Meaningful support (bootstrap, posterior, SH-aLRT) comes only from explicit resampling or model-based procedures. To visualize support for a parsimony analysis, compute it externally (e.g., map bootstrap replicates onto the strict consensus, per Simmons and Freudenstein 2011), save the summarized tree, and pass that single file to phylorug. Passing raw tied optima into support mode would display arbitrary node labels as though they were support values, producing an artifactual rug plot.

Use prune_to_shared() when taxa differ. If a comparison tree is missing some backbone taxa, node_presence_matrix() will refuse to proceed (a clade containing a missing taxon cannot be evaluated). Run check_taxa() first to see the discrepancies, then prune_to_shared() to reduce all trees to their common taxa.

Large trees: draw a cladogram. Above about 100 taxa, add use.edge.length = FALSE, node.depth = 2 to plot_phylorug() so every node gets its own space (see “Large trees: draw a cladogram” under Customisation).

A dot means different things in the two modes. In presence mode it means “recovered by every analysis”. In support mode it additionally means “rated high by every analysis”. If you compare figures from the two modes, read the legend’s dot row, which states the rule in effect.

Coloured branches, mapped characters and phytools. plot_phylorug() draws the tree with ape::plot.phylo(). To colour branches, paint clades, or show stochastic character maps or phytools::contMap() under the rug plots, draw the tree yourself and add the rug plots with add_rug_plots(). See vignette("phylorug-phytools"), also online at https://mdrifathahamed.github.io/phylorug/articles/phylorug-phytools.html.

References