コード例 #1
0
def test_fetch_multiple_subsample():
    af = AtlasFetcher()
    atlas = af.fetch_multiple_atlases(['Darmanis_2015', 'Enge_2017'],
                                      kind='subsample')
    assert (isinstance(atlas, AnnData))
    assert ('CellType' in atlas.obs.columns)
    assert ('Dataset' in atlas.obs.columns)
コード例 #2
0
ファイル: test_fetch_atlas.py プロジェクト: pythseq/northstar
def test_fetch_multiple_subsample():
    af = AtlasFetcher()
    atlas = af.fetch_multiple_atlases(['Darmanis_2015', 'Enge_2017'],
                                      kind='subsample')
    assert (isinstance(atlas, dict))
    assert ('counts' in atlas)
    assert ('cell_types' in atlas)
コード例 #3
0
def test_fetch_Enge_2017():
    af = AtlasFetcher()
    atlas = af.fetch_atlas('Enge_2017')
    assert (isinstance(atlas, AnnData))
    assert ('NumberOfCells' in atlas.obs.columns)

    counts = atlas[:, ['INS', 'GCG', 'PPY']]
    assert (counts['beta', 'INS'].X > counts['acinar', 'INS'].X)
コード例 #4
0
ファイル: test_fetch_atlas.py プロジェクト: pythseq/northstar
def test_fetch_Enge_2017():
    af = AtlasFetcher()
    atlas = af.fetch_atlas('Enge_2017')
    assert (isinstance(atlas, dict))
    assert ('counts' in atlas)
    assert ('number_of_cells' in atlas)
    counts = atlas['counts'].loc[['INS', 'GCG', 'PPY']]
    assert (counts.loc['INS', 'beta'] > counts.loc['INS', 'acinar'])
コード例 #5
0
def test_average_Darmanis_2015():
    af = AtlasFetcher()
    atlas = af.fetch_atlas('Darmanis_2015', kind='subsample')

    ss = average_atlas(
            atlas,
            )

    assert(isinstance(ss, anndata.AnnData))
    assert(ss.shape[0] == 8)
コード例 #6
0
def test_run_within_atlas():
    aname = 'Darmanis_2015'
    atlas = AtlasFetcher().fetch_atlas(aname, kind='subsample')
    matrix = atlas.copy()
    cell_types = atlas.obs['CellType'].values

    sa = Subsample(aname)
    sa.fit(matrix)

    # Small samples are a bit tricky, one cell can tip the balance
    assert ((cell_types == sa.membership).mean() >= 0.85)
コード例 #7
0
def test_run_across_atlas():
    atlas = AtlasFetcher().fetch_atlas('Enge_2017', kind='subsample')
    matrix = atlas.copy()
    cell_types = atlas.obs['CellType'].values

    sa = Subsample(
        'Baron_2016',
        n_pcs=25,
        n_features_per_cell_type=3,
        n_features_overdispersed=200,
    )
    sa.fit(matrix)

    # Nobody's perfect
    # Baron annotates Stellate cells more accurately, so we skip them
    assert ((cell_types == sa.membership)[:60].mean() >= 0.5)
コード例 #8
0
ファイル: test_subsamples.py プロジェクト: pythseq/northstar
def test_run_within_atlas():
    aname = 'Darmanis_2015'
    atlas = AtlasFetcher().fetch_atlas(aname, kind='subsample')
    matrix = atlas['counts']
    cell_types = atlas['cell_types'].values

    sa = Subsample(aname)
    sa.fit(matrix)

    # Nobody's perfect
    assert ((cell_types == sa.membership).mean() >= 0.9)
コード例 #9
0
ファイル: test_subsamples.py プロジェクト: pythseq/northstar
def test_run_within_atlas_means():
    aname = 'Darmanis_2015'
    atlas = AtlasFetcher().fetch_atlas(aname, kind='average')

    ind = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 5, 6, 0]
    matrix = atlas['counts'].iloc[:, ind]
    cell_types = atlas['counts'].columns.values[ind]

    sa = Subsample(aname)
    sa.fit(matrix)

    # Nobody's perfect
    assert ((cell_types == sa.membership).mean() >= 0.9)
