I have a matrix m with 8300 columns and 18 rows. Each column represents a gene; and each row, a sample. I want to calculate the adjacency matrix (using spearman correlation) and the corresponding p-value matrix.
The code I've got so far is:
W = np.zeros((n_genes, n_genes)) P = np.zeros((n_genes, n_genes)) for i in range(0, n_genes): for j in range(0, n_genes): W[i,j], P[i,j] = st.spearmanr(m[:,i], m[:,j]) Which is amazingly inefficient (It takes around 11 hours to run in colab-google using GPU). Is there a way to vectorize this?
Thank you a lot!