I would like to convert an incidence matrix of a bipartite procjection into a matrix of an unipartite projection.
For example:
I have this matrix, in which the columns are interacting with the respective rows when element equals > 0.
int <- matrix(rbinom(48, 2, 0.2),nrow=8,ncol=6)
colnames(int) <- letters[1:6]
rownames(int) <- letters[7:14]
I would like to generate a adjacency (square matrix) of the higher nodes (the columns), in which the new elements will be sum of times they shared the same interaction with the rows (g to n).
So if my int matrix is this one:
a b c d e f
g 0 0 0 1 1 0
h 1 0 0 1 1 0
i 0 1 0 0 0 0
j 1 0 1 1 1 0
k 1 1 1 0 1 0
l 0 0 1 0 0 0
m 0 0 1 2 0 0
n 1 1 2 1 0 0
My unipartite projection resulting will be like:
a b c d e f
a 0 2 3
b 2 0 2
c 3.. 0
d 3
e
f
In which the pair ab shared interaction with two rows (k and n) . The pair ac shared interaction with three rows (k , k and n), etc.
Any ideas?