PyiTOL CLI Complete Reference¶
中文 | English
Global Parameters¶
All subcommands share the following global parameters:
| Parameter | Shortcut | Default | Description |
|---|---|---|---|
--version |
Show version number, release date, Git hash, dependency library versions, and license | ||
--verbose |
False |
Show verbose logs (DEBUG level) | |
--quiet |
-q |
False |
Show only key information (WARNING level) |
--config |
-c |
YAML/JSON configuration file path (can be specified multiple times; later files override earlier ones) | |
--log-file |
Log file path (also output to file) | ||
--low-memory |
False |
Low memory mode (suitable for large datasets) |
Command Overview¶
self-test - Self-Test Mode¶
pyitol self-test¶
Runs a self-test: verifies dependency libraries, example parsing, and monophyly determination logic.
Outputs a [PASS]/[FAIL] table that verifies:
- Third-party dependency libraries can be imported and their versions
- Internal modules can be imported
- Newick tree parsing
- Embedded taxonomy extraction
- Monophyletic group determination logic
- Malicious character detection
Exit code: 0=all passed, 1=some failed
validate - Input Validation¶
pyitol validate¶
Validates input file format, color codes, and node ID consistency. Supports deep validation and adversarial protection.
# Basic validation
pyitol validate --tree tree.nwk --taxonomy taxonomy.csv
# Deep validation (with sequence file)
pyitol validate --tree tree.nwk --taxonomy tax.csv --sequence seqs.fasta --alphabet DNA
| Parameter | Shortcut | Description |
|---|---|---|
--tree |
-t |
Tree file path |
--taxonomy |
Taxonomy table file path | |
--sequence |
-s |
Sequence file path |
--alphabet |
Expected alphabet: auto/DNA/RNA/protein/any |
|
--template |
Template file path (can be specified multiple times) | |
--color |
Color code (can be specified multiple times) |
Deep validation contents: - Tree file: bracket balance, negative branch lengths (CRITICAL), empty node names (ERROR), duplicate tip names (ERROR), multiple root nodes (ERROR) - Sequence file: alphabet detection (DNA/RNA/protein), ID uniqueness, length consistency - Adversarial protection: malicious characters (control characters/bidirectional text), circular dependencies, empty files
config - Configuration File Management¶
pyitol config init¶
Generates a default configuration file template.
| Parameter | Default | Description |
|---|---|---|
--output / -o |
pyitol_config.yaml |
Output configuration file path |
--api-key-file |
.itolapi.key |
API key file path |
--default-format |
svg |
Default export format |
template - Template Management¶
pyitol template create <type> ⭐ Unified Entry¶
Creates an iTOL v7 template file based on the type. This is the recommended unified entry for template generation.
# Example: generate a taxonomy color strip
pyitol template create color-strip \
--taxonomy taxonomy.csv --tree tree.nwk \
--column Phylum --output colors.txt
# Example: generate a heatmap
pyitol template create heatmap \
--taxonomy expr.csv --tree tree.nwk \
--columns Sample1,Sample2,Sample3 --output heatmap.txt
# Example: conditional collapse of a monophyletic group (dedicated subcommand, only one with --strict)
pyitol template create-collapse \
--tree tree.nwk --taxonomy tax.csv \
--taxon Cyanobacteriota --rank Phylum \
--strict -o collapse.txt
Supported template types:
| Type | Description | Required Parameters |
|---|---|---|
color-strip |
Color strip | --taxonomy, --tree, --column |
branch |
Branch coloring | --taxonomy, --tree, --column |
simple-bar |
Single-value bar chart | --taxonomy, --tree, --column |
multi-bar |
Multi-value bar chart | --taxonomy, --tree, --columns |
heatmap |
Heatmap | --taxonomy, --tree, --columns |
symbols |
Symbol markers | --taxonomy, --tree, --column |
pie |
Pie chart | --taxonomy, --tree, --columns |
boxplot |
Boxplot | --taxonomy, --tree |
gradient |
Gradient strip | --taxonomy, --tree, --column |
connections |
Connection lines | --connections |
labels |
Label renaming | --taxonomy, --tree, --column |
popup-info |
Hover information | --taxonomy, --tree |
domains |
Protein domains | --data-file |
binary |
Binary data | --taxonomy, --tree, --columns |
text |
Text labels | --taxonomy, --tree, --column |
external-shape |
External shapes | --taxonomy, --tree, --column |
tree-colors |
Tree coloring | --taxonomy, --tree, --column |
branch-gradient |
Branch gradient | --taxonomy, --tree, --column |
collapse |
Collapse clades | --node-ids or --taxon |
prune |
Prune branches | --node-ids |
spacing |
Node spacing | --data-file |
ranges |
Colored ranges | --taxonomy, --tree, --column |
highlight |
Label highlighting | --taxonomy, --tree, --column |
style |
Branch/label style | --taxonomy, --tree, --column |
arrow |
Arrow annotations | --data-file |
linechart |
Line chart | --taxonomy, --tree, --column |
image |
Image embedding | --taxonomy, --tree, --column or --image-column |
alignment |
Sequence alignment | --taxonomy, --tree, --column or --alignment-column |
tanglegram |
Tanglegram | --connections |
placement |
Phylogenetic placement | --data-file |
timescale |
Timescale | --data-file |
meme |
MEME motifs | --data-file |
manual |
Manual annotations | --data-file |
Note: The unified entry point
template createsupports 33 types. In addition,external-shape-bubble(bubble external shape, a variant ofexternal-shape) must be created via the dedicated subcommandpyitol template create-external-shape-bubbleand is not part of the unified entry point. There are also 34 dedicatedcreate-*subcommands available (pyitol template create-color-strip, etc.): 33 of them map one-to-one to the 33 types of the unified entry point and are functionally equivalent to it, and the remaining one iscreate-external-shape-bubble.
Common parameters:
| Parameter | Shortcut | Default | Description |
|---|---|---|---|
--output / -o |
config_template.txt |
Output template file path | |
--taxonomy / -t |
Taxonomy table file path | ||
--tree / -r |
Tree file path | ||
--column / -c |
Data column name | ||
--columns |
Multiple data column names, comma-separated | ||
--colors |
Custom color mapping JSON | ||
--label / -l |
dataset |
Dataset label (when left at the default it is replaced by the type-specific default label, e.g. color_strip, heatmap) |
|
--id-column |
id |
ID column name | |
--separator / -s |
TAB |
Data separator (field separator for the template's data lines, not the rank separator inside a tip name) | |
--palette |
Color palette preset (only color-strip reads this value, and it is currently reserved and has no effect — see the subcommand reference) |
||
--data-file / -d |
Data file path | ||
--force / -f |
False |
Overwrite existing output file | |
--no-clobber |
False |
Skip existing output file |
collapse-specific parameters:
| Parameter | Description |
|---|---|
--node-ids / -n |
Node IDs to collapse, comma-separated |
--taxon |
Taxon name to collapse (requires --taxonomy and --tree) |
--rank |
Taxonomic rank (e.g., Phylum, Class) |
--strict |
Strict mode: abort if not monophyletic (skips by default) |
Note:
--strictis accepted only by the dedicatedtemplate create-collapsesubcommand; the unified entrytemplate create collapsedoes not have this option.
pyitol template bundle¶
One-click bundled generation of multiple visualization template files.
pyitol template bundle \
--output-dir ./templates \
--taxonomy taxonomy.csv --tree tree.nwk \
--config '[{"type":"color-strip","column":"Phylum"},{"type":"heatmap","columns":["A","B","C"]}]'
pyitol template validate¶
Validates iTOL template file format.
PyiTOL also provides 34 dedicated subcommands pyitol template create-* (e.g. create-color-strip, create-symbols, create-pie), each accepting only its type-specific parameters — better suited for precise scripting and pipelines. Full options and examples are in Template Subcommand Reference.
taxonomy - Taxonomy Analysis¶
pyitol taxonomy ranks¶
Displays the list of taxonomic ranks.
pyitol taxonomy extract¶
Extracts information for a specified taxonomic rank.
pyitol taxonomy extract-stats¶
Extracts taxonomy statistics (member count, LCA node, etc.).
pyitol taxonomy extract-stats --taxonomy taxonomy.csv --tree tree.nwk --rank Phylum --output stats.csv
pyitol taxonomy extract-from-names¶
Automatically extracts taxonomic information from tree tip names.
# GTDB format
pyitol taxonomy extract-from-names --tree tree.nwk --format gtdb -o taxonomy.csv
# Embedded format
pyitol taxonomy extract-from-names --tree tree.nwk --format embedded -o taxonomy.csv
# Auto-detection
pyitol taxonomy extract-from-names --tree tree.nwk --format auto -o taxonomy.csv
# Custom taxonomy levels
pyitol taxonomy extract-from-names --tree tree.nwk \
--taxonomy-levels "d:Domain,p:Phylum,c:Class,o:Order,f:Family,g:Genus,s:Species" \
-o taxonomy.csv
| Parameter | Default | Description |
|---|---|---|
--tree / -r |
Tree file path | |
--output / -o |
taxonomy_from_names.csv |
Output taxonomy table path |
--format / -f |
auto |
Naming format: auto/gtdb/embedded/ncbi |
--delimiter / -d |
_ |
Name segment delimiter (splits the rank segments inside a tip name) |
--taxonomy-levels |
Custom taxonomy level prefixes | |
--taxonomy-delimiter-mode |
segment |
Name parsing strategy for the embedded format: segment (default, forward segment-by-segment matching) / reverse (strict reverse order) / greedy (cut from the first _d_) |
Supported formats:
- GTDB (Format B): d__Bacteria;p__Proteobacteria;c__Gammaproteobacteria;...
- Embedded (Format A): GB_GCA_0001_d_Bacteria_p_Proteo_c_Gamma_o_Enter_f_Enter_g_Escherichia
- NCBI: Genus_species
pyitol taxonomy monophyly¶
Checks the monophyly (monophyletic/paraphyletic/polyphyletic) of a specified taxonomic group.
# Detect by taxonomic rank
pyitol taxonomy monophyly --taxonomy taxonomy.csv --tree tree.nwk --rank Phylum --output mono.csv
# Detect by specified taxa
pyitol taxonomy monophyly --taxonomy taxonomy.csv --tree tree.nwk \
--taxa "Proteobacteria,Firmicutes" --output mono.csv
# Use special identifiers
pyitol taxonomy monophyly --taxonomy taxonomy.csv --tree tree.nwk \
--taxa "LUCA,LACA,LBCA,ROOT" --output mono.csv
| Parameter | Description |
|---|---|
--taxonomy / -t |
Taxonomy table file path |
--tree / -r |
Tree file path |
--rank |
Taxonomic rank name |
--taxa |
Specified taxon names, comma-separated (supports LUCA/LACA/LBCA/ROOT) |
--taxa-file |
File containing taxon names (one per line) |
--output / -o |
Output file path |
--id-column |
ID column name |
--multi-tree-mode / -m |
Accepted but currently has no effect: declared for future use and never forwarded to the tree-loading code. The strategies ask/first/last/split (all being an internal alias for split) are a library capability of core/parser.load_tree |
--polytomy-mode |
Polytomy handling strategy: strict/relaxed/data-insufficient, default strict. When a group's members occupy only some child branches of a polytomous LCA: strict (default) and data-insufficient return data_insufficient; relaxed returns paraphyletic instead of polyphyletic |
Special identifiers:
- LUCA: MRCA of all bacteria and archaea
- LACA: MRCA of all archaea
- LBCA: MRCA of all bacteria
- ROOT: Root of the entire tree (all tip nodes)
pyitol taxonomy check-and-style¶
Checks whether a specified taxon is monophyletic; if so, generates a styling template, otherwise issues a warning.
pyitol taxonomy check-and-style \
--tree tree.nwk --taxonomy tax.csv \
--taxon Escherichia --rank Genus \
--action color-branch --color "#e41a1c" \
--output clade.txt
# Use special identifiers
pyitol taxonomy check-and-style \
--tree tree.nwk --taxonomy tax.csv \
--taxon LUCA --rank Domain \
--action color-branch --output luca.txt
| Parameter | Description |
|---|---|
--tree / -r |
Tree file path |
--taxonomy / -t |
Taxonomy table file path (optional; if omitted, taxonomy is extracted from tip names) |
--taxon |
Taxon name to check (supports LUCA/LACA/LBCA/ROOT) |
--rank |
Taxonomic rank (default Genus) |
--action / -a |
Style action: color-branch/highlight/color-strip (default color-branch) |
--color |
Specified color (HEX); auto-assigned if omitted |
--output / -o |
Output template file path (default styled_template.txt) |
--id-column |
ID column name (default id) |
--name-format |
Naming format: auto/gtdb/embedded/ncbi (default auto, used only when --taxonomy is absent) |
--palette |
Color palette preset (default nature) |
--separator |
Data separator: TAB/SPACE/COMMA (default TAB) |
--domain-column |
Domain column name (used for LUCA/LACA/LBCA resolution) |
--multi-tree-mode / -m |
Accepted but currently has no effect: declared for future use and never forwarded to the tree-loading code. The strategies ask/first/last/split (all being an internal alias for split) are a library capability of core/parser.load_tree |
--taxonomy-source-priority |
Mixed-source priority: table (default, table takes precedence) / embedded (tree names take precedence) |
pyitol taxonomy style¶
Generates an iTOL template configuration file based on taxonomy information and a specified style action.
pyitol taxonomy style \
--taxonomy taxonomy.csv --tree tree.nwk \
--rank Phylum --action color-strip --output style.txt
Supported style actions (--action):
- color-branch / color-label / color-range / color-strip
- style-branch / style-label
- width / highlight / symbol / range / gradient
pyitol taxonomy convert-binary¶
Converts taxonomy data into a 0/1 binary matrix.
pyitol taxonomy convert-connect¶
Converts a 0/1 matrix into a long-format table of connection pairs.
task - API Task Management¶
pyitol task upload¶
Uploads trees and templates to iTOL.
pyitol task upload --tree tree.nwk \
--config colors.txt --config bars.txt \
--api-key YOUR_KEY --dataset-name MyTree
| Parameter | Shortcut | Default | Description |
|---|---|---|---|
--tree |
-r |
Tree file path (required) | |
--config |
-c |
Template/configuration file path (can be specified multiple times) | |
--api-key |
iTOL API key | ||
--api-key-file |
API key file path | ||
--dataset-name |
Dataset (tree) name; defaults to the tree file name stem | ||
--tree-description |
Tree description | ||
--verbose |
False |
Show detailed response | |
--retry |
3 |
Number of network request retries | |
--wait |
60 |
Fixed number of seconds to wait for iTOL rendering after upload (a fixed delay, not a timeout/deadline; only takes effect with --download) |
|
--download |
-d |
If set, export images to this directory once the upload finishes | |
--parameters-file |
Export parameters file (one key=value per line) |
||
--parameter |
Export parameter key=value (can be specified multiple times) |
Note:
task uploadhas no--formatoption; when exporting via--download, the format must be given as--parameter format=svg(defaults to
pyitol task export¶
Exports iTOL visualization images.
| Parameter | Shortcut | Default | Description |
|---|---|---|---|
--upload-id |
-u |
Upload ID (required) | |
--download |
-d |
Download output directory (required) | |
--api-key |
iTOL API key | ||
--api-key-file |
API key file path | ||
--parameters-file |
Export parameters file (one key=value per line) |
||
--parameter |
Export parameter key=value (can be specified multiple times) |
||
--wait |
60 |
Accepted but currently has no effect: the value is parsed and discarded, no delay is performed and it is not a timeout/deadline; the export request is issued immediately (a fixed wait only happens in task upload --download and task upload-and-export) |
|
--retry |
3 |
Number of retries |
Note:
task exportdoes not provide the--format,--dpi,--widthor--heightoptions. The export format must be given as--parameter format=svg(one ofsvg/png/tiff/eps/newick/nexus/phyloxml, defaults to--parameter dpi=300,--parameter width=2400, etc. Usepyitol task upload-and-exportif you want those standalone options.
pyitol task upload-and-export¶
Uploads and exports an image (in one step).
pyitol task upload-and-export \
--tree tree.nwk --config colors.txt \
--output output.svg --format svg --wait 60
| Parameter | Shortcut | Default | Description |
|---|---|---|---|
--tree |
-r |
Tree file path (required) | |
--output |
-o |
Output image path (required) | |
--config |
-c |
Template/configuration file path (can be specified multiple times) | |
--api-key |
iTOL API key | ||
--api-key-file |
API key file path | ||
--dataset-name |
Dataset (tree) name | ||
--tree-description |
Tree description | ||
--verbose |
False |
Show detailed response | |
--wait |
60 |
Fixed number of seconds to wait for iTOL rendering after upload and before issuing the export (a fixed delay, not a timeout/deadline) | |
--retry |
3 |
Number of retries | |
--format |
-f |
svg |
Export format: svg/png/pdf |
--dpi |
Image DPI (only applies to PNG/PDF) | ||
--width |
Image width (pixels) | ||
--height |
Image height (pixels) | ||
--parameters-file |
Export parameters file (one key=value per line) |
||
--parameter |
Export parameter key=value (can be specified multiple times) |
Supports --parameter for passing iTOL export parameters (e.g., datasets_visible, display_mode, background), consistent with task export:
pyitol task upload-and-export \
--tree tree.nwk --config colors.txt \
--output output.png --format png --dpi 300 --wait 60 \
--parameter datasets_visible=0,1 \
--parameter display_mode=2 \
--parameter background=ffffff
Common --parameter values: datasets_visible (dataset visibility), display_mode (0=rectangular/1=circular/2=unrooted circular/3=unrooted rectangular), background (background color), ignore_branch_length (ignore branch lengths), line_width (line width), current_font_size (current font size), margin (page margin), arc (arc).
pyitol task delete¶
Deletes uploaded trees or projects.
pyitol task delete --upload-id ID1 --upload-id ID2 --api-key YOUR_KEY
# Delete an entire project
pyitol task delete --project MyProject --confirm
pyitol task status¶
Queries the status of an uploaded tree.
Note:
task statustakes the tree name via--tree-name/-n(not--upload-id).
pyitol task run¶
Runs a configuration file (single config or batch list).
tree - Tree File Operations¶
pyitol tree info¶
Displays basic tree file information.
pyitol tree format-support-values¶
Formats support value display (supports IQ-TREE, RAxML, ALRT and other formats).
utils - Utilities¶
pyitol utils tree-info¶
Displays basic tree file information. Deprecated: duplicated by pyitol tree info (the canonical command); kept only for backward compatibility and emits a DeprecationWarning when run.
pyitol utils search-tree-file¶
Automatically searches for a phylogenetic tree file in a directory.
pyitol utils taxonomy-parse¶
Parses and previews the structure and content of a taxonomy table.
pyitol utils learn-template¶
Learns the configuration back from an existing iTOL template file. Deprecated: duplicated by pyitol learn template (the canonical command); kept only for backward compatibility and emits a DeprecationWarning when run.
pyitol utils wide-to-long / long-to-wide¶
Format conversion.
pyitol utils wide-to-long --data wide.csv --id-column id -o long.csv
pyitol utils long-to-wide --data long.csv --id-column id -o wide.csv
pyitol utils count-to-tree¶
Builds a phylogenetic tree based on count-value distances.
pyitol utils df-tree ⭐¶
Builds a Newick-format phylogenetic tree directly from a data frame.
pyitol utils group-columns¶
Aggregates data by specified columns. Supports regex matching for column-name grouping and multi-attribute mapping grouping.
pyitol utils binary¶
Converts taxonomy data into a binary matrix.
pyitol utils connections¶
Generates connection pairs (based on co-occurrence weights).
pyitol utils preview¶
Previews the data distribution of a specific column in the taxonomy table.
learn - Learning from Existing Templates¶
pyitol learn template¶
Learns the configuration back from template files.
pyitol learn palette¶
Views available color palette presets.
pyitol learn train-theme ⭐¶
Batch-learns themes from a template directory and generates recommended default parameters.
replay - Action Replay¶
pyitol replay¶
Replays a previous operation record.
| Parameter | Shortcut | Default | Description |
|---|---|---|---|
--session |
-s |
Snapshot (session.yaml) file path (required) | |
--dry-run |
False |
Only show the suggested commands without executing them | |
--use-cli |
True |
Prefer replaying the recorded command line as-is (when disabled, actions are rebuilt parameter by parameter) |
Configuration File Format¶
PyiTOL supports passing a YAML/JSON configuration file via --config to override global parameters. Parameter priority: command line > configuration file > default values.
--config is used to override CLI default parameters (such as tree, taxonomy, api_key, etc.).
pyitol task run uses an independent task configuration file format, with each item specifying the operation via the command field, supporting upload/export/extract/monophyly/convert-binary, etc. See API Usage Guide for details.
Task configuration file example batch.yaml (list format):
- command: upload
tree: tree.nwk
configs: [colors.txt, bars.txt]
api_key: YOUR_API_KEY
name: MyTree
- command: export
upload_id: TREE_ID
download: ./output
parameters:
format: svg
dpi: 300
Exit Codes¶
| Exit Code | Meaning | Description |
|---|---|---|
| 0 | Success | Operation completed normally |
| 1 | Runtime Error | Internal error, dependency issue, API failure |
| 2 | Parameter Error | Invalid CLI parameters, validation failure |
| 3 | Data Error | Input file format/content error |
| 130 | User Interrupt | Received SIGINT (Ctrl+C) |