polychrom.legacy.contactmaps module¶
This file contains a bunch of method to work on contact maps of a Hi-C data.
- polychrom.legacy.contactmaps.averageBinnedContactMap(filenames, chains=None, binSize=None, cutoff=1.7, n=4, loadFunction=<function load>, exceptionsToIgnore=None, printProbability=1, map_function=<class 'map'>)[source]¶
Returns an average contact map of a set of conformations. Non-existing files are ignored if exceptionsToIgnore is set to IOError. example:
An example:
- Parameters
filenames (list of strings) – Filenames to average map over
chains (list of tuples or Nx2 array) – (start,end+1) of each chain
binSize (int) – size of each bin in monomers
cutoff (float, optional) – Cutoff to calculate contacts
n (int, optional) – Number of threads to use. By default 4 to minimize RAM consumption.
exceptionsToIgnore (list of Exceptions) – List of exceptions to ignore when finding the contact map. Put IOError there if you want it to ignore missing files.
- Returns
tuple of two values
(i) MxM numpy array with the conntact map binned to binSize resolution.
(ii) chromosomeStarts a list of start sites for binned map.
- polychrom.legacy.contactmaps.averagePureContactMap(filenames, cutoff=1.7, n=4, loadFunction=<function load>, exceptionsToIgnore=[], printProbability=0.005, map_function=<class 'map'>)[source]¶
Parameters
- cutofffloat, optional
Cutoff to calculate contacts
- nint, optional
Number of threads to use. By default 4 to minimize RAM consumption with pure maps.
- exceptionsToIgnorelist of Exceptions
List of exceptions to ignore when finding the contact map. Put IOError there if you want it to ignore missing files.
- Returns
An NxN (for pure map) numpy array with the contact map.
- polychrom.legacy.contactmaps.pureMap(data, cutoff=1.7, contactMap=None)[source]¶
calculates an all-by-all contact map of a single polymer chain. Doesn’t work for multi-chain polymers!!! If contact map is supplied, it just updates it
- Parameters
data (Nx3 or 3xN array) – polymer conformation
cutoff (float) – cutoff for contacts
contactMap (NxN array, optional) – contact map to update, if averaging is used
- polychrom.legacy.contactmaps.rescalePoints(points, bins)[source]¶
converts array of contacts to the reduced resolution contact map
- polychrom.legacy.contactmaps.rescaledMap(data, bins, cutoff=1.7, contactMap=None)[source]¶
calculates a rescaled contact map of a structure :param data: polymer conformation :type data: Nx3 or 3xN array :param bins: bin starts :type bins: Lx1 array :param cutoff: cutoff for contacts :type cutoff: float, optional
- Returns
resXres array with the contact map