How Do I intersect between multiple samples?
I have 29 lists of concatenates I build according to gene name, cc change, coordinate. Each list is 400-800 long. I need to build a table showing how many variants shared among two lists for all 812 combinations. Is there a way I can do this in R?
For example: If I have 4 lists.
A<-c("TSC22112517","SLC141T43309911","RAD51D33446609","WRN31024638")
B<-c("TSC22112517","SLC14A143309911","RHBDF274474996","WRN31024638")
C<-c("TSC22112517","SLC14A143309911","RAD51D33446609","MEN164575556")
D<-c("FANCM45665468","SLC14A143309911","RAD51D33446609","MEN164575556")
I just need to find how many variants are shard among each other.
AB<-length(intersect(A,B))
give me the # of variants shared by A and B which is 3. Then I can get a table like below showing # of shared variants:
A B C D
A 4 3 2 2
B 3 4 3 2
C 2 3 4 2
D 2 2 2 4
How to do it for large # of lists? I have 29 lists and each has 600 variants.