metaloci.graph_layout package

Subset of modules that contain methods to layout the Hi-C information. For now, only Kamada-Kawai is implemented.

Submodules

metaloci.graph_layout.kk module

Functions to calculate the top interactions matrix subset, plot matrix and get restraints for the Kamada-Kawai layout processing.

metaloci.graph_layout.kk.estimate_cutoff(mlobject: MetalociObject, optimise: bool = False) float

Estimate the cutoff for the Kamada-Kawai layout processing. It will iteratively try several cutoffs until it finds the one that satisfies that the number of conections the node with the least amount of connections is 25% of the node with higher amount of connections in the graph.

Parameters:

mlobject (mlo.MetalociObject) – METALoci object with a matrix in it (MetalociObject.matrix).

Returns:

Estimated cutoff for the Kamada-Kawai layout processing.

Return type:

float

metaloci.graph_layout.kk.estimate_persistence_length(mlobject: MetalociObject, optimise: bool = False) float

Estimate the persistence length for the Kamada-Kawai layout processing.

Parameters:

mlobject (mlo.MetalociObject) – METALoci object with a matrix in it (MetalociObject.matrix).

Returns:

Estimated persistence length for the Kamada-Kawai layout processing.

Return type:

float

metaloci.graph_layout.kk.get_restraints_matrix(mlobject: MetalociObject, optimise: bool = False, silent: bool = False) MetalociObject

Calculate top interaction matrix subset, plot matrix and get restraints.

Parameters:
  • mlobject (mlo.MetalociObject) – METALoci object with a matrix and a cutoff (MetalociObject.matrix and MetalociObject.kk_cutoff) in it. MetalociObject.persistence_length is optional.

  • silent (bool, optional) – Variable passed to get_subset_matrix function to control the verbosity of it (useful for multiprocessing).

Returns:

mlobject – METALoci object with the calculated restraints for the Kamada-Kawai layout processing, the ‘mixed matrix’ (upper diagonal is the original HiC, lower diagonal is the subset matrix), the flattened matrix and the top indexes of the subset matrix added to it, for plotting purposes.

Return type:

mlo.MetaloiObject

metaloci.graph_layout.kk.get_subset_matrix(mlobject: MetalociObject, optimise: bool = False, silent=False) ndarray

Get a subset of the Hi-C matrix with the top contact interactions in the matrix, defined by a cutoff. The diagonal is also removed.

Parameters:
  • mlobject (mlo.MetalociObject) – METALoci object with a matrix and a cutoff in it (MetalociObject.matrix and MetalociObject.kk_cutoff respectively).

  • silent (boolean) – Variable that controls the verbosity of the function (useful for multiprocessing).

Returns:

subset_matrix – Subset matrix, containing only top interactions. The rest of the matrix is set to 0.

Return type:

np.ndarray

Notes

This function is called from:

get_restraints_matrix()

so it is not required to call it when computing the regular pipeline.