I'm trying to apply a function to each pair of columns in a numpy array (each column is an individual's genotype).
For example:
[48]: g[0:10,0:10]
array([[ 1, 1, 1, 1, 1, 1, 1, 1, 1, -1],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, -1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, -1],
[-1, -1, 0, -1, -1, -1, -1, -1, -1, 0],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], dtype=int8)
My goal is to produce a distance matrix d so that each element of d is the pairwise distance comparing each column in g.
d[0,1] = func(g[:,0], g[:,1])
Any ideas would be fantastic! Thank you!