Skip to content

Commit 5c3d592

Browse files
authored
Merge pull request #443 from BiAPoL/add-min-dist-to-umap-parameters
add min_dist to umap parameters
2 parents a098c6d + 9eee728 commit 5c3d592

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/napari_clusters_plotter/_algorithms.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def reduce_umap(
7777
data: pd.DataFrame,
7878
n_components: int = 2,
7979
n_neighbors: int = 30,
80+
min_dist: float = 0.1,
8081
scale: bool = True,
8182
) -> FunctionWorker[pd.DataFrame]:
8283
"""
@@ -85,7 +86,11 @@ def reduce_umap(
8586

8687
@thread_worker(progress=True)
8788
def _reduce_umap(
88-
data: pd.DataFrame, n_components: int, n_neighbors: int, scale: bool
89+
data: pd.DataFrame,
90+
n_components: int,
91+
n_neighbors: int,
92+
min_dist: float,
93+
scale: bool,
8994
) -> pd.DataFrame:
9095
import umap
9196
from sklearn.preprocessing import StandardScaler
@@ -98,7 +103,11 @@ def _reduce_umap(
98103
else:
99104
preprocessed = non_nan_data.values
100105

101-
reducer = umap.UMAP(n_components=n_components, n_neighbors=n_neighbors)
106+
reducer = umap.UMAP(
107+
n_components=n_components,
108+
n_neighbors=n_neighbors,
109+
min_dist=min_dist,
110+
)
102111
reduced_data = reducer.fit_transform(preprocessed)
103112

104113
# Add NaN rows back
@@ -107,7 +116,7 @@ def _reduce_umap(
107116

108117
return result
109118

110-
return _reduce_umap(data, n_components, n_neighbors, scale)
119+
return _reduce_umap(data, n_components, n_neighbors, min_dist, scale)
111120

112121

113122
def cluster_kmeans(

0 commit comments

Comments
 (0)