Skip to content

Commit

Permalink
Merge pull request #30 from rmarkello/fix/atlasnum
Browse files Browse the repository at this point in the history
[FIX] More fixes for atlas numbering
  • Loading branch information
rmarkello authored Oct 17, 2018
2 parents ab2c232 + 552b24d commit 39cb746
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion abagen/allen.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,11 @@ def get_expression_data(files, atlas, atlas_info=None, *, exact=True,
if not exact:
coords = utils.xyz_to_ijk(annotation[['mni_x', 'mni_y', 'mni_z']],
atlas.affine)
empty = np.setdiff1d(all_labels, labs)
empty = ~np.in1d(all_labels, labs)
closest, dist = utils.closest_centroid(coords, centroids[empty],
return_dist=True)
closest = samples.loc[annotation.iloc[closest].index]
empty = all_labels[empty]
closest.index = pd.Series(empty, name='label')
missing += [(closest, dict(zip(empty, np.diag(dist))))]

Expand Down
6 changes: 5 additions & 1 deletion abagen/tests/test_allen.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ def test_missing_labels(testfiles):
atlas_info = pd.read_csv(ATLAS.info)
atlas_info = atlas_info[~atlas_info.id.isin(remove)]
# test get expression
out = allen.get_expression_data(testfiles, atlas, atlas_info)
out, counts = allen.get_expression_data(testfiles, atlas, atlas_info,
exact=False, return_counts=True)
assert isinstance(out, pd.DataFrame)
assert out.index.name == 'label'
assert out.columns.name == 'gene_symbol'
assert len(out) == len(atlas_info)

assert isinstance(counts, pd.DataFrame)
assert counts.shape == (len(atlas_info), len(testfiles.probes))

0 comments on commit 39cb746

Please sign in to comment.