grafify

Easy grafs, ANOVAs and posthoc comparisons.

https://github.com/ashenoy-cmbi/grafify

Science Score: 59.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 5 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    2 of 3 committers (66.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.6%) to scientific vocabulary

Keywords

ggplot2 linear-models post-hoc-comparisons r statistics vignettes
Last synced: 6 months ago · JSON representation

Repository

Easy grafs, ANOVAs and posthoc comparisons.

Basic Info
Statistics
  • Stars: 52
  • Watchers: 1
  • Forks: 6
  • Open Issues: 1
  • Releases: 19
Topics
ggplot2 linear-models post-hoc-comparisons r statistics vignettes
Created about 5 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog

Readme.Rmd

---
output: github_document
---

### **Latest version: v5.1.0 on  [CRAN](https://CRAN.R-project.org/package=grafify) & GitHub** 

### Features

`grafify` has three main features: 

1. plotting great-looking graphs for quick-n-easy data exploration with few lines of code
2. apply colour blind-friendly palettes to graphs plotted with `grafify` or `ggplot2`
3. use linear models for ANOVA (including those with randomised block designs and repeated-measures) & post-hoc comparisons (estimated marginal means, confidence intervals and *P* values)

The [vignettes website](https://grafify-vignettes.netlify.app) has detailed help on usage and latest [release notes are here](https://grafify.shenoylab.com/release_notes.html).

As an example, you could write this to plot bar/SD graph from a 2-way ANOVA data with randomised blocks:

```{r, eval = TRUE, include=FALSE}
library(grafify)
```


```{r plot1, eval = F, fig.height=4}
plot_4d_scatterbar(data = data_2w_Festing, 
                   xcol = Strain,
                   ycol = GST,
                   bars = Treatment,
                   shapes = Block)
```


```{r echo=FALSE, eval = F}
ggsave("fig1.jpg", height = 4.5)
```


```{r, fig1, echo = F, out.width="90%"}
knitr::include_graphics("man/figures/fig1.jpg")
```

instead of all this! 

```{r, 2wanova, eval=FALSE}
ggplot2::ggplot(data = data_2w_Festing,
       aes(x = Strain,
           y = GST,
           group = interaction(Strain,
                               Treatment)))+
  stat_summary(geom = "bar",
               aes(fill = Treatment),
               position = position_dodge(width = 0.8), 
               fun = "mean")+
  geom_point(aes(shape = Block),
             size = 3, stroke = 1,
             position = position_jitterdodge(jitter.width = .2,
                                            dodge.width = .8))+
  stat_summary(geom = "errorbar",
               width = .2, size = 1,
               fun.data = "mean_sdl",
               fun.args = list(mult = 1),
               position = position_dodge(width = 0.8))+
  scale_shape_manual(values = 21:22)+
  theme_classic(base_size = 21)+
  theme(axis.text.x = element_text(angle = 45, hjust = 1))+
  scale_fill_manual(values = c(as.vector(graf_palettes$okabe_ito[1:2])))
```


Two other features including practice datasets (with randomised blocks), and data simulation for power analyses. The first three features are better documented at present.

#### Graphs

1. Easily plot data as scatter/dot plots with boxes, violins or bars with `plot_` functions of 6 broad types. 

     a. 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` or `plot_dotbar_sd`, `plot_dotbox`, `plot_dotviolin`
     b. One-way or two-way ANOVA designs with or without randomised blocks (3 or 4 dimensions or variables): `plot_3d_point_sd`, `plot_3d_scatterbar`, `plot_3d_scatterbox`,  `plot_3d_scatterviolin` or `plot_4d_point_sd`, `plot_4d_scatterbar`, `plot_4d_scatterbox`, `plot_4d_scatterviolin`
     c. Matched before-after graphs: `plot_befafter_colours`, `plot_befafter_shapes`, `plot_befafter_box`     
     c. Quantitative X & Y, plus a third variable: `plot_xy_NumGroup`, `plot_xy_CatGroup` 
     d. Data distributions: `plot_qqline`, `plot_density` `plot_histogram`, and model diagnostics with `plot_qqmodel`, `plot_qq_gam`, `plot_lm_predict` and `plot_gam_predict`
     f. Graphs with SD, SEM or CI95 error bars: `plot_point_sd`, `plot_scatterbar_sd`, `plot_3d_scatterbar`
  
  
```{r, all-graphs, echo = F, out.width="90%"}
knitr::include_graphics("man/figures/all_graphsv3.2.0.png")
```

#### Colourblind-friendly colour schemes

The following 12 categorical (qualitative/discreet) and 5 quantitative (3 sequential and 2 divergent) palettes are implemented in `grafify` for making graphs with `plot_` functions. 

In addition, `scale_fill_grafify` and `scale_colour_grafify` functions can be used to apply all `grafify` palettes to any `ggplot2` object.

```{r, image-palettes, echo = F, out.width="90%"}
knitr::include_graphics("man/figures/grafify_palettesv320.png")
```

All palettes are colourblind-friendly. (See Mike Mol's [blog](https://mikemol.github.io/technique/colorblind/2018/02/11/color-safe-palette.html) and Paul Tol's post and also available in the `khroma` [package](https://CRAN.R-project.org/package=khroma). Additional colour schemes were chosen from [`cols4all` package](https://github.com/cols4all/cols4all-R)).
    
#### `grafify` theme & adding log-scales

The `theme_grafify` function is a modification of `theme_classic` and enables graphs plotted with `ggplot2` to have a `grafify`-like appearance. 

`plot_logscales` lets you take any `ggplot2` object and transform Y, X or both axes into `log2` or `log10` values, and latter will also show log10 tick marks. 
    
#### Linear models for ANOVA

Get ANOVA tables and linear models with these easy wrappers.

  a. linear models for ordinary ANOVA: `simple_anova`, `simple_model`, `ga_model`, `ga_anova`.
  b. linear mixed effects for repeated-measures and randomised-block design ANOVA: `mixed_anova`, `mixed_model`, `mixed_anova_slopes`, `mixed_model_slopes`, `ga_model`, `ga_anova`.
  c. plot model residuals with `plot_qqmodel` and `plot_qq_gam`.
  d. plot model predictions with `plot_lm_predict` and `plot_gam_predict`.

#### Post-hoc comparisons & Estimated Marginal Means (easy wrappers for `emmeans`)

Perform post-hoc comparisons based on fitted models for response variables and slopes. Get Estimated Marginal Means, *P* values, parameter estimates with CI95 with these wrappers.
  
  a. `posthoc_Pariwise`, `posthoc_Levelwise` & `posthoc_vsRef`
  b. `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.

  a. one-way designs: `make_1way_data`, `make_1way_rb_data`
  b. two-way designs: `make_2way_data`, `make_2way_rb_data`
  
  
#### Data summaries

`table_summary` is simple function to obtain mean, median and SD by groups, and `table_x_reorder` is for working with factors. 

### Vignettes

The best place to see `grafify`  in action is the [vignettes](https://grafify-vignettes.netlify.app) website, which has detailed description of all functions.

### **Latest version: v5.1.0 on [CRAN](https://CRAN.R-project.org/package=grafify) and GitHub** 

Find out about [latest updates here](https://grafify.shenoylab.com/release_notes.html).

### Citing `grafify`

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](https://zenodo.org/badge/DOI/10.5281/zenodo.5136507.svg)](https://doi.org/10.5281/zenodo.5136507)

### Installation

`grafify` is now on [CRAN](https://CRAN.R-project.org/package=grafify) 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: `car`, `emmeans`, `ggplot2`, `Hmisc`, `lme4`, `lmerTest`, `magrittr`, `mgcv`, `patchwork`, `purrr`, `stats`, `tidyr`.

### Motivation behind `grafify`

I made this package mainly for exploring data by quickly making graphs of different types. Secondly, to implement linear regressions for ANOVA. I also use it to introduce linear models in my teaching, including the analyses of randomised block designs to new users. 

### Statistics for Micro/immuno biologists

Also visit Statistics for [Micro/Immuno Biologists](https://biostats.shenoylab.com/) for basic statistics theory and data analyses in R.

### Function references

Go to this [website](https://ashenoy-cmbi.github.io/grafify/index.html) for function documentations.

### Hexsticker

```{r, image-1hex, echo = F, out.width="150px"}
knitr::include_graphics("man/figures/grafify.png")
```

### Status


[![R-CMD-check](https://github.com/ashenoy-cmbi/grafify/workflows/R-CMD-check/badge.svg)](https://github.com/ashenoy-cmbi/grafify/actions)

Owner

  • Name: Avinash Shenoy
  • Login: ashenoy-cmbi
  • Kind: user
  • Company: @ImperialCollegeLondon

Reader of Innate Immunity & Infection, Imperial College London

GitHub Events

Total
  • Release event: 1
  • Watch event: 2
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 43
  • Fork event: 1
  • Create event: 3
Last Year
  • Release event: 1
  • Watch event: 2
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 43
  • Fork event: 1
  • Create event: 3

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 194
  • Total Committers: 3
  • Avg Commits per committer: 64.667
  • Development Distribution Score (DDS): 0.036
Past Year
  • Commits: 36
  • Committers: 2
  • Avg Commits per committer: 18.0
  • Development Distribution Score (DDS): 0.111
Top Committers
Name Email Commits
Avinash a****y@i****k 187
Shenoy a****y@i****k 4
Teun van den Brand t****d@g****m 3
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 5
  • Total pull requests: 3
  • Average time to close issues: 25 days
  • Average time to close pull requests: 5 days
  • Total issue authors: 4
  • Total pull request authors: 2
  • Average comments per issue: 3.4
  • Average comments per pull request: 2.33
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sorrywm (2)
  • teunbrand (1)
  • shaoyoucheng (1)
  • thomasp85 (1)
Pull Request Authors
  • teunbrand (3)
  • BB1464 (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cran 998 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 30
  • Total maintainers: 1
proxy.golang.org: github.com/ashenoy-cmbi/grafify
  • Versions: 16
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.5%
Average: 6.7%
Dependent repos count: 6.9%
Last synced: 6 months ago
cran.r-project.org: grafify

Easy Graphs for Data Visualisation and Linear Models for ANOVA

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 998 Last month
Rankings
Stargazers count: 7.7%
Forks count: 9.6%
Downloads: 17.4%
Average: 17.5%
Dependent repos count: 24.0%
Dependent packages count: 28.8%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: r-grafify
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Stargazers count: 42.3%
Average: 44.3%
Forks count: 49.6%
Dependent packages count: 51.2%
Last synced: 6 months ago

Dependencies

.github/workflows/check-release.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/check-standard.yaml actions
  • actions/checkout v3 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 >= 4.0 depends
  • ggplot2 * depends
  • Hmisc * imports
  • car * imports
  • emmeans * imports
  • lme4 * imports
  • lmerTest * imports
  • magrittr * imports
  • purrr * imports
  • stats * imports
  • tidyr * imports
  • dplyr * suggests
  • knitr * suggests
  • pbkrtest * suggests
  • rlang * suggests
  • rmarkdown * suggests
  • testthat >= 3.0.0 suggests