Learn R Programming

treeheatr

Your decision tree may be cool, but what if I tell you you can make it hot?

Changes in treeheatr 0.2.0

The first argument of heat_tree(), data is now replaced with x, which can be a dataframe (or tibble), a party (or constparty) object specifying the precomputed tree, or partynode object specifying the customized tree. custom_tree argument is no longer needed.

Install

Please make sure your version of R >= 3.5.0 before installation.

You can install the released version of treeheatr from CRAN with:

install.packages('treeheatr')

Or the development version from GitHub with remotes:

# install.packages('remotes') # uncomment to install devtools
remotes::install_github('trangdata/treeheatr')

Examples

Penguin dataset

These data were collected and made available by Dr. Kristen Gorman and the Palmer Station, Antarctica LTER.

Classification of different types of penguin species.

library(treeheatr)

heat_tree(penguins, target_lab = 'species')

Wine recognition dataset

Classification of different cultivars of wine.

heat_tree(wine, target_lab = 'Type', target_lab_disp = 'Cultivar')
## Warning in (function (mapping = NULL, nudge_x = 0, nudge_y = 0, ids = NULL, :
## Ignoring unknown parameters: `label.size`

Citing treeheatr

If you use treeheatr in a scientific publication, please consider citing the following paper:

Le TT, Moore JH. treeheatr: an R package for interpretable decision tree visualizations. Bioinformatics. 2020 Jan 1.

BibTeX entry:

@article{le2020treeheatr,
  title={treeheatr: an R package for interpretable decision tree visualizations},
  author={Le, Trang T and Moore, Jason H},
  journal={Bioinformatics},
  year={2020},
  doi="10.1093/bioinformatics/btaa662"
}

How to Use

treeheatr incorporates a heatmap at the terminal node of your decision tree. The basic building blocks to a treeheatr plot are (yes, you guessed it!) a decision tree and a heatmap.

  • The decision tree is computed with partykit::ctree() and plotted with the well-documented and flexible ggparty package. The tree parameters can be passed to ggparty functions via the heat_tree() and draw_tree() functions of treeheatr. More details on different ggparty geoms can be found here.

  • The heatmap is shown with ggplot2::geom_tile(). The user may choose to cluster the samples within each leaf node or the features across all samples.

Make sure to check out the vignette for detailed information on the usage of treeheatr.

Please open an issue for questions related to treeheatr usage, bug reports or general inquiries.

Thank you very much for your support!

Acknowledgements

Package hex was made with Midjourney and thus inherits a CC BY-NC 4.0 license.

Copy Link

Version

Install

install.packages('treeheatr')

Monthly Downloads

236

Version

0.2.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Trang Le

Last Published

January 29th, 2026

Functions in treeheatr (0.2.3)

wine

Results of a chemical analysis of wines grown in a specific area of Italy.
train_covid

Training dataset. Medical information of Wuhan patients collected between 2020-01-10 and 2020-02-18. Containing NAs.
wine_quality_red

Red variant of the Portuguese "Vinho Verde" wine.
prediction_df

Apply the predicted tree on either new test data or training data.
term_node_pos

Determines terminal node position.
test_covid

External test dataset. Medical information of Wuhan patients collected between 2020-01-10 and 2020-02-18.
get_cols

Get color functions from character vectors
galaxy

Galaxy dataset for regression.
eval_tree

Print decision tree performance according to different metrics.
draw_tree

Draws the conditional decision tree.
align_plots

Align decision tree and heatmap:
clust_feat_func

Performs clustering or features.
draw_heat

Draws the heatmap.
clust_samp_func

Performs clustering of samples.
compute_tree

Compute decision tree from data set
scale_norm

Performs transformation on continuous variables.
diabetes

Diabetes patient records.
print.ggHeatTree

Print a ggHeatTree object. Adopted from https://github.com/daattali/ggExtra/blob/master/R/ggMarginal.R#L207-L244.
heat_tree

Draws and aligns decision tree and heatmap.
get_disp_feats

Select the important features to be displayed.
get_fit

------------------------------------------------------------------------------------ Get the fitted tree depending on the input `x`.
penguins

Data of three different species of penguins.
prep_data

------------------------------------------------------------------------------------ Prepare dataset
prepare_feats

Prepares the feature dataframes for tiles.
position_nodes

Creates smart node layout.