Beispiel #1
0
def test_neighbors_small():
    matrix = pd.DataFrame(
        index=['INS', 'GCG', 'PPY'],
        columns=['cell1', 'cell2', 'cell3'],
        data=[[2302, 123, 0], [0, 5034, 6453], [0, 0, 1]],
    )
    n_pcs = 2
    k = 1
    threshold = 0.8

    sa = Averages('Enge_2017',
                  n_neighbors=k,
                  threshold_neighborhood=threshold,
                  n_pcs=n_pcs,
                  distance_metric='correlation',
                  n_cells_per_type=20,
                  n_neighbors_out_of_atlas=1)

    sa.new_data = matrix
    sa._check_init_arguments()
    sa.fetch_atlas_if_needed()
    sa.compute_feature_intersection()
    sa._check_feature_intersection()
    sa.prepare_feature_selection()
    sa.select_features()
    sa._check_feature_selection()
    sa.merge_atlas_newdata()
    sa.compute_pca()
    sa.compute_similarity_graph()
    neis = sa.neighbors

    assert (isinstance(neis, list))
    assert (len(neis) == int(np.sum(sa.sizes)))
    for nei in neis:
        assert (isinstance(nei, list))
Beispiel #2
0
def test_merge_small():
    matrix = pd.DataFrame(
        index=['INS', 'GCG', 'PPY'],
        columns=['cell1', 'cell2', 'cell3'],
        data=[[2302, 123, 0], [0, 5034, 6453], [0, 0, 1]],
    )
    n_pcs = 2
    k = 1
    threshold = 0.8

    sa = Averages('Enge_2017',
                  n_neighbors=k,
                  threshold_neighborhood=threshold,
                  n_pcs=n_pcs,
                  distance_metric='correlation',
                  n_neighbors_out_of_atlas=1)

    sa.new_data = matrix
    sa._check_init_arguments()
    sa.fetch_atlas_if_needed()
    sa.compute_feature_intersection()
    sa._check_feature_intersection()
    sa.prepare_feature_selection()
    sa.select_features()
    sa._check_feature_selection()
    sa.merge_atlas_newdata()

    assert (sa is not None)