ggalluvial

ggalluvial: Layered Grammar for Alluvial Plots - Published in JOSS (2020)

https://github.com/corybrunson/ggalluvial

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    2 of 7 committers (28.6%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

alluvial-diagrams alluvial-plots categorical-data-visualization ggplot2 r repeated-measures-data
Last synced: 4 months ago · JSON representation

Repository

ggplot2 extension for alluvial plots

Basic Info
Statistics
  • Stars: 513
  • Watchers: 13
  • Forks: 34
  • Open Issues: 21
  • Releases: 13
Topics
alluvial-diagrams alluvial-plots categorical-data-visualization ggplot2 r repeated-measures-data
Created over 9 years ago · Last pushed 5 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.md

ggalluvial

Travis CRAN downloads DOI JOSS

This is a ggplot2 extension for alluvial plots.

Design

The alluvial plots implemented here can be used to visualize frequency distributions over time or frequency tables involving several categorical variables. The design is inspired by the alluvial package, but the ggplot2 framework induced several conspicuous differences:

  • alluvial understands a variety of inputs (vectors, lists, data frames), whereas ggalluvial requires a single data frame;
  • alluvial uses each variable of these inputs as a dimension of the data, whereas ggalluvial requires the user to specify the dimensions, either as separate aesthetics or as key-value pairs;
  • alluvial produces both the alluvia, which link cohorts across multiple dimensions, and (what are here called) the strata, which partition the data along each dimension, in a single function; whereas ggalluvial relies on separate layers (stats and geoms) to produce strata, alluvia, and alluvial segments called lodes and flows.

Additionally, ggalluvial arranges these layers vertically without gaps, so that the secondary plotting axis indicates the cumulative values of the strata at each dimension.

Installation

The latest stable release can be installed from CRAN:

r install.packages("ggalluvial")

The cran branch will contain the version most recently submitted to CRAN. It is duplicated in the master branch, from which source the website is built.

The development version can be installed from the (default) main branch on GitHub:

r remotes::install_github("corybrunson/ggalluvial@main", build_vignettes = TRUE)

Note that, in order to build the vignettes, the imported packages alluvial, ggfittext, and ggrepel must be installed. To skip this step, leave build_vignettes unspecified or set it to FALSE.

The optimization branch contains a development version with experimental functions to reduce the number or area of alluvial overlaps (see issue #6). Install it as follows:

r remotes::install_github("corybrunson/ggalluvial", ref = "optimization")

Note, however, that this branch has not kept pace with the main branch or with recent upgrades on CRAN.

Usage

Example

Here is how to generate an alluvial plot representation of the multi-dimensional categorical dataset of passengers on the Titanic:

``` r titanicwide <- data.frame(Titanic) head(titanicwide)

> Class Sex Age Survived Freq

> 1 1st Male Child No 0

> 2 2nd Male Child No 0

> 3 3rd Male Child No 35

> 4 Crew Male Child No 0

> 5 1st Female Child No 0

> 6 2nd Female Child No 0

ggplot(data = titanicwide, aes(axis1 = Class, axis2 = Sex, axis3 = Age, y = Freq)) + scalexdiscrete(limits = c("Class", "Sex", "Age"), expand = c(.2, .05)) + xlab("Demographic") + geomalluvium(aes(fill = Survived)) + geomstratum() + geomtext(stat = "stratum", aes(label = afterstat(stratum))) + thememinimal() + ggtitle("passengers on the maiden voyage of the Titanic", "stratified by demographics and survival") ```

<!-- -->

The data is in “wide” format, but ggalluvial also recognizes data in “long” format and can convert between the two:

``` r titaniclong <- tolodesform(data.frame(Titanic), key = "Demographic", axes = 1:3) head(titaniclong)

> Survived Freq alluvium Demographic stratum

> 1 No 0 1 Class 1st

> 2 No 0 2 Class 2nd

> 3 No 35 3 Class 3rd

> 4 No 0 4 Class Crew

> 5 No 0 5 Class 1st

> 6 No 0 6 Class 2nd

ggplot(data = titaniclong, aes(x = Demographic, stratum = stratum, alluvium = alluvium, y = Freq, label = stratum)) + geomalluvium(aes(fill = Survived)) + geomstratum() + geomtext(stat = "stratum") + theme_minimal() + ggtitle("passengers on the maiden voyage of the Titanic", "stratified by demographics and survival") ```

<!-- -->

Documentation

For detailed discussion of the data formats recognized by ggalluvial and several examples that illustrate its flexibility and limitations, read the technical vignette:

r vignette(topic = "ggalluvial", package = "ggalluvial")

Several additional vignettes offer detailed solutions to specific needs:

  • “Labeling small strata” ("labels") for how to elegantly label strata of a wide range of heights in an alluvial plot;
  • “The Order of the Rectangles” ("order-rectangles") for how to control the positioning of strata and lodes in an alluvial plot; and
  • “Tooltips for ggalluvial plots in Shiny apps” ("shiny") for how to incorporate alluvial plots into interactive apps.

The object documentation includes several more examples. Use help() to call forth more detail on

  • any layer (stat_* or geom_*),
  • the conversion functions (to_*_form), and
  • the data sets installed with the package (vaccinations and majors).

Short form

For some more digestible guidance on using ggalluvial, check out three cheat sheets and demos by students in Joyce Robbins’s Exploratory Data Analysis and Visualization Community Contribution Project:

Acknowledgments

Resources

Development of this package benefitted from the use of equipment and the support of colleagues at UConn Health and at UF Health.

Contribute

Contributions in any form are more than welcome! Pretty much every fix and feature of this package derives from a problem or question posed by someone with datasets or design goals i hadn’t anticipated. See the CONTRIBUTING file for guidance, and please respect the Code of Conduct.

Cite

If you use ggalluvial-generated figures in publication, i’d be grateful to hear about it! You can also cite the package according to citation("ggalluvial").

Owner

  • Name: Cory Brunson
  • Login: corybrunson
  • Kind: user
  • Location: Gainesville, FL
  • Company: @LaboratoryForSystemsMedicine

Mathematician by training, data scientist by testing. Relatively new to pretty much everything.

JOSS Publication

ggalluvial: Layered Grammar for Alluvial Plots
Published
May 21, 2020
Volume 5, Issue 49, Page 2017
Authors
Jason Cory Brunson ORCID
Center for Quantitative Medicine, UConn Health
Editor
Anisha Keshavan ORCID
Tags
ggplot2 alluvial plots statistical graphics data visualization repeated measures data categorical data

GitHub Events

Total
  • Issues event: 15
  • Watch event: 15
  • Issue comment event: 27
  • Push event: 1
  • Create event: 1
Last Year
  • Issues event: 15
  • Watch event: 15
  • Issue comment event: 27
  • Push event: 1
  • Create event: 1

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 664
  • Total Committers: 7
  • Avg Commits per committer: 94.857
  • Development Distribution Score (DDS): 0.402
Past Year
  • Commits: 3
  • Committers: 1
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
corybrunson j****o@v****u 397
Jason Cory Brunson c****d@g****m 218
Quentin Read q****d@g****m 33
corybrunson c****n@c****l 6
Cory Brunson b****n@u****u 5
Brunson j****n@F****l 3
Michael Chirico m****4@g****m 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 127
  • Total pull requests: 10
  • Average time to close issues: 4 months
  • Average time to close pull requests: 19 days
  • Total issue authors: 83
  • Total pull request authors: 2
  • Average comments per issue: 3.82
  • Average comments per pull request: 5.9
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 13
  • Pull requests: 0
  • Average time to close issues: about 1 month
  • Average time to close pull requests: N/A
  • Issue authors: 9
  • Pull request authors: 0
  • Average comments per issue: 1.69
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • corybrunson (33)
  • SimonDedman (3)
  • dcarbajo (3)
  • qdread (3)
  • peter308 (3)
  • jasonpott (2)
  • plijnzaad (2)
  • mbojan (2)
  • Generalized (2)
  • hmlea (1)
  • elbamos (1)
  • abiyug (1)
  • SaintRod (1)
  • twedl (1)
  • AdrianS85 (1)
Pull Request Authors
  • qdread (6)
  • MichaelChirico (4)
Top Labels
Issue Labels
enhancement (17) bug (16) documentation (7) question (6) help wanted (4)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cran 20,693 last-month
  • Total docker downloads: 27,136
  • Total dependent packages: 13
    (may contain duplicates)
  • Total dependent repositories: 84
    (may contain duplicates)
  • Total versions: 31
  • Total maintainers: 1
proxy.golang.org: github.com/corybrunson/ggalluvial
  • Versions: 13
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 4 months ago
cran.r-project.org: ggalluvial

Alluvial Plots in 'ggplot2'

  • Versions: 13
  • Dependent Packages: 12
  • Dependent Repositories: 79
  • Downloads: 20,693 Last month
  • Docker Downloads: 27,136
Rankings
Stargazers count: 0.8%
Forks count: 2.3%
Dependent repos count: 2.6%
Downloads: 4.0%
Dependent packages count: 4.6%
Average: 6.1%
Docker downloads count: 22.5%
Maintainers (1)
Last synced: 4 months ago
conda-forge.org: r-ggalluvial
  • Versions: 5
  • Dependent Packages: 1
  • Dependent Repositories: 5
Rankings
Dependent repos count: 14.8%
Stargazers count: 18.5%
Average: 23.4%
Dependent packages count: 29.0%
Forks count: 31.5%
Last synced: 4 months ago

Dependencies

.github/workflows/check-full.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 3.5 depends
  • ggplot2 >= 2.2 depends
  • dplyr >= 0.7 imports
  • lazyeval * imports
  • rlang * imports
  • stats * imports
  • tidyr >= 0.7 imports
  • tidyselect * imports
  • alluvial * suggests
  • babynames * suggests
  • ggfittext >= 0.6 suggests
  • ggrepel * suggests
  • grid * suggests
  • htmltools * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • sessioninfo * suggests
  • shiny >= 1.4.0.2 suggests
  • sp >= 1.4 suggests
  • testthat * suggests
  • vdiffr >= 0.2 suggests