Question: Limma Venn Diagram
2
gravatar for Ly
8.9 years ago by
Ly20
Ly20 wrote:

Hello,

I made a vennDiagram using the limma package. Do you know of a way to get a list of genes that are in each of the piece of the VennDiagram. On a related note, I can't seem to figure out how to get the gene names in the table function either (below). For example, how do I get the genes that is down in both results or up in just one?

table(Tumor.C=results[,4],Tumor.T=results[,5])

Thank you, Ly

gene limma • 7.4k views
ADD COMMENTlink modified 6.9 years ago by Biostar ♦♦ 20 • written 8.9 years ago by Ly20

You haven't really shown enough code or given enough detail of the various objects you have in R to allow us to help you. More detail would be useful.

Best

duff

ADD REPLYlink written 8.9 years ago by Duff660
9
gravatar for seidel
8.9 years ago by
seidel7.1k
United States
seidel7.1k wrote:

The vennDiagram function in limma takes a TestResults matrix, which is simply a matrix containing 0, 1, -1, indicating if a given row (i.e. gene) is significant up or down for a given column (i.e. experiment), such that 0 = not significant, 1 = significant up, -1 = significant down. The vennDigram function summarizes visually how rows partition into sets. So to get the pieces of the venn diagram you have to apply logic to the rows of your matrix to get the sets you want. For instance, to get any genes that are significantly changed up OR down in both experiments 4 AND 5, (like your example above), you could do:

which(results[,4] != 0 & results[,5] != 0)

This returns the overlap set from both experiments. Using combinations of statements containing AND/OR you can retrieve any set represented in the venn diagram. However, it's easy to make mistakes with the logic, so it can be useful to check your results to make sure the counts you retrieve match the numbers you see in the venn diagram. For instance to get genes up only in experiment 4 but not experiment 5, you would apply the following:

sum(results[,4] == 1 & results[,5] != 1)

Since the result of the statement in parenthesis above is a boolean vector, you can use it as an index vector to get your gene names. Assuming a limma object called fit2 (like in the limma documentation):

# make a boolean index vector based on criteria
iv <- results[,4] == 1 & results[,5] != 1
# use it to extract gene names
fit2$genes[iv,"gene_name"]

You can't get the names from the Table function like you mentioned above, as that just summarizes the elements of your matrix.

There are a few ways to work with venn diagrams and there's a good biostar question on this.

Also, if you want an easy way to get the sets in R, you can use a function written by Thomas Girke:

source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/vennDia.R")

When you draw a venn diagram using his function (the docs are in the comments), the sets are all saved in a list and can be easily accessed.

ADD COMMENTlink modified 12 months ago by RamRS30k • written 8.9 years ago by seidel7.1k

Thank you Seidel! I will try this and look into the sights that you have suggested.

ADD REPLYlink written 8.9 years ago by Ly20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1245 users visited in the last hour