3
$\begingroup$

I'm a little at loss as to what my supervisor meant by the "hierarchical block decomposition" of a matrix, but the goal is to put a sparse symmetric adjacency matrix into a block diagonal structure to highlight the structure of the clusters present in the data.

(The data captures whether the two proteins are adjacent in a molecule: if they are, the corresponding adjacency matrix has one on their row/column, otherwise zero. I sum a few of these adjacency matrices(one for each unique molecule) and divide the result by the number of molecules(to simulate the mean).

I'm wondering how to get to the block diagonal structure from there. People over here suggest scipy's reverse CM and seaborn's heatmap should be able to do that ostensibly, but i had no luck with either so far. Should i go with SVD? What am i missng? This is what I got. Thank you kindly!

def construct_adjacency_matrix(clusters=dict, nomenclature_namespace=dict):

   nbrpairs  = tree2tuplearr(clusters['nbrtree'])
    dim       = len(nomenclature_namespace.items())
    keys      = list(nomenclature_namespace.keys())
    substrate = np.zeros((dim, dim))

    for pair in nbrpairs:
        if (pair[0] not in keys or pair[1] not in keys):
            pass
        else:
            substrate[nomenclature_namespace[pair[0]],
                      nomenclature_namespace[pair[1]]] = 1
    return substrate


def get_simplemean(targetgroup=str):
    targetspath = './../clusterdata/targetgroups/{}/'.format(targetgroup)
    batch       = os.listdir(targetspath)
    adjmats     = [construct_adjacency_matrix(openjson(targetspath+x), namespace) for x in batch]
    # laplacians  = []
    reduced = functools.reduce(lambda x, y: np.add(x,y), adjmats)
    reduced = np.divide(reduced, len(adjmats))
    plt.matshow(reduced)
    seaborn.clustermap(reduced)
    plt.show()

enter image description here

There is obviously certain structure in the data and in fact I already have the graphs of clusters, but how do i put into the form that resembles this below? I realize that this picture has quite a few more datapoints.

enter image description here

$\endgroup$
2
  • $\begingroup$ Look up the Dulmage-Mendelsohn decomposition. $\endgroup$ Apr 19 '20 at 18:24
  • $\begingroup$ @BrianBorchers He didn't say the input graph was bipartite. $\endgroup$
    – wcochran
    Jun 29 '20 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.