• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    R
  • License
    Other
  • Created over 5 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Venn Diagram by ggplot2, with really easy-to-use API.

ggvenn

Venn Diagram by ggplot2, with really easy-to-use API. This package is inspired by Venny

Screenshots

Venn 2 Venn 3 Venn 4

Installation

install.packages("ggvenn") # install via CRAN

or

if (!require(devtools)) install.packages("devtools")
devtools::install_github("yanlinlin82/ggvenn") # install via GitHub (for latest version)

Quick Start

This package supports both list and data.frame type data as input.

For list data (each element is a set):

library(ggvenn)

a <- list(`Set 1` = c(1, 3, 5, 7, 9),
          `Set 2` = c(1, 5, 9, 13),
          `Set 3` = c(1, 2, 8, 9),
          `Set 4` = c(6, 7, 10, 12))
ggvenn(a, c("Set 1", "Set 2"))            # draw two-set venn
ggvenn(a, c("Set 1", "Set 2", "Set 3"))   # draw three-set venn
ggvenn(a)   # without set names, the first 4 elements in list will be chose to draw four-set venn

For data.frame data (each logical column is a set):

d <- tibble(value   = c(1,     2,     3,     5,     6,     7,     8,     9),
            `Set 1` = c(TRUE,  FALSE, TRUE,  TRUE,  FALSE, TRUE,  FALSE, TRUE),
            `Set 2` = c(TRUE,  FALSE, FALSE, TRUE,  FALSE, FALSE, FALSE, TRUE),
            `Set 3` = c(TRUE,  TRUE,  FALSE, FALSE, FALSE, FALSE, TRUE,  TRUE),
            `Set 4` = c(FALSE, FALSE, FALSE, FALSE, TRUE,  TRUE,  FALSE, FALSE))
ggvenn(d, c("Set 1", "Set 2"))           # draw two-set venn
ggvenn(d, c("Set 1", "Set 2", "Set 3"))  # draw three-set venn
ggvenn(d)   # without set names, the first 4 logical column in data.frame will be chose to draw four-set venn

For data.frame data, there is also another way to plot in ggplot grammar:

# draw two-set venn (use A, B in aes)
ggplot(d, aes(A = `Set 1`, B = `Set 2`)) +
  geom_venn() + theme_void() + coord_fixed()

# draw three-set venn (use A, B, C in aes)
ggplot(d, aes(A = `Set 1`, B = `Set 2`, C = `Set 3`)) +
  geom_venn() + theme_void() + coord_fixed()

# draw four-set venn (use A, B, C, D in aes)
ggplot(d, aes(A = `Set 1`, B = `Set 2`, C = `Set 3`, D = `Set 4`)) +
  geom_venn() + theme_void() + coord_fixed()

More Options

There are more options for customizing the venn diagram.

  1. Tune the color and size

    For filling:

    • fill_color - default is c("blue", "yellow", "green", "red")
    • fill_alpha - default is 0.5

    For stroke:

    • stroke_color - default is "black"
    • stroke_alpha - default is 1
    • stroke_size - default is 1
    • stroke_linetype - default is "solid"

    For set name:

    • set_name_color - default is "black"
    • set_name_size - default is 6

    For text:

    • text_color - default is "black"
    • text_size - default is 4

    All parameters above could be used in both ggvenn() and geom_venn().

    For example:

    a <- list(A = 1:4, B = c(1,3,5))
    ggvenn(a, stroke_linetype = 2, stroke_size = 0.5,
      set_name_color = "red", set_name_size = 15,
      fill_color = c("pink", "gold"))
    
  2. Show elements

    • show_elements - default is FALSE
    • label_sep - text used to concatenate elements, default is ","

    For example:

    a <- list(A = c("apple", "pear", "peach"),
              B = c("apple", "lemon"))
    ggvenn(a, show_elements = TRUE)
    
    ggvenn(a, show_elements = TRUE, label_sep = "\n")  # show elements in line
    
  3. Hide percentage

    • show_percentage - default is TRUE

    For example:

    a <- list(A = 1:5, B = 1:2)
    ggvenn(a, show_percentage = FALSE)
    
  4. Change digits of percentage

    • digits - default is 1

    For example:

    a <- list(A = 1:5, B = 1:2)
    ggvenn(a, digits = 2)
    

Data Format

The ggvenn support two types of input data: list and data.frame. Two functions (data_frame_to_list() and list_to_data_frame()) can convert data between the two types.

a <- list(A = 1:5, B = 4:6)
d <- tibble(key = 1:6,
            A = c(rep(TRUE, 5), FALSE),
            B = rep(c(FALSE, TRUE), each = 3))

identical(a, data_frame_to_list(d))  # TRUE
identical(d, list_to_data_frame(a))  # TRUE

More Repositories

1

plcscan

