Closed pavlin-policar closed 3 years ago
Wow, this precomputed
thing escalated pretty quickly :)
Haha, yeah. Things got pretty complicated when I just patched things up. So I tried to simplify it, but all the different ways we can call things now and string them together have made things a bit messy and necessarily complicated.
I'm trusting that my tests are thorough enough that nothing broke here. Most of the major things are tested pretty well though.
Description of changes
Adding this kind of functionality complicated things quite a bit, so a pretty major refactor was necessary to keep things manageable. Notable changes include:
build_knn_index
no longer computes the neighbors, but only returns the correct index. This lets us pass in already existingKNNIndex
objects to affinities.Affinity
classes can now be called in two ways. 1) with a data matrix, as is standard, or 2) using an existingKNNIndex
object. This is in preparation for scanpy integration, where we will have to use existing KNNGs.KNNIndex
objects now have the default parameter `metric="euclidean". This just makes it easier to debug or instantiate manually.nearest_neighbors.PrecomputedNeighbors
which allows us to wrap the standard KNNG representations.Because there are now a whole bunch of possible ways to call this API, I added a test module which runs over the different ways to create an iris embedding. See
tests/test_different_usages.py
.Includes