0

enter image description here

I have 6 lists. Each contains genes of interest from a given condition. These six lists were then used to make a venn diagram in r using the venn package.

The venn diagram is precisely what I want, but now I would like to produce a list of genes from each section of the venn diagram. how do I do this? i.e. how do I figure out what genes from my lists comprise the 1251 genes that are present in each list/condition?

library(venn)

venn_list_no <- list(pt_v_lb = rownames(pt_v_lb_no), lbdm_v_lb = rownames(lbdm_v_lb_no), ptdm_v_lb = rownames(ptdm_v_lb_no), lbdm_v_pt = rownames(lbdm_v_pt_no), ptdm_v_pt = rownames(ptdm_v_pt_no), ptdm_v_lbdm = rownames(ptdm_v_lbdm_no))

venn(venn_list_no, zcolor = "style", ggplot = T, opacity = 0.2, box = F)+
  theme()
jrcalabrese
  • 2,184
  • 3
  • 10
  • 30
406phage
  • 5
  • 3
  • 1
    `dput(data)` that would be helpful for replicating the same what your code shows – PesKchan Apr 17 '23 at 07:17
  • I am unsure what dput(data) means. If you are wanting the data from the lists, I am unsure how to upload the list data. – 406phage Apr 18 '23 at 15:51
  • See here on how to make a reproducible example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – jrcalabrese Apr 18 '23 at 18:05

1 Answers1

0

I have had a look at the package source and I cannot see any documented function to extract the elements in a region. In fact, the venn function does not return anything, so there is nothing you can check. You might want to try my nVennR package for that. At this time it is not available in CRAN, but you can install it from Github with devtools::install_github("vqf/nVennR"). An example:

>library(nVennR)
>myV <- plotVenn(list(set1=c(1, 2, 3), set2=c(2, 3, 4), set3=c(3, 4, 5, 'a', 'b'), set4=c(5, 6, 1, 4)))

enter image description here

>getVennRegion(myV, c('set2', 'set3', 'set4'))
[1] 4

>getVennRegion(myV, c('set3'))
[1] "a" "b"

>listVennRegions(myV)
$`0, 0, 0, 1 (set4)`
[1] 6

$`0, 0, 1, 0 (set3)`
[1] "a" "b"

$`0, 0, 1, 1 (set3, set4)`
[1] 5

$`0, 1, 1, 1 (set2, set3, set4)`
[1] 4

$`1, 0, 0, 1 (set1, set4)`
[1] 1

$`1, 1, 0, 0 (set1, set2)`
[1] 2

$`1, 1, 1, 0 (set1, set2, set3)`
[1] "3"

You can see more examples at the vignette.

vqf
  • 2,600
  • 10
  • 16