ggsignif

Easily add significance brackets to your ggplots

https://github.com/const-ae/ggsignif

Science Score: 54.0%

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

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 11 committers (9.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.4%) to scientific vocabulary

Keywords

asterisk ggplot-extension ggplot2 rstats significance-stars

Keywords from Contributors

standardization
Last synced: 4 months ago · JSON representation ·

Repository

Easily add significance brackets to your ggplots

Basic Info
Statistics
  • Stars: 606
  • Watchers: 15
  • Forks: 45
  • Open Issues: 29
  • Releases: 10
Topics
asterisk ggplot-extension ggplot2 rstats significance-stars
Created over 8 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License Code of conduct Citation Codemeta

README.Rmd

---
output: github_document
---

# ggsignif: Significance Brackets for 'ggplot2' 

[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/ggsignif)](https://cran.r-project.org/package=ggsignif)
[![R build status](https://github.com/const-ae/ggsignif/workflows/R-CMD-check/badge.svg)](https://github.com/const-ae/ggsignif/actions)
[![Total downloads badge](https://cranlogs.r-pkg.org/badges/grand-total/ggsignif?color=blue)](https://CRAN.R-project.org/package=ggsignif)
[![Codecov test coverage](https://codecov.io/gh/const-ae/ggsignif/branch/main/graph/badge.svg)](https://app.codecov.io/gh/const-ae/ggsignif?branch=main)
[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)



```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  dpi = 300,
  out.width = "100%",
  fig.path = "man/figures/README-",
  message = FALSE,
  warning = FALSE
)
```

## Introduction

This package provides an easy way to indicate if two groups are significantly
different. Commonly this is shown by a bar on top connecting the groups of
interest which itself is annotated with the level of significance (NS, \*, \*\*,
\*\*\*). The package provides a single layer (`geom_signif`) that takes the
groups for comparison and the test (t.test, wilcox etc.) and adds the annotation
to the plot.

## Citation

If you wish to cite this package in a publication, you can run the following
command in your R console:

```{r citation}
citation("ggsignif")
```

## Example

You can first install this package from `CRAN`:

```{r eval=FALSE}
install.packages("ggsignif")
```

Or get the latest development version:

```{r eval=FALSE}
install.packages("remotes")
remotes::install_github("const-ae/ggsignif")
```

Plot significance

```{r simpe_comparison}
library(ggplot2)
library(ggsignif)

p1 <- ggplot(mpg, aes(class, hwy)) +
  geom_boxplot() +
  geom_signif(
    comparisons = list(c("compact", "midsize"), c("minivan", "suv")),
    map_signif_level = TRUE, textsize = 6
  ) +
  ylim(NA, 48)
p1
```

Control the direction (either `x` or `y`) via `orientation` 

```{r orientation_argument}
p2 <- ggplot(
  data = mpg,
  mapping = aes(
    x = hwy,
    y = class
  )
) +
  geom_boxplot(
    orientation = "y"
  ) +
  geom_signif(
    comparisons = list(
      c("compact", "midsize"),
      c("minivan", "suv")
    ),
    map_signif_level = TRUE,
    textsize = 6,
    margin_top = 0.08,
    step_increase = 0.05,
    tip_length = 0.01,
    orientation = "y"
  )
p2
```

Compatible with coord_flip

```{r coord_flip}
p1 + coord_flip()
``` 

Setting the precise location

This is important if you use `position="dodge"`, because in that case I cannot
calculate the correct position of the bars automatically.

```{r dodge_comparison}
# Calculate annotation
anno <- t.test(
  iris[iris$Petal.Width > 1 & iris$Species == "versicolor", "Sepal.Width"],
  iris[iris$Species == "virginica", "Sepal.Width"]
)$p.value

# Make plot with custom x and y position of the bracket
ggplot(iris, aes(x = Species, y = Sepal.Width, fill = Petal.Width > 1)) +
  geom_boxplot(position = "dodge") +
  geom_signif(
    annotation = formatC(anno, digits = 1),
    y_position = 4.05, xmin = 2.2, xmax = 3,
    tip_length = c(0.2, 0.04)
  )
```

`ggsignif` is compatible with facetting (`facet_wrap` or `facet_grid`). The significance label is calculated for each facet where the axis labels listed in `comparisons` occur. Note that `ggsignif` fails to calculate the significance if the data is grouped globally (e.g., by setting `color`, `fill`, or `group` in `ggplot(aes(...))`). It is fine to group the data per geom (e.g., set the fill within `geom_boxplot(aes(fill = ...)))`.

```{r faceted_simple}
ggplot(diamonds, aes(x = cut, y = carat)) +
  geom_boxplot(aes(fill = color)) +
  geom_signif(comparisons = list(
    c("Fair", "Good"),
    c("Very Good", "Ideal")
  )) +
  facet_wrap(~color) +
  ylim(NA, 6.3)
```



## Advanced Example

Sometimes one needs to have a very fine tuned ability to set the location of the
the significance bars in combination with `facet_wrap` or `facet_grid`. In those
cases it you can set the flag `manual=TRUE` and provide the annotations as a
data.frame:

```{r faceted_comparison}
annotation_df <- data.frame(
  color = c("E", "H"),
  start = c("Good", "Fair"),
  end = c("Very Good", "Good"),
  y = c(3.6, 4.7),
  label = c("Comp. 1", "Comp. 2")
)

annotation_df

ggplot(diamonds, aes(x = cut, y = carat)) +
  geom_boxplot() +
  geom_signif(
    data = annotation_df,
    aes(xmin = start, xmax = end, annotations = label, y_position = y),
    textsize = 3, vjust = -0.2,
    manual = TRUE
  ) +
  facet_wrap(~color) +
  ylim(NA, 5.3)
```

You can ignore the warning about the missing aesthetics.

For further details, see:


## Maintenance

This package is provided as is and we currently don't have any plans and the
capacity to add any new features to it. If there is nonetheless a feature which
you would like to see in the package, you are always welcome to submit pull
request, which we will try to address as soon as possible.

## Code of Conduct
  
Please note that the `ggsignif` project is released with a [Contributor Code of Conduct](https://const-ae.github.io/ggsignif/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.

Owner

  • Name: Constantin
  • Login: const-ae
  • Kind: user
  • Location: Heidelberg, Germany
  • Company: EMBL

PhD Student, Biostats, R

Citation (CITATION.cff)

# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.2.1
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------
 
cff-version: 1.2.0
message: 'To cite package "ggsignif" in publications use:'
type: software
license: GPL-3.0-only
title: 'ggsignif: Significance Brackets for ''ggplot2'''
version: 0.6.3.9000
doi: 10.31234/osf.io/7awm6
abstract: Enrich your 'ggplots' with group-wise comparisons. This package provides
  an easy way to indicate if two groups are significantly different. Commonly this
  is shown by a bracket on top connecting the groups of interest which itself is annotated
  with the level of significance (NS, *, **, ***). The package provides a single layer
  (geom_signif()) that takes the groups for comparison and the test (t.test(), wilcox.text()
  etc.) as arguments and adds the annotation to the plot.
authors:
- family-names: Ahlmann-Eltze
  given-names: Constantin
  email: artjom31415@googlemail.com
  orcid: https://orcid.org/0000-0002-3762-068X
- family-names: Patil
  given-names: Indrajeet
  email: patilindrajeet.science@gmail.com
  orcid: https://orcid.org/0000-0003-1995-6531
preferred-citation:
  type: article
  title: 'ggsignif: R Package for Displaying Significance Brackets for ''ggplot2'''
  authors:
  - family-names: Constantin
    given-names: Ahlmann-Eltze
  - family-names: Patil
    given-names: Indrajeet
    email: patilindrajeet.science@gmail.com
    orcid: https://orcid.org/0000-0003-1995-6531
  year: '2021'
  journal: PsyArxiv
  url: https://psyarxiv.com/7awm6
  doi: 10.31234/osf.io/7awm6
repository: https://CRAN.R-project.org/package=ggsignif
repository-code: https://github.com/const-ae/ggsignif
url: https://const-ae.github.io/ggsignif/
contact:
- family-names: Ahlmann-Eltze
  given-names: Constantin
  email: artjom31415@googlemail.com
  orcid: https://orcid.org/0000-0002-3762-068X
keywords:
- asterisk
- ggplot-extension
- ggplot2
- rstats
- significance-stars
references:
- type: software
  title: ggplot2
  abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics'
  notes: Imports
  authors:
  - family-names: Wickham
    given-names: Hadley
    email: hadley@rstudio.com
    orcid: https://orcid.org/0000-0003-4757-117X
  - family-names: Chang
    given-names: Winston
    orcid: https://orcid.org/0000-0002-1576-2126
  - family-names: Henry
    given-names: Lionel
  - family-names: Pedersen
    given-names: Thomas Lin
    email: thomas.pedersen@rstudio.com
    orcid: https://orcid.org/0000-0002-5147-4711
  - family-names: Takahashi
    given-names: Kohske
  - family-names: Wilke
    given-names: Claus
    orcid: https://orcid.org/0000-0002-7470-9261
  - family-names: Woo
    given-names: Kara
    orcid: https://orcid.org/0000-0002-5125-4188
  - family-names: Yutani
    given-names: Hiroaki
    orcid: https://orcid.org/0000-0002-3385-7233
  - family-names: Dunnington
    given-names: Dewey
    orcid: https://orcid.org/0000-0002-9415-4582
  year: '2022'
  url: https://CRAN.R-project.org/package=ggplot2
  version: '>= 3.3.5'
- type: software
  title: knitr
  abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
  notes: Suggests
  authors:
  - family-names: Xie
    given-names: Yihui
    email: xie@yihui.name
    orcid: https://orcid.org/0000-0003-0645-5666
  year: '2022'
  url: https://CRAN.R-project.org/package=knitr
- type: software
  title: rmarkdown
  abstract: 'rmarkdown: Dynamic Documents for R'
  notes: Suggests
  authors:
  - family-names: Allaire
    given-names: JJ
    email: jj@rstudio.com
  - family-names: Xie
    given-names: Yihui
    email: xie@yihui.name
    orcid: https://orcid.org/0000-0003-0645-5666
  - family-names: McPherson
    given-names: Jonathan
    email: jonathan@rstudio.com
  - family-names: Luraschi
    given-names: Javier
    email: javier@rstudio.com
  - family-names: Ushey
    given-names: Kevin
    email: kevin@rstudio.com
  - family-names: Atkins
    given-names: Aron
    email: aron@rstudio.com
  - family-names: Wickham
    given-names: Hadley
    email: hadley@rstudio.com
  - family-names: Cheng
    given-names: Joe
    email: joe@rstudio.com
  - family-names: Chang
    given-names: Winston
    email: winston@rstudio.com
  - family-names: Iannone
    given-names: Richard
    email: rich@rstudio.com
    orcid: https://orcid.org/0000-0003-3925-190X
  year: '2022'
- type: software
  title: testthat
  abstract: 'testthat: Unit Testing for R'
  notes: Suggests
  authors:
  - family-names: Wickham
    given-names: Hadley
    email: hadley@rstudio.com
  year: '2022'
  url: https://CRAN.R-project.org/package=testthat
- type: software
  title: vdiffr
  abstract: 'vdiffr: Visual Regression Testing and Graphical Diffing'
  notes: Suggests
  authors:
  - family-names: Henry
    given-names: Lionel
    email: lionel@rstudio.com
  - family-names: Pedersen
    given-names: Thomas Lin
    email: thomas.pedersen@rstudio.com
    orcid: https://orcid.org/0000-0002-5147-4711
  - family-names: Luciani
    given-names: T Jake
    email: jake@apache.org
  - family-names: Decorde
    given-names: Matthieu
    email: matthieu.decorde@ens-lyon.fr
  - family-names: Lise
    given-names: Vaudor
    email: lise.vaudor@ens-lyon.fr
  year: '2022'
  url: https://CRAN.R-project.org/package=vdiffr
  version: '>= 1.0.2'

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "identifier": "ggsignif",
  "description": "Enrich your 'ggplots' with group-wise comparisons. This package provides an easy way to indicate if two groups are significantly different. Commonly this is shown by a bracket on top connecting the groups of interest which itself is annotated with the level of significance (NS, *, **, ***). The package provides a single layer (geom_signif()) that takes the groups for comparison and the test (t.test(), wilcox.text() etc.) as arguments and adds the annotation to the plot.",
  "name": "ggsignif: Significance Brackets for 'ggplot2'",
  "relatedLink": [
    "https://const-ae.github.io/ggsignif/",
    "https://CRAN.R-project.org/package=ggsignif"
  ],
  "codeRepository": "https://github.com/const-ae/ggsignif",
  "license": "https://spdx.org/licenses/GPL-3.0",
  "version": "0.6.4",
  "programmingLanguage": {
    "@type": "ComputerLanguage",
    "name": "R",
    "url": "https://r-project.org"
  },
  "runtimePlatform": "R version 4.1.1 (2021-08-10)",
  "provider": {
    "@id": "https://cran.r-project.org",
    "@type": "Organization",
    "name": "Comprehensive R Archive Network (CRAN)",
    "url": "https://cran.r-project.org"
  },
  "author": [
    {
      "@type": "Person",
      "givenName": "Constantin",
      "familyName": "Ahlmann-Eltze",
      "email": "artjom31415@googlemail.com",
      "@id": "https://orcid.org/0000-0002-3762-068X"
    },
    {
      "@type": "Person",
      "givenName": "Indrajeet",
      "familyName": "Patil",
      "email": "patilindrajeet.science@gmail.com",
      "@id": "https://orcid.org/0000-0003-1995-6531"
    }
  ],
  "contributor": [
    {
      "@type": "Person",
      "givenName": "Constantin",
      "familyName": "Ahlmann-Eltze",
      "email": "artjom31415@googlemail.com",
      "@id": "https://orcid.org/0000-0002-3762-068X"
    },
    {
      "@type": "Person",
      "givenName": "Indrajeet",
      "familyName": "Patil",
      "email": "patilindrajeet.science@gmail.com",
      "@id": "https://orcid.org/0000-0003-1995-6531"
    }
  ],
  "maintainer": [
    {
      "@type": "Person",
      "givenName": "Constantin",
      "familyName": "Ahlmann-Eltze",
      "email": "artjom31415@googlemail.com",
      "@id": "https://orcid.org/0000-0002-3762-068X"
    }
  ],
  "softwareSuggestions": [
    {
      "@type": "SoftwareApplication",
      "identifier": "knitr",
      "name": "knitr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=knitr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "rmarkdown",
      "name": "rmarkdown",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rmarkdown"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "testthat",
      "name": "testthat",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=testthat"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "vdiffr",
      "name": "vdiffr",
      "version": ">= 1.0.2",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=vdiffr"
    }
  ],
  "softwareRequirements": {
    "1": {
      "@type": "SoftwareApplication",
      "identifier": "ggplot2",
      "name": "ggplot2",
      "version": ">= 3.3.5",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=ggplot2"
    },
    "SystemRequirements": null
  },
  "fileSize": "906.037KB",
  "citation": [
    {
      "@type": "ScholarlyArticle",
      "datePublished": "2021",
      "author": [
        {
          "@type": "Person",
          "givenName": "Ahlmann-Eltze",
          "familyName": "Constantin"
        },
        {
          "@type": "Person",
          "givenName": "Indrajeet",
          "familyName": "Patil"
        }
      ],
      "name": "{ggsignif}: R Package for Displaying Significance Brackets for {'ggplot2'}",
      "identifier": "10.31234/osf.io/7awm6",
      "url": "https://psyarxiv.com/7awm6",
      "@id": "https://doi.org/10.31234/osf.io/7awm6",
      "sameAs": "https://doi.org/10.31234/osf.io/7awm6",
      "isPartOf": {
        "@type": "PublicationIssue",
        "datePublished": "2021",
        "isPartOf": {
          "@type": [
            "PublicationVolume",
            "Periodical"
          ],
          "name": "PsyArxiv"
        }
      }
    }
  ],
  "releaseNotes": "https://github.com/const-ae/ggsignif/blob/master/NEWS.md",
  "readme": "https://github.com/const-ae/ggsignif/blob/main/README.md",
  "contIntegration": "https://app.codecov.io/gh/const-ae/ggsignif?branch=main",
  "developmentStatus": "https://lifecycle.r-lib.org/articles/stages.html",
  "keywords": [
    "rstats",
    "ggplot-extension",
    "significance-stars",
    "ggplot2",
    "asterisk"
  ]
}

GitHub Events

Total
  • Issues event: 7
  • Watch event: 21
  • Issue comment event: 13
Last Year
  • Issues event: 7
  • Watch event: 21
  • Issue comment event: 13

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 171
  • Total Committers: 11
  • Avg Commits per committer: 15.545
  • Development Distribution Score (DDS): 0.468
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
const-ae a****5@g****m 91
Indrajeet Patil p****e@g****m 55
xiangpin x****n@1****m 6
Ilia Kats i****s@g****t 6
Roman Hillje r****e@g****m 5
Artjom-Metro A****o 3
SMargell 3****l 1
Michael Chirico m****4@g****m 1
M-Colley 3****y 1
Luca Albergante l****e@g****m 1
Jakub Kaczmarzyk j****k@m****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 79
  • Total pull requests: 36
  • Average time to close issues: about 1 year
  • Average time to close pull requests: 1 day
  • Total issue authors: 63
  • Total pull request authors: 7
  • Average comments per issue: 2.96
  • Average comments per pull request: 1.03
  • Merged pull requests: 35
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 5
  • Pull requests: 0
  • Average time to close issues: about 9 hours
  • Average time to close pull requests: N/A
  • Issue authors: 5
  • Pull request authors: 0
  • Average comments per issue: 0.6
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • IndrajeetPatil (10)
  • Rsigni (3)
  • Saadi4469 (3)
  • MPietzke (2)
  • bersbersbers (2)
  • QuentinRoy (2)
  • eleonore-schneeg (1)
  • JulianStopp (1)
  • Lucas97223 (1)
  • JCSzamosi (1)
  • jchellmuth (1)
  • nishuai (1)
  • yesitsjess (1)
  • ACMGlueck (1)
  • elcega (1)
Pull Request Authors
  • IndrajeetPatil (33)
  • MichaelChirico (2)
  • elnaggarj (1)
  • M-Colley (1)
  • romanhaa (1)
  • const-ae (1)
  • xiangpin (1)
Top Labels
Issue Labels
enhancement (10) question (10) reprex (6) planning :calendar: (3) bug (3) help wanted (3) documentation :newspaper: (2) wontfix (2)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cran 121,511 last-month
  • Total docker downloads: 176,909
  • Total dependent packages: 7
    (may contain duplicates)
  • Total dependent repositories: 39
    (may contain duplicates)
  • Total versions: 26
  • Total maintainers: 1
cran.r-project.org: ggsignif

Significance Brackets for 'ggplot2'

  • Versions: 10
  • Dependent Packages: 5
  • Dependent Repositories: 31
  • Downloads: 121,511 Last month
  • Docker Downloads: 176,909
Rankings
Stargazers count: 0.7%
Downloads: 1.1%
Forks count: 1.8%
Dependent repos count: 4.8%
Average: 5.8%
Dependent packages count: 9.1%
Docker downloads count: 17.3%
Maintainers (1)
Last synced: 4 months ago
proxy.golang.org: github.com/const-ae/ggsignif
  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.5%
Average: 6.7%
Dependent repos count: 6.9%
Last synced: 4 months ago
conda-forge.org: r-ggsignif
  • Versions: 7
  • Dependent Packages: 2
  • Dependent Repositories: 8
Rankings
Dependent repos count: 12.2%
Stargazers count: 17.5%
Average: 19.4%
Dependent packages count: 19.6%
Forks count: 28.2%
Last synced: 4 months ago

Dependencies

DESCRIPTION cran
  • ggplot2 >= 3.3.5 imports
  • knitr * suggests
  • rmarkdown * suggests
  • testthat * suggests
  • vdiffr >= 1.0.2 suggests
.github/workflows/check-full.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
.github/workflows/lint.yml actions
  • actions/checkout v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2-branch composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite