Ejemplo n.º 1
0
def test_pattern_detector(matrix):
    """Test if pattern detector exits correctly"""
    contact_map = DummyMap(matrix, max_dist=100, detectable_bins=None)
    # Gaussian kernel
    kernel_matrix = gauss_mat(0, 0, 5, shape=(7, 7)).todense()
    kernel_config = {
        "max_dist": 100,
        "precision": 1,
        "max_perc_undetected": 10,
    }
    kernel_matrix = (kernel_matrix + kernel_matrix.T -
                     np.diag(np.diag(kernel_matrix)))
    cud.pattern_detector(contact_map, kernel_config, kernel_matrix)
Ejemplo n.º 2
0
def _quantify_sub_mat(data):
    """
    This function is dispatched by multiprocessing to
    run the quantification pipeline.
    """
    sub = data[0][1]
    config = data[1]
    kernel = data[2]
    positions = data[3]
    # If there is no pattern on this sub matrix,
    # do not scan it.
    if positions.shape[0]:
        sub.contact_map.create_mat()
        # Feed the submatrix to quantification pipeline
        patterns, windows = cid.pattern_detector(
            sub.contact_map,
            config,
            kernel,
            coords=np.array(positions.loc[:, ["bin1", "bin2"]]),
            full=True,
            tsvd=config["tsvd"],
        )
        sub.contact_map.destroy_mat()
    else:
        patterns = windows = None

    return {
        "coords": patterns,
        "windows": windows,
        "chr1": sub.chr1,
        "chr2": sub.chr2,
    }
Ejemplo n.º 3
0
def _detect_sub_mat(data):
    sub = data[0][1]
    config = data[1]
    kernel = data[2]
    dump = data[3]
    chrom_patterns, chrom_windows = cid.pattern_detector(
        sub.contact_map, config, kernel, dump
    )
    return {
        "coords": chrom_patterns,
        "windows": chrom_windows,
        "chr1": sub.chr1,
        "chr2": sub.chr2,
    }
Ejemplo n.º 4
0
def _detect_sub_mat(data):
    sub = data[0][1]
    config = data[1]
    kernel = data[2]
    dump = data[3]
    sub.contact_map.create_mat()
    chrom_patterns, chrom_windows = cid.pattern_detector(
        sub.contact_map,
        config,
        kernel,
        dump=dump,
        full=True,
        tsvd=config["tsvd"],
    )
    sub.contact_map.destroy_mat()

    return {
        "coords": chrom_patterns,
        "windows": chrom_windows,
        "chr1": sub.chr1,
        "chr2": sub.chr2,
    }