clustering.py
def checkFolds(dists, target_names, threshold, foldmap):
    '''check that targets in different folds pass dissimilarity threshold'''
    ok = True
    n_targets = dists.shape[0]
    min_dist = np.inf
    closest = None
    for t in foldmap:
        if t not in set(target_names):
            print('warning: {} not found in distance matrix'.format(t))
    for a in range(n_targets):
        for b in range(a+1, n_targets):
            a_name = target_names[a]
            b_name = target_names[b]
            if a_name in foldmap and b_name in foldmap:
                if foldmap[a_name] != foldmap[b_name]:
                    if dists[a][b] < min_dist:
                        min_dist = dists[a][b]
                        closest = (a_name, b_name)
                    if dists[a][b] < threshold:
                        print('warning: {} and {} are {:.3f}% similar but in different folds' \
                              .format(a_name, b_name, 100*(1-dists[a][b])))
                        ok = False
    if closest:
        print('{} and {} are the most similar targets in different folds ({:.3f}%)' \
              .format(closest[0], closest[1], 100*(1-min_dist)))
    return ok
check that targets in different folds pass dissimilarity threshold
check that targets in different folds pass dissimilarity threshold
check that targets in different folds pass dissimilarity threshold
def checkFolds(dists, target_names, threshold, foldmap):
    ok = True
    n_targets = dists.shape[0]
    min_dist = np.inf
    closest = None
    for t in foldmap:
        if t not in set(target_names):
            print('warning: {} not found in distance matrix'.format(t))
    for a in range(n_targets):
        for b in range(a+1, n_targets):
            a_name = target_names[a]
            b_name = target_names[b]
            if a_name in foldmap and b_name in foldmap:
                if foldmap[a_name] != foldmap[b_name]:
                    if dists[a][b] < min_dist:
                        min_dist = dists[a][b]
                        closest = (a_name, b_name)
                    if dists[a][b] < threshold:
                        print('warning: {} and {} are {:.3f}% similar but in different folds' \
                              .format(a_name, b_name, 100*(1-dists[a][b])))
                        ok = False
    if closest:
        print('{} and {} are the most similar targets in different folds ({:.3f}%)' \
              .format(closest[0], closest[1], 100*(1-min_dist)))
    return ok
def checkFolds ( dists , target_names , threshold , foldmap ) : ok = True n_targets = dists . shape [ 0 ] min_dist = np . inf closest = None for t in foldmap : if t not in set ( target_names ) : print ( 'warning: {} not found in distance matrix' . format ( t ) ) for a in range ( n_targets ) : for b in range ( a + 1 , n_targets ) : a_name = target_names [ a ] b_name = target_names [ b ] if a_name in foldmap and b_name in foldmap : if foldmap [ a_name ] != foldmap [ b_name ] : if dists [ a ] [ b ] < min_dist : min_dist = dists [ a ] [ b ] closest = ( a_name , b_name ) if dists [ a ] [ b ] < threshold : print ( 'warning: {} and {} are {:.3f}% similar but in different folds' . format ( a_name , b_name , 100 * ( 1 - dists [ a ] [ b ] ) ) ) ok = False if closest : print ( '{} and {} are the most similar targets in different folds ({:.3f}%)' . format ( closest [ 0 ] , closest [ 1 ] , 100 * ( 1 - min_dist ) ) ) return ok
check that targets in different folds pass dissimilarity threshold
check that targets in different folds pass dissimilarity threshold
'''check that targets in different folds pass dissimilarity threshold'''
dists
target_names
threshold
foldmap