Skip to content

Commit

Permalink
Merge pull request #42 from emdann/fix-annotate-nhoods
Browse files Browse the repository at this point in the history
  • Loading branch information
emdann authored Sep 4, 2023
2 parents af88cc5 + fa86b02 commit 49db7b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion milopy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ def annotate_nhoods(adata: AnnData,
anno_dummies = pd.get_dummies(adata.obs[anno_col])
anno_count = adata.obsm["nhoods"].T.dot(
scipy.sparse.csr_matrix(anno_dummies.values))
anno_frac = np.array(anno_count/anno_count.sum(1))
try:
anno_frac = (anno_count/anno_count.sum(1)).toarray()
except AttributeError: # for old version of python
anno_frac = np.array(anno_count/anno_count.sum(1))

anno_frac = pd.DataFrame(anno_frac,
columns=anno_dummies.columns,
Expand Down

0 comments on commit 49db7b8

Please sign in to comment.