Skip to content

Commit

Permalink
fix for Scanpy sc.pp.neighbors backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
awnimo committed May 10, 2020
1 parent 63fd927 commit eca0771
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/harmony/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def augmented_affinity_matrix(

temp = sc.AnnData(data_df.values)
sc.pp.neighbors(temp, n_pcs=0, n_neighbors=n_neighbors)
kNN = temp.uns['neighbors']['distances']
# maintaining backwards compatibility to Scanpy `sc.pp.neighbors`
try:
kNN = temp.uns['neighbors']['distances']
except KeyError:
kNN = temp.obsp['distances']

# Adaptive k
adaptive_k = int(np.floor(n_neighbors / 3))
Expand Down
2 changes: 1 addition & 1 deletion src/harmony/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.3"
__version__ = "0.1.4"

0 comments on commit eca0771

Please sign in to comment.