Automatically exported from code.google.com/p/plcscan
Python
55
star
2

simple-style

My simple style hugo theme, based on <https://yanlinlin82.github.io/webpage-templates/simple-style/index.html>
HTML
30
star
3

Rmagic

解构R语言中的“黑魔法”
CSS
16
star
4

leetcode

刷leetcode算法题库
C++
12
star
5

WeChatRot

(已废弃项目)微信机器人:向多个微信群同时发送图文直播
JavaScript
11
star
6

libffc

Free Foundation Classes
C++
9
star
7

ggturtle

Use ggplot2 to draw like turtle in LOGO language
R
7
star
8

seqpipe

A framework for SEQuencing data analysis PIPElines.
Perl
7
star
9

bntools

Tools for BioNano data analysis
C
5
star
10

color-printf

Colorize Text Output in C++
C++
5
star
11

what-deep-learning-does-in-biomedicine

A homework of literature review about learning what deep learning doing in biomed field.
Python
5
star
12

single-cell-papers

Database for collecting and curating scientific papers related to single-cell and spatial transcriptomics sequencing.
Python
4
star
13

ggmaze

R
3
star
14

cpp-webui

C++
3
star
15

ARTS-Weekly

左耳听风ARTS(Algorithm, Review, Tip, Share)每周打卡
Shell
3
star
16

yanlinlin.cn

Linlin Yan's personal website in Chinese, where a 20+ yrs programmer and researcher collects good things for sharing.
R
3
star
17

XCAVATOR

A CNV caller of NGS data. This repo is for recording bug-fixings. Original source code is from https://sourceforge.net/projects/xcavator/, which has no any modification since 2017-10-12.
R
3
star
18

fuseek

A fusion detection tool written in perl.
Perl
2
star
19

kids.typing

A Typing Game for Kids. 用R语言手工打造的供娃练指法的小程序
R
2
star
20

icpp

an interpreter for C++
C++
2
star
21

jsonxx

JSON++: A lightweight and easey-to-use JSON parser/manipulator implemented in C++ new standards
C++
2
star
22

tsv

A single perl script to make text file tables manipulating in command line as easy as in R package dplyr
Shell
2
star
23

blast-seed

Perl
2
star
24

auth-watch

Generate or update IP black list by watching /var/log/auth.log
Shell
2
star
25

enhdebug

Enhanced DEBUG for PC DOS and MS-DOS (copied from https://sites.google.com/site/pcdosretro/enhdebug)
Assembly
2
star
26

9x9

九九表
R
2
star
27

Rbionano

[obsolete] R package for BioNano data manipulation and visualization
R
2
star
28

EMBOSS

WARNING: This is _NOT OFFICIAL_ source repository of EBI EMBOSS (The European Molecular Biology Open Software Suite)! I use this repository to record some modifications/bug-fixings.
C
2
star
29

191019a_900-Cells

R
1
star
30

gentoo-utils

Shell
1
star
31

dot-files

My Best Practice on Linux Configure Files
Shell
1
star
32

stock-leverage

关于股票融资杠杆的计算
R
1
star
33

access-wuhan-2019-ncov

获取武汉2019-nCoV序列数据
1
star
34

r-2048

2048 Game in R
R
1
star
35

synthetic-biology-papers

Database for collecting and curating scientific papers related to synthetic biology.
Python
1
star
36

gurtle

Automatically exported from code.google.com/p/gurtle
C#
1
star
37

study-statistics

HTML
1
star
38

yanlinlin82

Config files for my GitHub profile.
1
star
39

openai-session-downloader

OpenAI Session Downloader
JavaScript
1
star
40

Rvenn

R package for venn diagram
R
1
star
41

COS-Salon-37

Presentation about lipid biopsy for COS Salon on Apr. 17, 2016.
CSS
1
star
42

eval-exp

There are two algorithms for evaluating an expression: by stack & by recursive function.
C++
1
star
43

immortality-research

1
star
44

191017a_Color-Filling

HTML
1
star
45

dup-file-scanner

Perl
1
star
46

flattracker

An issue tracker plug-in for TortoiseSVN.
C
1
star
47

how-to

how-to-list
1
star
48

bukaopuyanlun

个人微信公众号“不靠谱颜论”的文章链接目录
1
star
49

hba-hbb-dotmatcher

R
1
star
50

study-xwindow

C
1
star
51

mock-win

C
1
star
52

190805a_Search-Engines

R
1
star
53

181231a_Burn-Down-Chart-of-2018-Year

Shell
1
star
54

AI-Times

Collection of big news about AI
1
star
55

yanll-gentoo-overlay

Shell
1
star
56

paper-hub.cn

Python
1
star
57

ARTS-Weekly-BioMed

仿照《左耳听风》专栏ARTS每周打卡活动而启动的自学活动,内容面向生物信息/精准医疗。
Shell
1
star