Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add **kwargs in umap to allow other parameters in UMAP. #222

Merged
merged 2 commits into from
Feb 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions snapatac2-python/snapatac2/tools/_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def umap2(
Random seed.
inplace
Whether to store the result in the anndata object.

Returns
-------
np.ndarray | None
Expand Down Expand Up @@ -68,6 +68,7 @@ def umap(
key_added: str = 'umap',
random_state: int = 0,
inplace: bool = True,
**kwargs
) -> np.ndarray | None:
"""
Parameters
Expand All @@ -86,6 +87,8 @@ def umap(
Random seed.
inplace
Whether to store the result in the anndata object.
**kwargs
Other parameters defined in umap.UMAP

Returns
-------
Expand All @@ -101,7 +104,9 @@ def umap(
if use_dims is not None:
data = data[:, :use_dims] if isinstance(use_dims, int) else data[:, use_dims]

umap = UMAP(random_state=random_state, n_components=n_comps).fit_transform(data)
umap = UMAP(random_state=random_state,
n_components=n_comps,
**kwargs).fit_transform(data)
if inplace:
adata.obsm["X_" + key_added] = umap
else:
Expand Down Expand Up @@ -518,4 +523,4 @@ def multi_spectral(
evals = evals[idx]
evecs = evecs[:, idx] * np.sqrt(evals)

return (evals, evecs)
return (evals, evecs)
Loading