vennchart: Making Venn/Eular charts

Description Usage Arguments Value Note Examples

Description

This function takes three-variable values and their overlapped values and fit to a Venn chart. (The value of where three variables overlap may not fit exactly.)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
vennchart(A_all, B_all, C_all, 
          AandB, AandC, BandC)
vennChart(A_all , B_all , C_all ,
          AandB , AandC , BandC,
          plot = TRUE, 
          colors = list(rgb(0,0,1,0.3), rgb(1,0, 0, 0.3), rgb(0, 1, 0, 0.3)),
          frameadj = 1.5, line  = NA, lwd = 2, 
          texts = TRUE, names = c("A", "B", "C"),
          Value = TRUE, cex = 1, textadj = c(0.5, 0.5),
          connect = "\n", unit = " ", digits = 3)

plotVenn(V, 
         color = list(rgb(0,0,1,0.3), rgb(1,0, 0, 0.3), rgb(0, 1, 0, 0.3)),
         line  = NA,lwd = 2, frameadj = 1.5)
plotVennTexts(P, Atext = "A", Btext = "B", Ctext = "C", 
              ABtext = " ", ACtext = " ", BCtext = " ",
              Value = TRUE, cex = 1, connect = "\n", unit = " ")
          
          

Arguments

A_all, B_all, C_all

Values of variable A, B and C. The area of circles corresponds to these values.

AandB, AandC, BandC

Value of intersections between two variables. The values correspond to the ovelaping circle area. Note that the overlaping area of three variables are not considered in rendering the plot.

plot

Whether to make the plot (default: TRUE)

colors

List of 3 color arguments, each item correspond to one variable, and will be passed to the polygon{graphics} function.

frameadj

The size of the frame realtive to the minimal suqure to fit the graph.(Default : 1.5)

lim

A list of two arrays, passing to function plot as xlim and ylim. Default is "NULL", that means calculat x, y limits from the frameadj value. This argument will overwrite the frameadj argument.

line

Eadge lines to the circles, the argyment will be passed to the polygon{graphics} function. Default is NA (no lines).

lwd

Eadge line width of the circles, the argyment will be passed to the polygon{graphics} function. Default is 2 (but will be ignored when line = NA).

texts

Whether to print texts on the plot. Default is TRUE.

names

An array of strings, names given to the three circles (variables).

value

whether to add variable values (A_all, B_all, ...) to the printed texts. Default is TRUE.

cex

Relative text size, will be passed to the text{graphics} function. Default is 1.

textadj

An array of 2 numerics.The locations of text (variables and overlapped area), as distance from a center in the unit of the radius. Default is c(0.5, 0.5).

connect

A string. Attached between the variable names and values if values are printed. Default is "\n" (print value in a new line).

unit

A string. Attached to the end of the variable value if values are printed. Default is " "

V

The item "circle" from the output of vennChart(). See example.

P

The item "textspos" from the output of vennChart(). See example.

Atext, Btext, Ctext

Strings, the names of vairiables. (As the elements in the names argument.)

ABtext, ACtext, BCtext

Strings of the overlaping area.

Value

circles

A list of centers (c1, c2, c3) and radius (r1, r2, r3) of the three circles.

textpos

Alist of calculated text positions.

Note

Set the output format to be square so the circles look right. In .Rmd notebooks, use fig.width = s, fig.height = s to make the output figure square.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# the vairiable values

  co_A <- 10
  co_B <- 12
  co_C <- 3
  co_AB <- 1.9 # where AB overlapped 
  co_BC <- 0.5
  co_AC <-1

# make the plot with default 

  vennChart(A_all = co_A, B_all = co_B, C_all = co_C,
                AandB = co_AB, AandC = co_AC, BandC = co_BC)

# alter some things, and save the outputs in a new variable  

Q <- vennChart(A_all = co_A, B_all = co_B, C_all = co_C,
                AandB = co_AB, AandC = co_AC, BandC = co_BC,
               colors = list(rgb(0.145, 0.51, 0.71, 0.4), 
                             rgb(1, 0.78, 0.16, 0.4),
                             rgb(1, 0.32, 0.16, 0.4)),
               textadj = c(1, 0.2),
               cex = 1.5,
               frameadj = 1.1
               )
      # change plot color
      # put the text of the three variables on the edge (\code{textadj[1] = 1}.)
      # larger text font
      # relatively smaller frame

# plot and print text from the output of \code{vennChart}

  plotVenn(Q$circles, frameadj = 1.2)
  plotVennTexts(Q$textspos, unit = "%)", connect = ":\n(" )
  
  

weitingwlin/vennchart documentation built on May 4, 2019, 4:18 a.m.