Giter Club home page Giter Club logo

treeheatr's Introduction

vignette documentation github-action-status

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')

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.

treeheatr's People

Contributors

benmarwick avatar trangdata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

treeheatr's Issues

Handling of logical columns

Thanks for the great work!

I found that the package to have some issues in handling logical columns.
A simple fix is to coerce the logical columns, but unsure how will that fit into the whole package.

library(treeheatr)
library(tidyverse)

## A single logical column prevents the heat_tree function from running.
penguins_with_lgl = penguins %>% 
  dplyr::mutate(
    flipper_length_lgl = flipper_length_mm >= 200)

heat_tree(penguins_with_lgl, target_lab = 'species')
#> Error in .ctree_test_internal(x = x, X = X, ix = NULL, Xleft = Xleft, : object 'X' not found

## But converting the logical column into characters fixes this. 
## The code below is a simple fix using tidyselect-type functions.
penguins_with_fct = penguins_with_lgl %>% 
  dplyr::mutate(dplyr::across(.cols = where(is.logical),
                              .f = ~ ifelse(.x, "Yes", "No")))

heat_tree(penguins_with_fct, target_lab = 'species')
#> Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
#> "none")` instead.
#> Warning: It is deprecated to specify `guide = FALSE` to remove a guide. Please
#> use `guide = "none"` instead.

#> Warning: It is deprecated to specify `guide = FALSE` to remove a guide. Please
#> use `guide = "none"` instead.

Created on 2021-07-03 by the reprex package (v2.0.0)

The package version is treeheatr_0.2.1.

Release treeheatr 0.2.1

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS
  • Review pkgdown reference index for, e.g., missing topics

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Prepare for release 0.1.0

Prepare for release:

  • Check that description is informative
  • Check licensing of included files
  • usethis::use_cran_comments()
  • devtools::check()
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('major')
  • Update cran-comments.md
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • usethis::use_news_md()
  • Update install instructions in README
  • Finish blog post
  • Tweet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.