scprep icon indicating copy to clipboard operation
scprep copied to clipboard

Density subsampling

Open scottgigante opened this issue 5 years ago • 1 comments

Describe the solution you'd like scprep.select.subsample(density=True, knn=3). Use nmslib if available?

Describe alternatives you've considered Use sklearn.NearestNeighbors

scottgigante avatar Jun 08 '20 22:06 scottgigante

distances, _ = sklearn.NearestNeighbors(n_neighbors=3).fit(X).kneighbors()
distances = distances.max(axis=1)
p = distances / distances.sum()
X_subsample = scprep.select.select_rows(X, idx=np.random.choice(X.shape[0], n, p=p, replace=False)

scottgigante avatar Jun 08 '20 22:06 scottgigante