Intersection 5 sets of genes and retrieval of specific subsets
1
0
Entering edit mode
6.8 years ago
lessismore ★ 1.4k

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?

R genes intersections • 1.4k views
ADD COMMENT
2
Entering edit mode
6.8 years ago
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.

ADD COMMENT

Login before adding your answer.

Traffic: 1606 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6