Venn diagram proportional and color shading with semi-transparency

RPlotVenn Diagram

R Problem Overview


I have following type of count data.

A	450
B	1800
A and B both 	230

I want to develop a colorful (possibly semi-transparency at intersections) like the following Venn diagram.

enter image description here

Note: This figure is an example hand drawn in PowerPoint, and it is not to scale.

R Solutions


Solution 1 - R

Here is a post which discusses https://stackoverflow.com/questions/8153594/venn-diagram-from-list-of-clusters-and-co-occuring-factors.

For easy solution use package venneuler:

require(venneuler)
v <- venneuler(c(A=450, B=1800, "A&B"=230))
plot(v)

enter image description here

For more advanced and customized solutions check package VennDiagram.

library(VennDiagram) 
venn.diagram(list(B = 1:1800, A = 1571:2020), fill = c("lightblue", "green"), 
             alpha = c(0.5, 0.5), lwd =0, "venn_diagram.tiff")

enter image description here

Solution 2 - R

I have recently published a new R package, eulerr, which does what you want. It is quite similar to venneuler but without its inconsistencies.

library(eulerr)
fit <- euler(c(A = 450, B = 1800, "A&B" = 230))
plot(fit)

eulerplot

Or you could try the shiny application for the same r package at eulerr.co

shiny-euler

Solution 3 - R

Based on second answer by Geek On Acid second suggestion ( thanks once again ) I would able sove the line problem as well. I am posting if this is relevent to other googlers !

  require(VennDiagram)
    venn.diagram(list(B = 1:1800, A = 1571:2020),fill = c("red", "green"),
  alpha = c(0.5, 0.5), cex = 2,cat.fontface = 4,lty =2, fontfamily =3, 
   filename = "trial2.emf");

enter image description here

Solution 4 - R

Even though this doesnt answer your question completely. I thought that this will be useful for other people looking to plot Venn Diagram. One can use the venn() function from the gplots package: http://www.inside-r.org/packages/cran/gplots/docs/venn

## modified slightly from the example given in the documentation
## Example using a list of item names belonging to the
## specified group.
##
require(gplots) 
## construct some fake gene names..
oneName <- function() paste(sample(LETTERS,5,replace=TRUE),collapse="")
geneNames <- replicate(1000, oneName())
 
## 
GroupA <- sample(geneNames, 400, replace=FALSE)
GroupB <- sample(geneNames, 750, replace=FALSE)
GroupC <- sample(geneNames, 250, replace=FALSE)
GroupD <- sample(geneNames, 300, replace=FALSE)
 
venn(list(GrpA=GroupA,GrpB=GroupB,GrpC=GroupC,GrpD=GroupD))

enter image description here Afterwards I just add colours and transparency using illustrator. enter image description here

Solution 5 - R

There is an intuitive and flexible proportional plotter that you can download and run. Find it at: http://omics.pnl.gov/software/VennDiagramPlotter.php

and

jvenn: an interactive Venn diagram viewer - GenoToul Bioinfo: http://bioinfo.genotoul.fr/jvenn/

Solution 6 - R

I know that the OP asks about a solution in R but I would like to point to a web-based solution called BioVenn. It takes up to 3 lists of elements and draws a Venn diagram so that each surface is proportional to the number of elements - like this one:

enter image description here

In this diagram I have changed manually (via PhotoShop) the placement of the numbers as I did not like the locations chosen by BioVenn. But you can chose not to have numbers.

In theory the lists used with BioVenn shall consist of gene IDs but, in practice, it doesn't matter - the lists simply have to contain strings.

Solution 7 - R

FWIW: found this package for python that does the same thing.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjonView Question on Stackoverflow
Solution 1 - RGeek On AcidView Answer on Stackoverflow
Solution 2 - RJohan LarssonView Answer on Stackoverflow
Solution 3 - RjonView Answer on Stackoverflow
Solution 4 - RktyagiView Answer on Stackoverflow
Solution 5 - RNirupa ChaudhariView Answer on Stackoverflow
Solution 6 - RNick stands with UkraineView Answer on Stackoverflow
Solution 7 - RmithunpaulView Answer on Stackoverflow