Motif adjacency matrices¶
Functions for building motif adjacency matrices are in motifcluster.motifadjacency.
-
build_motif_adjacency_matrix
(adj_mat, motif_name, motif_type='struc', mam_weight_type='unweighted', mam_method='sparse')¶ Build a motif adjacency matrix.
Build a motif adjacency matrix from an adjacency matrix. Entry (i, j) of a motif adjacency matrix is the sum of the weights of all motifs containing both nodes i and j.
- The motif is specified by name and the type of motif instance can be one of:
- Functional: motifs should appear as subgraphs.
- Structural: motifs should appear as induced subgraphs.
- The weighting scheme can be one of:
- Unweighted: the weight of any motif instance is one.
- Mean: the weight of any motif instance is the mean of its edge weights.
- Product: the weight of any motif instance is the product of its edge weights.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_name (str) – Motif used for the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build. One of “func” or “struc”.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”. The sparse formulation avoids generating large dense matrices so tends to be faster for large sparse graphs.
Returns: A motif adjacency matrix.
Return type: sparse matrix
Examples
>>> adj_mat = np.array(range(1, 10)).reshape((3, 3)) >>> build_motif_adjacency_matrix(adj_mat, "M1", "func", "mean")
- The motif is specified by name and the type of motif instance can be one of:
-
mam_M1
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M1.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M10
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M10.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M11
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M11.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M12
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M12.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M13
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M13.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M2
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M2.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M3
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M3.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M4
(adj_mat, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M4.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M5
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M5.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M6
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M6.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M7
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M7.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M8
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M8.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_M9
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif M9.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_Mcoll
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif Mcoll.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_Md
(adj_mat, mam_weight_type)¶ Perform the motif adjacency matrix calculations for motif Md.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_Mexpa
(adj_mat, motif_type, mam_weight_type, mam_method)¶ Perform the motif adjacency matrix calculations for motif Mexpa.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
- mam_method (str) – Which formulation to use. One of “dense” or “sparse”.
Returns: A motif adjacency matrix.
Return type: sparse matrix
-
mam_Ms
(adj_mat, motif_type, mam_weight_type)¶ Perform the motif adjacency matrix calculations for motif Ms.
Parameters: - adj_mat (matrix) – Adjacency matrix from which to build the motif adjacency matrix.
- motif_type (str) – Type of motif adjacency matrix to build.
- mam_weight_type (str) – The weighting scheme to use. One of “unweighted”, “mean” or “product”.
Returns: A motif adjacency matrix.
Return type: sparse matrix