slowkow / harmonypy

🎼 Integrate multiple high-dimensional datasets with fuzzy k-means and locally linear adjustments.
https://portals.broadinstitute.org/harmony/
GNU General Public License v3.0
192 stars 22 forks source link

Fix break in lisi computation #1

Closed tariqdaouda closed 4 years ago

tariqdaouda commented 4 years ago

q = np.squeeze(np.argwhere(labels[ix] == label_category))

Does not have a consistent behaviour, it could return either an iterable or a single element. In which case LISI computation breaks. This simple fix ensures a consistent behaviour.

slowkow commented 4 years ago

Thanks, Tariq! Sorry for the slow reply.

Could I ask if this simpler code might work for your data?

for label_category in labels.categories:
   ix = indices[:,i]
   q = labels[ix] == label_category
   if np.any(q):
       P_sum = np.sum(P[q])
       simpson[i] += P_sum * P_sum

Also, do you think it'd be possible to generate a simple dataset and test the LISI code to confirm it won't break in this case?