I am trying to find a fast vectorized (at least partially) solution finding combinatorial occurrence between two 2D numpy array to identified Single Point Polymorphism linkage. The shape of each array is (factors, samples) an example for matrix 1 is as follows:
array([[0., 1., 1.],
[1., 0., 1.]])
and matrix 2
array([[1., 1., 0.],
[0., 0., 0.]])
I need to find the total number of occurrence along samples axis for each permutation of 2 factors at the same position of 2 matrix (order matters because (1,0) count is different from (0,1) count). Therefore the combinations should be [(0, 0), (0, 1), (1, 0), (1, 1)] and the final output is (factor, factor) for counts of each occurrence.
For combination (0,0) for instance, we get the matrix
array([[0, 1],
[0., 1]])
Because 0 counts (0,0) along row 0 of matrix 1 & row 0 of matrix 2, 1 along row 0 of matrix 1 & row 1 of matrix 2, 0 along row 1 of matrix 1 & row 0 of matrix 2, 1 along row 1 of matrix 1 & row 1 of matrix 2,