-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10d5448
commit eaf9df9
Showing
3 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: ggVennDiagram | ||
Type: Package | ||
Title: A 'ggplot2' Implement of Venn Diagram | ||
Version: 1.5.0 | ||
Version: 1.5.1 | ||
Authors@R: c( | ||
person("Chun-Hui","Gao", email="[email protected]", role=c("aut","cre"), comment=c(ORCID = "0000-0002-1445-7939")), | ||
person("Guangchuang", "Yu", email = "[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0002-6485-8781")), | ||
|
@@ -40,6 +40,7 @@ Suggests: | |
knitr, | ||
plotly, | ||
RColorBrewer, | ||
shiny | ||
shiny, | ||
rmarkdown | ||
VignetteBuilder: knitr | ||
LazyData: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
title: "Venn Calculator" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{VennCalculator} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
## How to use Venn Calculator? | ||
|
||
`ggVennDiagram` has a series of set operation functions, and this can be used as the Venn calculator. | ||
|
||
```{r setup} | ||
library(ggVennDiagram) | ||
set.seed(20231225) | ||
y = list( | ||
A = sample(letters, 8) |> sort(), | ||
B = sample(letters, 8) |> sort(), | ||
C = sample(letters, 8) |> sort(), | ||
D = sample(letters, 8) |> sort()) | ||
y | ||
``` | ||
|
||
First of all, we need to construct a `Venn` class object with this list. If you print this object, it will give meta information of the object. | ||
|
||
```{r} | ||
venn_y = Venn(y) | ||
venn_y | ||
``` | ||
|
||
* Find the overlapping members of two or more sets. | ||
|
||
```{r} | ||
overlap(venn_y, 1:2) # members in both the first two sets | ||
overlap(venn_y) # members in all the sets | ||
``` | ||
|
||
* Find the different members between sets and set unions | ||
|
||
```{r} | ||
discern(venn_y, 1) # members in set 1, but not in the resting sets | ||
discern(venn_y, c("A","B"), 3) # members in set A & B, but not in the 3rd set | ||
``` | ||
|
||
* Find the specific members in one or more sets | ||
|
||
```{r} | ||
discern_overlap(venn_y, 1) # specific items in set 1 | ||
discern_overlap(venn_y, 1:2) # specific items in set 1 and set 2 | ||
``` | ||
|
||
* Find the union of two or more sets | ||
|
||
```{r} | ||
unite(venn_y, 1:2) # union of set 1 and 2 | ||
unite(venn_y, "all") # union of all four sets | ||
unite(venn_y, c("A", "B", "C")) | ||
``` | ||
|
||
Combined results were provided as VennPlotData object. | ||
|
||
```{r} | ||
pd = process_data(venn_y) | ||
pd | ||
``` | ||
|
||
* `venn_set()`: get set data from the object. | ||
|
||
```{r} | ||
venn_set(pd) | ||
``` | ||
|
||
* `venn_region()`: get subsets data from the object. | ||
|
||
```{r} | ||
venn_region(pd) | ||
``` | ||
|
||
Please note in order to keep the result concise, the containing items are nested. You may use the following methods to further process it. | ||
|
||
* Method 1 | ||
|
||
```{r} | ||
venn_region(pd) |> tidyr::unnest(item) | ||
``` | ||
|
||
* Method 2 | ||
|
||
```{r} | ||
venn_region(pd) |> dplyr::rowwise() |> dplyr::mutate(item = paste0(item, collapse = ", ")) | ||
``` | ||
|
||
|
||
## Reference | ||
|
||
Some of these above-mentioned functions are originally developed by Turgut Yigit Akyol in `RVenn`. | ||
|
||
* Akyol T (2019). _RVenn: Set Operations for Many Sets_. R package version 1.1.0, | ||
<https://CRAN.R-project.org/package=RVenn>. |