0

The clinical experiment has 10 people give blood samples at three defined time points (t1,t2,t3). Not everyone was able to come to their appointment, so some people missed one or more of the samples, which is shown as "0". Others were at all three samples (t1 = "1", t2 = "1", t3 = "1").

My goal is to create a Venn Diagram using the ggvenndiagram pacakge with every intersecting area showing the number of people that gave their sample at the defined times (sets t1, t2, t3).

So in the middle is the fraction of people that gave all three requested samples. In the outer areas, without intersections, are the people that managed only one sample (e.g. subject Nr. 8 managed only the sample at t2, this should be displayed as "1" / "10 %" respectively. 4 people gave all three samples, so the middle of all three circles should show "4" / "40 %" respectively, for details see below).

Code&data:

library("ggVennDiagram") 
t1<-c(1,1,0,1,1,1,1,0,1,0) 
t2<-c(0,1,0,1,0,1,0,1,1,0) 
t3<-c(1,1,1,1,1,1,0,0,1,0) 
cbind(t1,t2,t3)
1
  • What have you tried so far?
    – Axeman
    Commented Jan 30, 2022 at 21:13

1 Answer 1

0

You could try:

ggVennDiagram(apply(cbind(t1, t2, t3), 2, function(x) which(x == 1)))

Note that people who did not show up for any visits can't easily be recorded, as they do not belong to any set (and there is no mechanism that I can find to assign to a "null" set), so the percentages are the percentage of people who participated.

Created on 2022-01-30 by the reprex package (v2.0.1)

3
  • At which place in your code do I insert "lty", "color" etc. in order to customize the plot? Commented Jan 30, 2022 at 22:46
  • You can use edge_lty and edge_size inside the call to ggVennDiagram, and to change colours, you can do + scale_color_manual(values = c("yellow", "brown", "pink")) as you would with a ggplot. Commented Jan 30, 2022 at 22:56
  • ggVennDiagram(apply(cbind(t1, t2, t3), 2, function(x) which(x == 1)), category.names = c("Probe 1", "Probe 2", "Probe 3"), edge_size = 0.2, label_size = 3, set_size = 3) + scale_fill_gradient(low = "#F4FAFE", high = "#4981BF")+ theme(legend.position = "bottom")+ scale_color_manual(values = c("black", "black", "black")) worked out. But the catagory names won´t display with their entire titles, but were cut off by the edges/margins of the plot. Is there a call to minimize the size of the circles or how do I cope that problem? Commented Jan 30, 2022 at 23:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.