コード例 #10
0
def test_run_mock_cells():
    aname = 'Darmanis_2015_nofetal'
    atlas = AtlasFetcher().fetch_atlas(aname, kind='average')

    ind = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 5]
    matrix = atlas[ind]
    cell_types = atlas.obs_names.values[ind]

    sa = Averages(
        aname,
        n_pcs=10,
    )
    sa.fit(matrix)

    assert ((cell_types == sa.membership).mean() > 0.9)
コード例 #11
0
def test_embed_averages():
    aname = 'Darmanis_2015_nofetal'
    atlas = AtlasFetcher().fetch_atlas(aname, kind='subsample')

    ind = [
        0, 2, 5, 8, 10, 15, 20, 25, 28, 30, 35, 38, 40, 45, 50, 60, 70, 75, 80,
        90
    ]
    matrix = atlas[ind].copy()

    sa = Averages(
        aname,
        n_features_per_cell_type=2,
        n_features_overdispersed=5,
        n_pcs=9,
    )
    sa.fit(matrix)
    vs = sa.embed()
    assert (vs.shape[1] == 4)
コード例 #12
0
def test_run_within_atlas():
    aname = 'Darmanis_2015_nofetal'
    atlas = AtlasFetcher().fetch_atlas(aname, kind='subsample')

    ind = [
        0, 2, 5, 8, 10, 15, 20, 25, 28, 30, 35, 38, 40, 45, 50, 60, 70, 75, 80,
        90
    ]
    matrix = atlas[ind]
    cell_types = atlas.obs['CellType'].values[ind]

    sa = Averages(
        aname,
        n_features_per_cell_type=2,
        n_features_overdispersed=5,
        n_pcs=9,
    )
    sa.fit(matrix)

    for i in range(len(cell_types)):
        print('{:10s}    {:10s}'.format(cell_types[i], sa.membership[i]))
    print((cell_types == sa.membership).mean())
    assert ((cell_types == sa.membership).mean() >= 0.5)
コード例 #13
0
def test_fetch_multiple():
    af = AtlasFetcher()
    atlas = af.fetch_multiple_atlases(['Darmanis_2015', 'Enge_2017'])
    assert (isinstance(atlas, AnnData))
    assert ('NumberOfCells' in atlas.obs.columns)
コード例 #14
0
def test_fetch_Darmanis_2015_subsample():
    af = AtlasFetcher()
    atlas = af.fetch_atlas('Darmanis_2015', kind='subsample')
    assert (isinstance(atlas, AnnData))
    assert ('CellType' in atlas.obs.columns)
コード例 #15
0
ファイル: test_fetch_atlas.py プロジェクト: pythseq/northstar
def test_fetch_Darmanis_2015_subsample():
    af = AtlasFetcher()
    atlas = af.fetch_atlas('Darmanis_2015', kind='subsample')
    assert (isinstance(atlas, dict))
    assert ('counts' in atlas)
    assert ('cell_types' in atlas)
コード例 #16
0
ファイル: test_fetch_atlas.py プロジェクト: pythseq/northstar
def test_constructor():
    af = AtlasFetcher()
コード例 #17
0
ファイル: test_fetch_atlas.py プロジェクト: pythseq/northstar
def test_fetch_Darmanis_2015():
    af = AtlasFetcher()
    atlas = af.fetch_atlas('Darmanis_2015')
    assert (isinstance(atlas, dict))
    assert ('counts' in atlas)
    assert ('number_of_cells' in atlas)
コード例 #18
0
ファイル: test_fetch_atlas.py プロジェクト: pythseq/northstar
def test_list_atlases():
    af = AtlasFetcher()
    table = af.list_atlases()
    assert (table is not None)
コード例 #19
0
ファイル: test_fetch_atlas.py プロジェクト: pythseq/northstar
def test_fetch_table():
    af = AtlasFetcher()
    af.fetch_atlas_table()

    assert (af.atlas_table is not None)
コード例 #20
0
ファイル: test_fetch_atlas.py プロジェクト: pythseq/northstar
def test_fetch_multiple():
    af = AtlasFetcher()
    atlas = af.fetch_multiple_atlases(['Darmanis_2015', 'Enge_2017'])
    assert (isinstance(atlas, dict))
    assert ('counts' in atlas)
    assert ('number_of_cells' in atlas)
コード例 #21
0
def test_fetch_Darmanis_2015():
    af = AtlasFetcher()
    atlas = af.fetch_atlas('Darmanis_2015')
    assert (isinstance(atlas, AnnData))
    assert ('NumberOfCells' in atlas.obs.columns)