Skip to content

Commit

Permalink
Fix #257
Browse files Browse the repository at this point in the history
  • Loading branch information
grst committed Apr 1, 2021
1 parent 122de08 commit c23584c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions scirpy/ir_dist/_clonotype_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,21 @@ def _make_clonotype_table(self, adata):

# groupby.indices gets us a (index -> array of row indices) mapping.
# It doesn't necessarily have the same order as `clonotypes`.
self.cell_indices = [
obs_filtered.index[
clonotype_groupby.indices.get(
# indices is not a tuple if it's just a single column.
ct_tuple[0] if len(ct_tuple) == 1 else ct_tuple,
[],
)
].values
for ct_tuple in clonotypes.itertuples(index=False, name=None)
]
# This needs to be a numpy array with dtype "object", otherwise anndata
# can't save it to h5ad.
self.cell_indices = np.array(
[
obs_filtered.index[
clonotype_groupby.indices.get(
# indices is not a tuple if it's just a single column.
ct_tuple[0] if len(ct_tuple) == 1 else ct_tuple,
[],
)
].values
for ct_tuple in clonotypes.itertuples(index=False, name=None)
],
dtype="object",
)

# make 'within group' a single column of tuples (-> only one distance
# matrix instead of one per column.)
Expand Down

0 comments on commit c23584c

Please sign in to comment.