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

fix ep.tl.umap when neighbors_key is not None #790

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Changes from 2 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
42 changes: 22 additions & 20 deletions ehrapy/tools/_scanpy_tl_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,28 @@ def umap(

**X_umap** : `adata.obsm` field UMAP coordinates of data.
"""
if adata.uns["neighbors"] is None or neighbors_key not in adata.uns:
Zethson marked this conversation as resolved.
Show resolved Hide resolved
return sc.tl.umap(
adata=adata,
min_dist=min_dist,
spread=spread,
n_components=n_components,
maxiter=maxiter,
alpha=alpha,
gamma=gamma,
negative_sample_rate=negative_sample_rate,
init_pos=init_pos,
random_state=random_state,
a=a,
b=b,
copy=copy,
method=method,
neighbors_key=neighbors_key,
)
else:
raise ValueError(f'.uns["{neighbors_key}"] or .uns["neighbors"] were not found. Run `ep.pp.neighbors` first.')

key_to_check = neighbors_key if neighbors_key is not None else "neighbors"
if key_to_check not in adata.uns:
raise ValueError(f"Did not find .uns[{key_to_check!r}]. Ensure you run `ep.pp.neighbors` first.")
eroell marked this conversation as resolved.
Show resolved Hide resolved

return sc.tl.umap(
adata=adata,
min_dist=min_dist,
spread=spread,
n_components=n_components,
maxiter=maxiter,
alpha=alpha,
gamma=gamma,
negative_sample_rate=negative_sample_rate,
init_pos=init_pos,
random_state=random_state,
a=a,
b=b,
copy=copy,
method=method,
neighbors_key=neighbors_key,
)


def draw_graph(
Expand Down
Loading