Intersection 5 sets of genes and retrieval of specific subsets
Hey all,
i need to intersect 5 sets of genes and retrieve all possible subsets, meaning the ones common to just 1, the ones in common in any 2/5, the ones common in any 3/5, any 4/5 and 5/5. So in the end my output ideally would be 5 "private" sets + 4 other sets (2/5,3/5,4/5,5/5).
important: i want to retrieve them, not visualize them.
Anyone has a quick way to do it?
• 1,817 views
•
link
1 answer
get.int.genes <- function(genes.list)
{
total.genes <- Reduce(union, genes.list)
genes.req <- list()
for(i in c(paste('only ', c(1:5)), paste("common ", c(2:5))))
genes.req[[i]] <- c()
for(gene in total.genes)
{
count = 0
set.ind = 0
for(j in seq_along(genes.list))
{
if(gene %in% genes.list[[j]])
{
count = count + 1
set.ind = j
}
}
if(count == 1)
genes.req[[paste('only ', set.ind)]] <- c(genes.req[[paste('only ', set.ind)]], gene)
else
genes.req[[paste('common ', count)]] <- c(genes.req[[paste('common ', count)]], gene)
}
return(genes.req)
}
This function should help with only denoting the 5 different sets and common denoting what you require.
• 0 views
•
link
Log in to answer this question.