ggVennDiagram

A 'ggplot2' implement of Venn Diagram.

https://github.com/gaospecial/ggvenndiagram

Science Score: 49.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: wiley.com
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.2%) to scientific vocabulary

Keywords

set-operations upset upsetplot venn-diagram venn-plot
Last synced: 6 months ago · JSON representation

Repository

A 'ggplot2' implement of Venn Diagram.

Basic Info
Statistics
  • Stars: 304
  • Watchers: 6
  • Forks: 45
  • Open Issues: 6
  • Releases: 9
Topics
set-operations upset upsetplot venn-diagram venn-plot
Created over 6 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License Roadmap

README.md

ggVennDiagram

<!-- badges: end -->

ggVennDiagram’ enables fancy Venn plot with 2-7 sets and generates publication quality figure. It also support upset plot with unlimited number of sets from version 1.4.4.

Installation

You can install the released version of ggVennDiagram from CRAN with:

r install.packages("ggVennDiagram")

And the development version from GitHub with:

``` r

install.packages("devtools")

devtools::install_github("gaospecial/ggVennDiagram") ```

Citation

If you find ggVennDiagram is useful and used it in academic papers, you may cite this package as:

Gao, C.-H., Chen, C., Akyol, T., Dușa, A., Yu, G., Cao, B., and Cai, P. (2024). ggVennDiagram: intuitive Venn diagram software extended. iMeta 3, 69. doi: 10.1002/imt2.177.

Features

Notes

The ggVennDiagram Shiny app can be accessed at Shinyapps.io (https://bio-spring.shinyapps.io/ggVennDiagram), or ggVennDiagram::launch_app() in local machine.

The TBtools plugin can be accessed through its plugin store.

Example

ggVennDiagram maps the fill color of each region to quantity, allowing us to visually observe the differences between different parts.

r library(ggVennDiagram) genes <- paste("gene",1:1000,sep="") set.seed(20231214) x <- list(A=sample(genes,300), B=sample(genes,525), C=sample(genes,440), D=sample(genes,350))

ggVennDiagram return a ggplot object, the fill/edge colors can be further modified with ggplot functions.

r library(ggplot2) ggVennDiagram(x) + scale_fill_gradient(low="grey90",high = "red")

``` r

ggVennDiagram(x, set_color = c("blue","red","green","purple")) ```

ggVennDiagram support 2-7 dimension Venn plot. The generated figure is generally ready for publish. The main function ggVennDiagram() will check how many items in the first parameter and call corresponding function automatically.

The parameter category.names is set names. And the parameter label can label how many items are included in each parts.

r ggVennDiagram(x,category.names = c("Stage 1","Stage 2","Stage 3", "Stage4"))

``` r

ggVennDiagram(x,category.names = c("Stage 1","Stage 2","Stage 3", "Stage4"), label = "none") ```

Set label_alpha = 0 to remove label background.

r ggVennDiagram(x, label_alpha=0)

Showing intersection values

Note: you need to install the GitHub version to enable these functions.

We implemented the process_region_data() to get intersection values.

``` r y <- list( A = sample(letters, 8), B = sample(letters, 8), C = sample(letters, 8), D = sample(letters, 8) )

processregiondata(Venn(y))

> # A tibble: 15 × 4

> id name item count

>

> 1 1 A 3

> 2 2 B 1

> 3 3 C 3

> 4 4 D 0

> 5 1/2 A/B 0

> 6 1/3 A/C 1

> 7 1/4 A/D 2

> 8 2/3 B/C 1

> 9 2/4 B/D 3

> 10 3/4 C/D 1

> 11 1/2/3 A/B/C 1

> 12 1/2/4 A/B/D 1

> 13 1/3/4 A/C/D 0

> 14 2/3/4 B/C/D 1

> 15 1/2/3/4 A/B/C/D 0

```

If only several items were included, intersections may also be viewed interactively by plotly method (if you have two many items, this is useless).

r ggVennDiagram(y, show_intersect = TRUE)

In web browser or RStudio, you will get:

Customizing your plot

There are three components in a Venn plot: 1) the set labels; 2) the edge of sets; and 3) the filling regions and labels (optional) of each parts. We separately stored these data in a structured VennPlotData object, in which labels, edges and regions are stored as data frames.

In general, ggVennDiagram() plot a Venn in three steps:

  • get the coordinates of a applicable shape from internal shapes datasets.
  • calculate sub regions of sets, including both the shape regions and sets members, and return a VennPlotData object that includes all necessary definitions. We implement a number of set operations functions to do this job.
  • plot using ggplot2 functions.

Please check vignette("fully-customed", package = "ggVennDiagram") for more information.

Venn Diagram for more than four sets

If you have reviewed my codes, you may find it is easy to support Venn Diagram for more than four sets, as soon as you find a ideal parameter to generate more circles or ellipses in the plot. The key point is to let the generated ellipses have exactly one intersection for each combination.

Venn Diagram of up to seven sets

From v1.0, ggVennDiagram can plot up to seven dimension Venn plot. Please note that the shapes for this five sets diagram, as well as those for six and seven sets, are imported from the original package venn authored by Adrian Dușa.

However, Venn Diagram for more than four sets may be meaningless in some conditions, as some parts may be omitted in such ellipses. Therefore, it is only useful in specific conditions. For example, if the set intersection of all group are extremely large, you may use several ellipses to draw a “flower” to show that.

