0

I have a list of genes from sequencing. This list of genes is annotated to a GEN-ID. An example of one list is shown on the link below.

file format of lists

In this list a number means the gen is found in the sample. NA means the gen is not found.

I want to take for example two such lists and do a Venn diagram with them. The code I use for this is as follows:

listA <- read.csv("young.csv", header = FALSE)
A <- listA
A

listB <- read.csv("old.csv", header = FALSE)
B <- listB
B

length(A$V2)
length(B$V2)

A[is.na(A)] <- ""
B[is.na(B)] <- ""

library(VennDiagram)

xx.1 <- venn.diagram(list("young_control" =A$V2, "old_control" = B$V2), fill = c("yellow","cyan"), cex
             =4.0, filename = "venn_excersice.png")

with this, I generate a Venn diagram displaying the genes which are in listA only, listB only or in both listA and listB.

My question now is: If I want to get a list, of Gen-IDs from each area of the generated Venn how do I do that? I tried attr, output, intersect, and other functions but somehow it won't work and I have no idea why this is the case.

Further on, I would like to generate an interactive Venn diagram. One in which you can click on the area and immediately get a visual representation of the Gen-IDs which are in this area.

If anybody has any recommendations on what I can try to reach this goal I would be super happy!

List format:

List A

ID.........Y
G-1........1
G-2.......NA
G-3........3
G-4........4

List B

ID.........O
G-1........1
G-2....... 2
G-3........3
G-4........NA

EpiG88
  • 1
  • 1
  • 1
    Can you share your data with us for both `listA` and `listB`? You can use `dput(listA)` and `dput(listB)` – neuron Dec 03 '21 at 14:44
  • I am not sure how to use dput in stack overflow. I hope my representation of the list together with the picture you can find on the hyperlink are helpful. – EpiG88 Dec 03 '21 at 15:06
  • 1
    You use `dput()` in R and then copy and paste the output into your question – neuron Dec 03 '21 at 17:30
  • Please provide enough code so others can better understand or reproduce the problem. – Community Dec 07 '21 at 06:44

1 Answers1

0

You can do most of those things with several R packages (there is a list here). With nVennR you can make and explore the diagrams you want (see the vignette for recipes). Making an interactive diagram is not easy in R, you would probably need a shiny app.

Nevertheless, there is also a web server for nVenn that produces something like that. You just need to write the lists in the text boxes. Duplicated rows are removed, but NA is understood as an item, so you would need to remove them beforehand. The interactivity is provided by the web page itself, so you need to use the permanent link provided to explore the diagram repeatedly. Here is one example with the data you gave. If you click on any circle, you will get the elements in that region in the textbox to the left. Notice the Permanent link below the text box.

vqf
  • 2,600
  • 10
  • 16