If you use grafify, please cite

Shenoy, A. R. (2021) grafify: an R package for easy graphs, ANOVAs and post-hoc comparisons. Zenodo. http://doi.org/10.5281/zenodo.5136508

Latest DOI for all versions: DOI

Installation

grafify is now on CRAN and can be installed by typing install.packages("grafify").

Any updates not yet on CRAN will be made available here first. To install from GitHub you also need to install the remotes package. Then type remotes::install_github("ashenoy-cmbi/grafify@*release").

grafify requires the following packages to be installed: broom.mixed, car, emmeans, ggplot2, Hmisc, lme4, lmerTest, magrittr, pbkrtest, purrr, stats, tidyr.

Motivation

I made this package mainly to plot great-looking graphs quickly while exploring data, and for linear regressions for ANOVA. I also use it to introduce linear models in my teaching. If you’re interested in basic theory and code for statistics written for biologists, also visit Statistics for Micro/Immuno Biologists.

Latest version: v2.2.0 on CRAN or GitHub

Features

Graphs

grafify has five main features (graphs, colour blind-friendly colour schemes, ANOVA & post-hoc comparisons, practice datasets and data simulations):

  1. There are 19 plot_ functions of 6 broad types in grafify. The plot_scatter.. versions are preferred when there are many data points, plot_dot.. versions have a “cleaner” layout for smaller datasets.

    1. Two variables (one categorical & one numeric): these graphs either use scatter (or also called jitter) or dot plot geometries: plot_scatterbar_sd, plot_scatterbox, plot_scatterviolin and plot_dotbar_sd, plot_dotbox, plot_dotviolin New since v1.5.0: new plot_ functions like the above but ending in _sc for same colour or single colour. See vignettes for details.
    2. Three or four variables (one-way or two-way ANOVA designs; one or two categorical variable & one numeric variable): plot_3d_scatterbar, plot_3d_scatterbox, plot_4d_scatterbar, plot_4d_scatterbox
    3. Quantitative X & Y, plus a third variable: plot_xy_NumGroup, plot_xy_CatGroup
    4. Matched before-after graphs: plot_befafter_colours, plot_befafter_shapes
    5. Data distributions: plot_qqline, plot_density plot_histogram, and residuals of linear models with plot_qqmodel New since v1.5.0: plot_qqmodel which generates a Q-Q plot of model residuals
    6. Summary graphs with SD error bars: plot_bar_sd, plot_point_sd New since v1.5.0: single colour versions of these available as names ending with _sc

Colourblind-friendly colour schemes

The following discreet (qualitative) and continuous (quantitative) palettes are implemented in grafify:

(The continuous colour scheme based on Paul Tol’s YlOrBl variant is new in v0.2.0.)

Apply these discrete palettes to any ggplot2 object with scale_fill_grafify, scale_colour_grafify, scale_fill_grafify2 or scale_colour_grafify2. Palettes available are: okabe_ito (see Mike Mol’s blog), bright, pale, muted, dark, light, vibrant, and contrast colours (see Paul Tol’s blog).

Apply the yellow_conti continuous colour scheme using scale_fill_grafify_c and scale_colour_grafify_c.

Linear models

Fitting linear models and linear mixed models and obtaining ANOVA tables

  1. linear models for ordinary ANOVA: simple_anova, simple_model,
  2. linear mixed effects for repeated-measures and randomised-block design ANOVA: mixed_anova, mixed_model, mixed_anova_slopes & mixed_model_slopes.

Post-hoc comparisons

Perform post-hoc comparisons based on fitted models for response variables and slopes

  1. posthoc_Pariwise, posthoc_Levelwise & posthoc_vsRef
  2. posthoc_Trends_Pairwise, posthoc_Trends_Levelwise & posthoc_Trends_vsRef

Data simulation

Generating random one-way and two-way data based on mean and SD and residual error.

  1. one-way designs: make_1way_data, make_1way_rb_data
  2. two-way designs: make_2way_data, make_2way_rb_data

Vignettes

The best place to see grafify in action is the vignettes website, which has detailed description of all functions.

Function references

Go to this website for function documentations.

Hexsticker

Status