``` r x <- list(A=sample(genes,300), B=sample(genes,525), C=sample(genes,440), D=sample(genes,350), E=sample(genes,200), F=sample(genes,150), G=sample(genes,100))

two dimension Venn plot

ggVennDiagram(x[1:2],label = "none")

three dimension Venn plot

ggVennDiagram(x[1:3],label = "none")

four dimension Venn plot

ggVennDiagram(x[1:4],label = "none")

five dimension Venn plot

ggVennDiagram(x[1:5],label = "none")

six dimension Venn plot

ggVennDiagram(x[1:6],label = "none")

seven dimension Venn plot

ggVennDiagram(x,label = "none") ```

Native support of upset plot

From version 1.4.4, ggVennDiagram supports unlimited number of sets, as it can draw a plain upset plot automatically when number of sets is more than 7.

``` r

add an extra member in list

x$H = sample(genes,500) ggVennDiagram(x)

> Warning in ggVennDiagram(x): Only support 2-7 dimension Venn diagram. Will give a plain upset plot instead.

> Warning: Removed 1 row containing missing values or values outside the scale range (geom_col()).

```

Upset plot can also be used by setting force_upset = TRUE.

r ggVennDiagram(x[1:4], force_upset = TRUE, order.set.by = "name", order.intersect.by = "none")

Since upset plot is consisted with upper panel and lower panel, and left panel and right panel, the appearance should be adjusted with different conditions. We provide two parameters, which are relative_height and relative_width to do this.

For example, if we want to give more space to lower panel, just change the relative_height from 3 (the default) to 2.

r venn = Venn(x) plot_upset(venn, nintersects = 30, relative_height = 2, relative_width = 0.3)

Reference

Adrian Dușa (2024) venn: Draw Venn Diagrams, R package version 1.12. https://CRAN.R-project.org/package=venn.

Owner

  • Name: Chun-Hui Gao
  • Login: gaospecial
  • Kind: user
  • Location: Wuhan, China
  • Company: Huazhong Agricultural University

Ph. D in BIOlogy, named after SPRING, interested in TOP science.

GitHub Events

Total
  • Release event: 1
  • Issues event: 5
  • Watch event: 21
  • Issue comment event: 8
  • Push event: 14
  • Pull request event: 2
  • Fork event: 4
Last Year
  • Release event: 1
  • Issues event: 5
  • Watch event: 21
  • Issue comment event: 8
  • Push event: 14
  • Pull request event: 2
  • Fork event: 4

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 158
  • Total Committers: 4
  • Avg Commits per committer: 39.5
  • Development Distribution Score (DDS): 0.025
Past Year
  • Commits: 4
  • Committers: 2
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.25
Top Committers
Name Email Commits
Chun-Hui Gao g****l@g****m 154
Adrian Dușa d****n@g****m 2
Yi Liu l****x@g****m 1
xiangpin x****n@1****m 1
Committer Domains (Top 20 + Academic)
163.com: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 67
  • Total pull requests: 12
  • Average time to close issues: 3 months
  • Average time to close pull requests: 22 days
  • Total issue authors: 60
  • Total pull request authors: 6
  • Average comments per issue: 2.18
  • Average comments per pull request: 0.17
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 6
  • Pull requests: 2
  • Average time to close issues: 3 days
  • Average time to close pull requests: 5 months
  • Issue authors: 6
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • crebli (2)
  • ying-ge (2)
  • joannawolthuis (2)
  • mmpust (2)
  • archymedes (2)
  • sfd99 (2)
  • realkrantz (1)
  • romanzenka (1)
  • MartinWitt (1)
  • larry1995 (1)
  • gavieira (1)
  • erikagucciardo (1)
  • jgarces02 (1)
  • pwwang (1)
  • gaospecial (1)
Pull Request Authors
  • gaospecial (5)
  • dusadrian (3)
  • andrewppurdy (2)
  • GuangchuangYu (2)
  • liuyigh (1)
  • xiangpin (1)
Top Labels
Issue Labels
enhancement (4) bug (1) good first issue (1)
Pull Request Labels

Packages

  • Total packages: 4
  • Total downloads:
    • cran 6,615 last-month
  • Total docker downloads: 11,405
  • Total dependent packages: 5
    (may contain duplicates)
  • Total dependent repositories: 13
    (may contain duplicates)
  • Total versions: 15
  • Total maintainers: 1
proxy.golang.org: github.com/gaospecial/ggVennDiagram
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.3%
Average: 5.5%
Dependent repos count: 5.7%
Last synced: 6 months ago
proxy.golang.org: github.com/gaospecial/ggvenndiagram
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.3%
Average: 5.5%
Dependent repos count: 5.7%
Last synced: 6 months ago
cran.r-project.org: ggVennDiagram

A 'ggplot2' Implement of Venn Diagram

  • Versions: 12
  • Dependent Packages: 5
  • Dependent Repositories: 12
  • Downloads: 6,615 Last month
  • Docker Downloads: 11,405
Rankings
Stargazers count: 1.8%
Forks count: 2.5%
Downloads: 6.7%
Dependent repos count: 8.4%
Average: 9.7%
Dependent packages count: 13.6%
Docker downloads count: 25.1%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: r-ggvenndiagram
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Dependent repos count: 24.4%
Stargazers count: 26.4%
Forks count: 30.8%
Average: 33.3%
Dependent packages count: 51.6%
Last synced: 6 months ago