Tutorial 20: Visualization commands

Objectives

Choose among a continuous trait map, a discrete state-probability map, a phenogram, and a tanglegram.

Prerequisites and working directory

Install PhyKIT and create a working directory. Save the tutorial files there under the listed names, then run the commands from that directory.

mkdir phykit-tutorial-20
cd phykit-tutorial-20

Download these example files into that directory.

Workflow

PhyKIT provides several phylogenetic visualization commands analogous to R's phytools plotting functions. All produce publication-quality plots saved at 300 DPI.

contMap — continuous trait mapping onto a phylogram:

phykit cont_map -t tree_simple.tre -d tree_simple_traits.tsv -o contmap.png

densityMap — posterior state probabilities from stochastic character mapping:

phykit density_map -t tree_simple.tre -d tree_simple_discrete_traits.tsv \
    -c diet -o densitymap.png -n 100 --seed 42

phenogram (traitgram) — trait values vs. distance from root:

phykit phenogram -t tree_simple.tre -d tree_simple_traits.tsv -o phenogram.png

cophylo (tanglegram) — two trees facing each other with connecting lines:

phykit cophylo -t tree_simple.tre -t2 tree_simple.tre -o tanglegram.png

All visualization commands support --json output. The density_map command also supports --seed for reproducibility and -n to set the number of stochastic mapping simulations. The cophylo command supports -m/--mapping for a tab-delimited file matching taxa between trees with different tip names.

For methodological details, see Revell (2012).


Expected artifacts

The four commands write contmap.png, densitymap.png, phenogram.png, and tanglegram.png. The tanglegram compares the sample tree with itself to illustrate the layout.

Troubleshooting

  • Run phykit <command> --help to compare an invocation with the live interface.

  • Confirm that downloaded files are in the current working directory and retain the filenames shown in the tutorial.

  • For parsing errors, compare taxon names exactly across alignments, trees, and trait tables, including capitalization and underscores.

  • See Troubleshooting for installation, format, and error-reporting guidance.