cmstats module¶
cmstats.correlateCMaps (ccMapObjOne, ccMapObjTwo) |
To calculate correlation between two Hi-C maps |
cmstats.getAvgContactByDistance (ccmaps[, stats]) |
To calcualte average contact as a function of distance |
-
correlateCMaps
(ccMapObjOne, ccMapObjTwo, ignore_triangular=True, diagonal_offset=1, corrType='pearson', blockSize=None, slideStepSize=1, cutoffPercentile=None, workDir=None, outFile=None, logHandler=None)¶ To calculate correlation between two Hi-C maps
This function can be used to calculate either Pearson or Spearman rank-order correlation between two Hi-C maps. It also ignore lower-trangular matrix with diagnonal offset to avoid duplicate and large values.
Parameters: - ccMapObjOne (
gcMapExplorer.lib.ccmap.CCMAP
) – FirstgcMapExplorer.lib.ccmap.CCMAP
instance containing Hi-C data - ccMapObjTwo (
gcMapExplorer.lib.ccmap.CCMAP
) – SecondgcMapExplorer.lib.ccmap.CCMAP
instance containing Hi-C data - ignore_triangular (bool) – Whether entire matrix is considered or only one half triangular region of matrixis considered.
- diagonal_offset (int) – If
ignore_triangular=True
, it is used to determine how much bins are ignored from the diagonal in one half triangular region of matrix.diagonal_offset = 0
is the main diagonal,diagonal_offset > 0
means ignore this many bins from the diagonal. - corrType (str) – Correlation type. For Pearson and Spearman rank-order correlation, use
pearson
andspearman
, respectively. - blockSize (str) – To calculate block-wise correlations by sliding block of given size along diagonals. It should be in resolution.
For example,
1mb
,500kb
,5mb
,2.5mb
etc. IfNone
, correlation of whole map is calculated. Sliding step of block depends onslideStepSize
. - slideStepSize (int) – Step-size in bins by which blocks will be shifted for block-wise correlation. If slideStepSize is large then blocks might not be overlapped.
- workDir (str) – Name of working directory, where temporary files will be kept.If
workDir = None
, file will be generated in OS based temporary directory. - outFile (str) – Name of output file. Only written for block-wise correlation.
Returns: - corr (float or list) – Correlation coefficient
- pvalue/centers (float or list) – If
blockSize=None
2-tailed p-value is returned. For block-wise correlation, list of block-center is returned.
See also
- scipy.stats.stats.pearsonr for Pearson correlation.
- scipy.stats.stats.spearmanr for Spearman rank-order correlation.
- ccMapObjOne (
-
getAvgContactByDistance
(ccmaps, stats='median')¶ To calcualte average contact as a function of distance
Parameters: hicmaps ( gcMapExplorer.lib.ccmap.CCMAP
or list[gcMapExplorer.lib.ccmap.CCMAP
]) –Returns: avg_contacts – A one-dimensional numpy array containing average contacts, where index is distance between two locations for given resolution/binsize. For example, if ccmap.binsize=100000
andavg_contacts[4]=1234.56
, then at distance of 400000 b, average contact is1234.56
.Return type: numpy.array