hic3defdr.util.filtering module

hic3defdr.util.filtering.filter_sparse_rows_count(matrix, min_nnz=25, k=300)[source]

Wipes the sparse bins (both rows and columns) of a matrix, where “sparse” means that the bin has less than min_nnz nonzero interactions with both the k nearest upstream and downstream bins.

This function wipes with zeros and will eliminate the wiped positions if matrix is a CSR format sparse matrix.

Parameters:
  • matrix (np.ndarray, scipy.sparse.csr_matrix, or BandedMatrix) – The matrix to wipe sparse bins from.
  • min_nnz (int) – The minimum number of nonzero contacts a bin has to make in either direction (upstream or downstream) to escape being wiped.
  • k (int) – How many bins upstream or downstream to look when counting the number of nonzero contacts a bin makes in a given direction.
Returns:

The filtered matrix.

Return type:

np.ndarray, scipy.sparse.csr_matrix, or BandedMatrix