| Title: | Automated Deep-Time Phylogenetic Tree Collapsing and Visualization |
|---|---|
| Description: | Provides a single-function pipeline for automated collapsing and visualization of large phylogenetic trees with geological timescales. Automatically parses taxonomic labels from multiple formats (GTDB, Silva, NCBI, embedded, custom), identifies Most Recent Common Ancestors (MRCAs), assigns color-blind-safe palettes, executes batch collapsing with automatic nesting-aware ordering, integrates 'deeptime' geologic time scales with adaptive time breaks and unit switching, and manages smart legend layout. Supports special ancestral node identifiers (LUCA, LACA, LBCA) for highlighting key nodes in the tree of life. Provides external taxonomy file support for trees with incomplete or missing taxonomic labels. Features real-time logging with timestamps, step tracking, and multiple log levels. Includes comprehensive input validation for tree and sequence file formats. Reduces a 60-line manual workflow to a single function call while preserving full compatibility with the 'ggtree'/'deeptime' ecosystem. The visualization pipeline builds on 'ggtree' Yu et al. (2017) <doi:10.1111/2041-210X.12628>, 'deeptime' Gearty (2025) <doi:10.1080/20964471.2025.2537516>, and 'ape' Paradis and Schliep (2019) <doi:10.1093/bioinformatics/bty633>. |
| Authors: | Zeng Zichao [aut, cre] |
| Maintainer: | Zeng Zichao <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.5 |
| Built: | 2026-10-01 19:54:01 UTC |
| Source: | https://github.com/zengzichao/rclade |
Batch plot timetrees from a directory of tree files
batch_plot( input_dir, output_dir, pattern = "*.tre", format = "pdf", width = 14, height = 10, overwrite = "ask", ignore_malformed = FALSE, ... )batch_plot( input_dir, output_dir, pattern = "*.tre", format = "pdf", width = 14, height = 10, overwrite = "ask", ignore_malformed = FALSE, ... )
input_dir |
Input directory containing tree files |
output_dir |
Output directory for plots |
pattern |
File matching pattern (glob format, e.g., "*.tre") |
format |
Output format: "pdf", "png", "tiff", "svg", "eps" (default "pdf") |
width |
Output width in inches (default 14) |
height |
Output height in inches (default 10) |
overwrite |
Overwrite mode: "ask" (default), "force", or "no-clobber" |
ignore_malformed |
Logical. If |
... |
Additional arguments passed to plot_timetree() |
Invisibly returns list of success/failure status
Tests whether all tips belonging to a specified taxonomic group form a monophyletic clade in the tree.
check_monophyly( tree, group, rank, format = "auto", custom_patterns = NULL, quiet = FALSE, delimiter_mode = "reverse", taxonomy_levels = NULL )check_monophyly( tree, group, rank, format = "auto", custom_patterns = NULL, quiet = FALSE, delimiter_mode = "reverse", taxonomy_levels = NULL )
tree |
A |
group |
Character. The name of the taxonomic group to check
(e.g., |
rank |
Character. Taxonomic rank of the group. One of |
format |
Character. Taxonomy label format. One of |
custom_patterns |
Named list of regex patterns for custom format.
Required when |
quiet |
Logical. If |
delimiter_mode |
Character. Embedded (Format A) parsing strategy:
|
taxonomy_levels |
Custom taxonomy level configuration (list with codes and names).
Default: |
A list with components:
Logical. Whether the group is monophyletic.
Character. The group name.
Integer. Number of tips belonging to the group.
Integer or NULL. The MRCA node number, or NULL if the group has fewer than 2 tips.
Character vector. Tips in the MRCA clade that do not belong to the group (empty if monophyletic).
Group matching is case-insensitive. The query group and every
parsed Group label are lower-cased with tolower() at
comparison time (not during parsing) before matching, so
"Proteobacteria" and "proteobacteria" match the same clade.
parse_taxonomy itself preserves the original case of parsed
labels; the lower-casing applied here is local to this comparison and keeps
the two modules consistent about what a group name refers to.
data(example_tree) # Check if phylum P1 is monophyletic result <- check_monophyly(example_tree, "P1", rank = "phylum", format = "GTDB") if (result$is_monophyletic) { message("P1 is monophyletic!") } else { message("P1 is NOT monophyletic.") }data(example_tree) # Check if phylum P1 is monophyletic result <- check_monophyly(example_tree, "P1", rank = "phylum", format = "GTDB") if (result$is_monophyletic) { message("P1 is monophyletic!") } else { message("P1 is NOT monophyletic.") }
Tests whether the MRCA of the specified domains (identified by LUCA/LACA/LBCA) contains only tips from those domains (i.e., is monophyletic with respect to the target domains).
check_special_monophyly( tree, identifier, format = "auto", quiet = FALSE, delimiter_mode = "reverse", taxonomy_levels = NULL )check_special_monophyly( tree, identifier, format = "auto", quiet = FALSE, delimiter_mode = "reverse", taxonomy_levels = NULL )
tree |
A |
identifier |
Character. One of |
format |
Character. Taxonomy label format. Default: |
quiet |
Logical. If TRUE, suppress informational messages. Default: FALSE. |
delimiter_mode |
Character. Embedded parsing strategy: |
taxonomy_levels |
Custom taxonomy level configuration (list with codes and names).
Default: |
A list with components:
Logical. Whether the group is monophyletic.
Character. The identifier name.
Integer or NULL. The MRCA node number.
Integer. Number of tips in the target domains.
Integer. Number of outsider tips in the MRCA clade.
Character vector. Domains of outsider tips.
data(example_tree) result <- check_special_monophyly(example_tree, "LBCA") if (result$is_monophyletic) { message("LBCA is monophyletic!") }data(example_tree) result <- check_special_monophyly(example_tree, "LBCA") if (result$is_monophyletic) { message("LBCA is monophyletic!") }
Detects Format A (embedded: _d_Bacteria_p_...) or
Format B (semicolon-delimited: d__Bacteria;p__...).
detect_taxonomy_format(labels)detect_taxonomy_format(labels)
labels |
Character vector of tip labels |
Format name: "embedded", "GTDB", "Silva", "NCBI", or "unknown"
Detection and parsing here are heuristic regex passes, not a strict grammar. Known boundaries the caller must respect:
Underscores in names: under delimiter_mode = "reverse"
the pattern uses [^_]+?, so an underscore inside a taxon name
(e.g. _g_Clostridium_sensu_stricto_s_X) can be mis-read as a rank
separator. Names that contain underscores should use
delimiter_mode = "segment" (delimiter-to-delimiter extraction),
which preserves embedded underscores. For Format B (;-delimited)
underscores are safe.
Custom regex backtracking: caller-supplied
custom_patterns are inserted verbatim into the parser. Unbounded
repeating groups (e.g. (.+)+) can cause catastrophic
backtracking on adversarial labels. Patterns are rejected above the
200-character limit, but keep sub-patterns bounded and anchored.
Detection is content-based: detect_taxonomy_format
samples labels; a mixed or malformed corpus may return "unknown",
in which case the caller must fall back to an explicit format=.
GTDB requires a semicolon majority (M-B3): the GTDB rule
additionally requires that more than half of sampled labels contain a
semicolon. Accession-prefixed embedded labels with double-underscore
rank separators (e.g. GCA_xxx_d__Archaea_p__Nanoarchaeota)
satisfy the [dpcofgsk]__ pattern but contain no semicolons; they
are detected as "embedded" rather than misclassified as GTDB.
The embedded parsers also tolerate double-underscore separators.
A phylo object with 50 tips containing GTDB-format taxonomic labels
spanning 5 coded phyla (P1, P2, P3, P4, P5) and 10 coded classes (C1, ..., C10)
for demonstration and testing purposes. Branch lengths are in Ma (mega-annum).
This tree is fully bifurcating with proper monophyletic groups at all
taxonomic levels. All labels are artificial codes, not real taxon names.
data(example_tree)data(example_tree)
A phylo object with 50 tips and 49 internal nodes.
Simulated data for package demonstration.
Get supported file extensions
get_supported_extensions()get_supported_extensions()
Named list of supported extensions by category.
Parses taxonomic information from tip labels using the specified format and returns a data.frame of group assignments. Intended for use as a stable library API by external workflows (e.g., Snakemake/Nextflow).
parse_taxonomy( labels, rank, format = "auto", custom_patterns = NULL, taxonomy_levels = NULL, delimiter_mode = "reverse" )parse_taxonomy( labels, rank, format = "auto", custom_patterns = NULL, taxonomy_levels = NULL, delimiter_mode = "reverse" )
labels |
Character vector of tip labels |
rank |
Taxonomic rank (abbreviation or full name) |
format |
Format: "auto", "embedded", "GTDB", "Silva", "NCBI", "custom_rank", "custom_regex" |
custom_patterns |
Custom regex patterns (required when format = "custom_regex") |
taxonomy_levels |
Custom taxonomy level configuration (list with codes and names) |
delimiter_mode |
Character. Embedded parsing strategy: "reverse", "greedy", "segment". |
data.frame with columns: label, Group
The main entry point of Rclade. Takes a phylogenetic tree object or file path and produces a publication-ready visualization with automatic taxonomic collapsing, geological timescale integration, and smart legend layout.
plot_timetree( tree, tree_index = NULL, multi_tree_mode = "error", rank = "none", triangle_mode = "mixed", space_mode = "proportional", layout = "rectangular", angle = 360, color_palette = "viridis", color_mapping = NULL, line_width = 1, show_tip_labels = FALSE, tip_label_size = 2, add_timescale = TRUE, timescale_levels = c("eras", "eons"), unit = NULL, taxonomy_format = "auto", custom_patterns = NULL, taxonomy_file = NULL, taxonomy_file_sep = "auto", taxonomy_file_header = FALSE, taxonomy_file_priority = TRUE, taxonomy_source_priority = NULL, taxonomy_table_sep = ";", taxonomy_delimiter_mode = "reverse", legend_position = "bottom", legend_nrow = NULL, legend_ncol = NULL, legend_title = NULL, clade = NULL, strict = FALSE, groups = NULL, show_clade_label = FALSE, show_clade_count = TRUE, clade_label_offset = 50, clade_label_fontsize = 3, show_support = FALSE, support_threshold = 0.95, show_hpd = FALSE, hpd_color = "firebrick", geo_events = FALSE, timescale_version = "ICS 2023/02", main_title = NULL, sub_title = NULL, highlight = NULL, highlight_alpha = 0.2, theme_fun = theme_timetree, output = NULL, overwrite = "ask", width = 14, height = 10, taxonomy_levels = NULL, low_memory = FALSE, ignore_malformed = FALSE, ignore_branch_length = FALSE, color_rank = NULL, timescale_mode = "radial", timescale_position = "right", tree_start_position = "right", opts = NULL )plot_timetree( tree, tree_index = NULL, multi_tree_mode = "error", rank = "none", triangle_mode = "mixed", space_mode = "proportional", layout = "rectangular", angle = 360, color_palette = "viridis", color_mapping = NULL, line_width = 1, show_tip_labels = FALSE, tip_label_size = 2, add_timescale = TRUE, timescale_levels = c("eras", "eons"), unit = NULL, taxonomy_format = "auto", custom_patterns = NULL, taxonomy_file = NULL, taxonomy_file_sep = "auto", taxonomy_file_header = FALSE, taxonomy_file_priority = TRUE, taxonomy_source_priority = NULL, taxonomy_table_sep = ";", taxonomy_delimiter_mode = "reverse", legend_position = "bottom", legend_nrow = NULL, legend_ncol = NULL, legend_title = NULL, clade = NULL, strict = FALSE, groups = NULL, show_clade_label = FALSE, show_clade_count = TRUE, clade_label_offset = 50, clade_label_fontsize = 3, show_support = FALSE, support_threshold = 0.95, show_hpd = FALSE, hpd_color = "firebrick", geo_events = FALSE, timescale_version = "ICS 2023/02", main_title = NULL, sub_title = NULL, highlight = NULL, highlight_alpha = 0.2, theme_fun = theme_timetree, output = NULL, overwrite = "ask", width = 14, height = 10, taxonomy_levels = NULL, low_memory = FALSE, ignore_malformed = FALSE, ignore_branch_length = FALSE, color_rank = NULL, timescale_mode = "radial", timescale_position = "right", tree_start_position = "right", opts = NULL )
tree |
A |
tree_index |
Integer. Index of tree to use from multiPhylo objects (e.g., BEAST posterior).
Only used when |
multi_tree_mode |
Character. How to handle multiple trees in a file.
Options: |
rank |
Taxonomic rank to collapse at. One of:
|
triangle_mode |
Collapse triangle visualization mode.
|
space_mode |
Space allocation strategy for collapsed clades.
|
layout |
Tree layout. |
angle |
Fan angle in degrees for circular layout (0-360).
Only used when |
color_palette |
Color palette specification. Can be:
|
color_mapping |
Named character vector of specific color assignments.
Takes highest priority over |
line_width |
Branch line width (passed to ggtree). Default: |
show_tip_labels |
Logical. Whether to display tip labels.
Default: |
tip_label_size |
Numeric. Tip label font size. Default: |
add_timescale |
Logical. Whether to add a geological timescale to the x-axis.
Requires rectangular layout and valid edge lengths. Default: |
timescale_levels |
Character vector of timescale levels to display.
Options: |
unit |
Time unit of input tree edge lengths: |
taxonomy_format |
Taxonomy label format. |
custom_patterns |
Named list of regex patterns for custom format parsing.
Required when |
taxonomy_file |
Character. Path to an external taxonomy file. The file
should have two columns: (1) tip labels and (2) taxonomy strings in GTDB
format (e.g., |
taxonomy_file_sep |
Character. Column separator for taxonomy file.
|
taxonomy_file_header |
Logical. Whether taxonomy file has a header row.
Default: |
taxonomy_file_priority |
Logical. If |
taxonomy_source_priority |
Character. Which taxonomy source takes priority
when both embedded (label-based) and table (file-based) taxonomy are available:
|
taxonomy_table_sep |
Character. Separator between taxonomy ranks in the
second column of an external taxonomy file. Default: |
taxonomy_delimiter_mode |
Character. Embedded (Format A) parsing strategy:
|
legend_position |
Legend placement. Can be a cardinal direction
( |
legend_nrow |
Integer. Number of rows in legend grid. Auto-computed if NULL. |
legend_ncol |
Integer. Number of columns in legend grid. Auto-computed if NULL. |
legend_title |
Character. Custom legend title. If |
clade |
Character. Specific clade name to collapse (e.g., "Cyanobacteriota").
When provided, only this clade is checked for monophyly and collapsed if valid.
Mutually exclusive with |
strict |
Logical. If |
groups |
Named list of custom tip groups for collapsing. Each element
is a character vector of tip labels belonging to that group. Groups must be
monophyletic; non-monophyletic groups will raise an error. When |
show_clade_label |
Logical. Whether to add clade labels next to collapsed
triangles showing group name and species count. Default: |
show_clade_count |
Logical. Whether to show species count in clade labels
(e.g., "Proteobacteria (n=42)"). Only used when |
clade_label_offset |
Numeric. Horizontal offset for clade labels from the
right edge of the collapsed triangle in Ma units (0-5000). Default: |
clade_label_fontsize |
Numeric. Font size for clade labels (1-20).
Default: |
show_support |
Logical. Whether to display node support values.
Requires treedata input with posterior/bootstrap annotations.
Default: |
support_threshold |
Numeric. Minimum support value to display (0-1).
Default: |
show_hpd |
Logical. Whether to display HPD (Highest Posterior Density)
intervals. Requires node data with HPD annotations. Default: |
hpd_color |
Color for HPD bars. Default: |
geo_events |
Data frame of geological events to annotate, with columns
|
timescale_version |
Geological timescale version string. Currently only
|
main_title |
Character. Main title for the plot. Default: |
sub_title |
Character. Subtitle for the plot. Default: |
highlight |
Character vector of group names to highlight with colored
backgrounds. Only monophyletic groups are highlighted; non-monophyletic
groups trigger a warning. Supports special identifiers:
|
highlight_alpha |
Numeric. Transparency of highlight color (0-1).
Default: |
theme_fun |
Theme function or NULL. Default: |
output |
Optional output file path. If provided, the plot is saved
immediately (backward compatibility). Default: |
overwrite |
Character. Overwrite mode when |
width |
Output width in inches. Default: |
height |
Output height in inches. Default: |
taxonomy_levels |
Optional list for custom taxonomy rank codes and
names, e.g. |
low_memory |
Logical. If |
ignore_malformed |
Logical. If |
ignore_branch_length |
Logical. If |
color_rank |
Character. Taxonomic rank for coloring, independent of
|
timescale_mode |
Character. Timescale display mode for circular layout:
|
timescale_position |
Character. Clock position of the timescale axis
when |
tree_start_position |
Character. Clock position where the tree starts
expanding (the gap between the last and first tip). One of |
opts |
A |
This function orchestrates the complete Rclade pipeline:
Input validation and reading (format detection, unit conversion)
Taxonomy parsing (GTDB/Silva/NCBI/custom, clade/groups/rank modes)
MRCA computation and monophyly check (with nesting conflict detection)
Color generation (color-blind-safe palette)
Tree rendering and batch clade collapsing (ggtree + depth-first collapse)
Timescale integration and annotations (deeptime, support, HPD, labels, highlight)
Plot finalization (legend, theme, title, save, metadata)
A ggplot object with an rclade_info attribute containing
metadata (tip count, group count, taxonomy format, etc.).
Can be further customized with + layers.
When tree is a file path, Newick labels longer than 500 characters
are truncated to 400 characters plus a _RCLADE_TRUNC suffix (with a
warning) before parsing, because ape's Newick parser aborts the whole R
process on labels longer than ~512 characters on Linux. Truncated labels
may no longer match external taxonomy files or sequence IDs; shorten
labels upstream if exact matching is required. See read_tree_auto().
For complex configurations, consider organizing parameters by category:
Tree input: tree
Collapsing: rank, triangle_mode, space_mode
Layout: layout, angle, line_width
Colors: color_palette, color_mapping
Labels: show_tip_labels, tip_label_size, show_clade_label, clade_label_offset
Timescale: add_timescale, timescale_levels, unit
Taxonomy: taxonomy_format, custom_patterns
Annotations: show_support, support_threshold, show_hpd
Legend: legend_position, legend_nrow, legend_ncol
Output: output, width, height
Yu G, Smith DK, Zhu H, Guan Y, Lam TT-Y (2017). "ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data." Methods in Ecology and Evolution, 8(1), 28-36. doi:10.1111/2041-210X.12628
Gearty W (2025). "deeptime: an R package that facilitates highly customizable and reproducible visualizations of data over geological time intervals." Big Earth Data. doi:10.1080/20964471.2025.2537516
Paradis E, Schliep K (2019). "ape 5.0: an environment for modern phylogenetics and evolutionary analyses in R." Bioinformatics, 35(3), 526-528. doi:10.1093/bioinformatics/bty633
# Quick start with the bundled example tree (no timescale) data(example_tree) p <- plot_timetree(example_tree, rank = "phylum", taxonomy_format = "GTDB", add_timescale = FALSE)# Quick start with the bundled example tree (no timescale) data(example_tree) p <- plot_timetree(example_tree, rank = "phylum", taxonomy_format = "GTDB", add_timescale = FALSE)
A phylo object with 9 tips containing intentional polytomies
(multifurcations) for testing polytomy handling. This tree has a structure
of ((A,B,C),(D,E),(F,G,H,I)) with three multifurcating clades.
data(polytomy_tree)data(polytomy_tree)
A phylo object with 9 tips.
Simulated data for testing polytomy handling.
Prints a stylized ASCII art logo for Rclade to the console.
rclade_logo(show_version = TRUE, show_tagline = TRUE)rclade_logo(show_version = TRUE, show_tagline = TRUE)
show_version |
Logical. Whether to show version number. Default: TRUE |
show_tagline |
Logical. Whether to show tagline. Default: TRUE |
Invisible NULL
rclade_logo()rclade_logo()
plot_timetree()
rclade_options() returns a named list of commonly used rendering
parameters that can be passed to plot_timetree(opts = ...) as a
single object. Explicit arguments supplied directly to
plot_timetree() always take precedence over values in opts.
rclade_options( rank = "none", layout = "rectangular", color_palette = "viridis", taxonomy_format = "auto", add_timescale = TRUE, timescale_mode = "radial", unit = NULL, legend_position = "bottom", line_width = 1, show_tip_labels = FALSE, width = 14, height = 10, ... )rclade_options( rank = "none", layout = "rectangular", color_palette = "viridis", taxonomy_format = "auto", add_timescale = TRUE, timescale_mode = "radial", unit = NULL, legend_position = "bottom", line_width = 1, show_tip_labels = FALSE, width = 14, height = 10, ... )
rank |
Character. Collapsing rank (e.g. "phylum", "class", "none"). |
layout |
Character. "rectangular" or "circular". |
color_palette |
Character. Palette name (e.g. "viridis", "plasma", "Set1"). |
taxonomy_format |
Character. One of "auto", "GTDB", "Silva", "NCBI", "embedded", "custom_regex". |
add_timescale |
Logical. Whether to add a geological timescale. |
timescale_mode |
Character. "radial", "linear", "none". |
unit |
Character or NULL. "Ma", "Ga", or NULL. Required when add_timescale = TRUE (the pipeline aborts for NULL); NULL leaves native units untouched and is only valid with add_timescale = FALSE. |
legend_position |
Character. Legend placement (e.g. "bottom", "right", "none"). |
line_width |
Numeric. Branch line width. |
show_tip_labels |
Logical. Whether to display tip labels. |
width |
Numeric. Output width in inches. |
height |
Numeric. Output height in inches. |
... |
Additional named parameters to include in the options list. These are passed through without validation. |
This constructor is the first step toward parameter-surface convergence:
it provides a single validated source of truth for parameter defaults,
reducing the risk of drift between the plot_timetree() signature,
internal forwarding lists, and documentation.
A named list of class "rclade_options" suitable for the
opts argument of plot_timetree().
# Create a reusable options object opts <- rclade_options(rank = "phylum", layout = "circular", color_palette = "plasma", add_timescale = TRUE)# Create a reusable options object opts <- rclade_options(rank = "phylum", layout = "circular", color_palette = "plasma", add_timescale = TRUE)
Reads taxonomy information from a two-column table file where:
Column 1: Tip labels (must match tree tip labels)
Column 2: Taxonomy strings in GTDB format
(e.g., d__Archaea;p__Thermoproteota;c__Korarchaeia)
read_taxonomy_file(file, sep = "auto", header = FALSE, table_sep = ";")read_taxonomy_file(file, sep = "auto", header = FALSE, table_sep = ";")
file |
Character. Path to the taxonomy table file. |
sep |
Character. Column separator. |
header |
Logical. Whether the file has a header row. Default: |
table_sep |
Character. Separator between taxonomy ranks in the
second column (the taxonomy string). Default: |
Supports tab-delimited or comma-delimited files. Missing ranks are indicated
by empty values after the rank prefix (e.g., s__ for missing species).
A data.frame with columns:
Character. Tip labels from column 1.
Character. Domain (d__).
Character. Phylum (p__).
Character. Class (c__).
Character. Order (o__).
Character. Family (f__).
Character. Genus (g__).
Character. Species (s__).
Missing ranks are NA.
Intended for use as a stable library API by external workflows (e.g., Snakemake/Nextflow).
read_tree_auto(filepath, tree_index = NULL, multi_tree_mode = "error")read_tree_auto(filepath, tree_index = NULL, multi_tree_mode = "error")
filepath |
Path to tree file (.tre, .nwk, .newick, .nexus, .nex, .treefile, .xml) |
tree_index |
Integer. Index of tree to use from multiPhylo objects (e.g., BEAST posterior). Default: NULL (will use multi_tree_mode to determine behavior). |
multi_tree_mode |
Character. How to handle multiple trees in a file. Options:
|
Newick labels longer than 500 characters are automatically truncated to
400 characters plus a _RCLADE_TRUNC suffix (with a warning), because
ape's Newick parser aborts the whole R process on labels longer than
~512 characters on Linux. Truncated labels may no longer match external
taxonomy files or sequence IDs; shorten labels upstream if exact matching
is required.
phylo object (or multiPhylo if multi_tree_mode = "all" or "split")
Provides a command-line interface for Rclade. Requires the optparse package.
run_rclade_cli(args = commandArgs(trailingOnly = TRUE))run_rclade_cli(args = commandArgs(trailingOnly = TRUE))
args |
Character vector of command-line arguments (default: commandArgs(trailingOnly = TRUE)) |
An invisible integer exit code following standard Unix conventions:
0L (success), 1L (runtime error), 2L (parameter error),
3L (input-data error), 130L (user interrupt / SIGINT).
The caller MUST pass this value to q(status = ...) or
quit(status = ...) for the exit code to propagate to the operating
system; simply calling run_rclade_cli() without forwarding the
return value will always exit with code 0 regardless of errors.
--config)A --config YAML file supplies defaults for any option, with
precedence CLI explicit argument > config file > built-in default.
Because optparse does not expose "was this flag passed?", the override
is applied by comparing each option against its built-in default:
any option the user left at its default value is eligible to be
overridden by the config file — even if the user explicitly typed a
value identical to the default. Concretely:
plot_timetree --rank phylum (where "phylum" is the
default) will be overridden by rank: class in the config.
plot_timetree --rank species (non-default) is preserved.
This is an optparse limitation, not a bug, and is intentional
but surprising. To make an option immune to config, pass a non-default value,
or avoid relying on config for options you care about. Unknown config keys are
warned and ignored.
Performs comprehensive self-check:
Required package availability and versions
Example tree parsing and taxonomy extraction
Monophyly logic validation
run_rclade_selftest(verbose = TRUE)run_rclade_selftest(verbose = TRUE)
verbose |
Logical. If TRUE (default), progress and results are
reported via |
Integer. Exit code (0 = all passed, 1 = failures).
Provides an interactive web interface for Rclade. Requires the shiny package.
run_rclade_shiny()run_rclade_shiny()
No return value, called for side effects (launches a Shiny web app).
The logger, step-progress, and interrupt subsystems use package-level global
environments (.logger_env, .interrupt_env). Within a single R
process, multiple concurrent Shiny sessions will share (and may corrupt) this
state — log messages, step counters, and interrupt flags can cross between
sessions. For production multi-user deployment, run one Shiny instance per R
process (e.g., behind a load balancer), or assign a dedicated log file per
task via --log_file. A session-scoped state refactor is on the
roadmap.
Save sessionInfo() for reproducibility
save_session_info(file = "session_info.txt")save_session_info(file = "session_info.txt")
file |
Output file path (default "session_info.txt") |
Invisibly returns sessionInfo
Save a timetree plot to file
save_timetree(p, file, width = 14, height = 10, dpi = 300, overwrite = "ask")save_timetree(p, file, width = 14, height = 10, dpi = 300, overwrite = "ask")
p |
ggplot object |
file |
Output file path |
width |
Width in inches |
height |
Height in inches |
dpi |
Resolution (for PNG/TIFF only) |
overwrite |
Character. Overwrite mode: "ask" (default), "force", "no-clobber". |
Invisibly returns the ggplot object
Enable or disable logging
set_log_enabled(enabled)set_log_enabled(enabled)
enabled |
Logical. |
No return value, called for side effects (toggles the package-level logging enabled flag).
Set log file for dual output
set_log_file(filepath)set_log_file(filepath)
filepath |
Character. Path to log file. NULL to disable. |
No return value, called for side effects (opens or closes a log file connection for dual console + file logging).
Set log level
set_log_level(level)set_log_level(level)
level |
Character. One of "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL". |
No return value, called for side effects (sets the package-level log threshold).
Provides a detailed report on how well taxonomic labels can be parsed, including per-rank parse rates and failed labels.
summarize_taxonomy_quality( labels, format = "auto", custom_patterns = NULL, taxonomy_levels = NULL, delimiter_mode = "reverse" )summarize_taxonomy_quality( labels, format = "auto", custom_patterns = NULL, taxonomy_levels = NULL, delimiter_mode = "reverse" )
labels |
Character vector of tip labels |
format |
Format: "auto", "embedded", "GTDB", "Silva", "NCBI", "custom_rank", "custom_regex" |
custom_patterns |
Custom regex patterns (for "custom_regex" format) |
taxonomy_levels |
Custom taxonomy level configuration |
delimiter_mode |
Character. Embedded parsing strategy: "reverse", "greedy", "segment". |
Invisibly returns a list with parsing statistics
Extended version of summarize_taxonomy_quality() that can use an
external taxonomy file.
summarize_taxonomy_quality_with_file( labels, format = "auto", custom_patterns = NULL, taxonomy_file = NULL, file_sep = "auto", file_header = FALSE, file_priority = TRUE, table_sep = ";", delimiter_mode = "reverse", taxonomy_levels = NULL )summarize_taxonomy_quality_with_file( labels, format = "auto", custom_patterns = NULL, taxonomy_file = NULL, file_sep = "auto", file_header = FALSE, file_priority = TRUE, table_sep = ";", delimiter_mode = "reverse", taxonomy_levels = NULL )
labels |
Character vector of tip labels. |
format |
Format: "auto", "GTDB", "Silva", "NCBI", "custom_rank", "custom_regex". |
custom_patterns |
Custom regex patterns (for "custom_regex" format). |
taxonomy_file |
Character. Path to external taxonomy file. Default: |
file_sep |
Character. Column separator for taxonomy file. Default: |
file_header |
Logical. Whether taxonomy file has header row. Default: |
file_priority |
Logical. If |
table_sep |
Character. Separator between taxonomy ranks in the second
column of the taxonomy file. Default: |
delimiter_mode |
Character. Embedded parsing strategy: "reverse", "greedy", "segment". |
taxonomy_levels |
Custom taxonomy level configuration (list with codes and names).
Default: |
Invisibly returns a list with parsing statistics.
Print a summary of a Rclade timetree plot
summarize_timetree(p)summarize_timetree(p)
p |
ggplot object returned by plot_timetree() (with rclade_info attribute) |
Invisibly returns the info list
Based on ggtree::theme_tree2(), customized for publication quality.
Includes coord_cartesian(clip = "off") to prevent collapsed clade
triangles from being clipped at the plot panel boundary — triangle vertices
(especially the MRCA node apex) often extend beyond the tip-based y-axis range.
theme_timetree(base_size = 12)theme_timetree(base_size = 12)
base_size |
Base font size |
A list with components theme (ggplot2 theme) and
coord (coord_cartesian(clip = "off")). Callers should apply
both via p + result$theme + result$coord.
Validates FASTA/FASTQ files: format detection, duplicate IDs, alphabet detection, and alignment length consistency.
validate_sequence_deep( filepath, expected_alphabet = NULL, check_alignment = FALSE )validate_sequence_deep( filepath, expected_alphabet = NULL, check_alignment = FALSE )
filepath |
Character. Path to sequence file. |
expected_alphabet |
Character or NULL. Expected alphabet: "DNA", "RNA", "protein", or NULL for auto-detect. |
check_alignment |
Logical. If TRUE, check all sequences have equal length. |
List with validation results.
Validate sequence file format
validate_sequence_file(filepath)validate_sequence_file(filepath)
filepath |
Character. Path to sequence file. |
Character. Detected format: "fasta", "fastq", "unknown".
Checks that all tree tips have corresponding sequences and vice versa.
validate_tree_sequence_match( tree, sequence_file, quiet = FALSE, mol_type = NULL, skip_length_check = FALSE, multi_tree_mode = "error" )validate_tree_sequence_match( tree, sequence_file, quiet = FALSE, mol_type = NULL, skip_length_check = FALSE, multi_tree_mode = "error" )
tree |
phylo object or path to tree file. |
sequence_file |
Character. Path to sequence file (FASTA/FASTQ). |
quiet |
Logical. If TRUE, suppress messages. |
mol_type |
Character. Molecule type for sequence validation: "DNA",
"RNA", "protein", or "auto" (NULL). Default: |
skip_length_check |
Logical. If TRUE, skip alignment length consistency
check. Default: |
multi_tree_mode |
Character. How to handle multiple trees in a file when
|
List with match status and differences.