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

Skip labels before loop #394

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

johnarevalo
Copy link
Contributor

When there are many labels to be skipped, having this validation inside the for loop makes kbet computation significantly slow:

scib/scib/metrics/kbet.py

Lines 114 to 122 in ed3e284

# subset by label
adata_sub = adata_tmp[adata_tmp.obs[label_key] == clus, :].copy()
# check if neighborhood size too small or only one batch in subset
if np.logical_or(
adata_sub.n_obs < 10, len(adata_sub.obs[batch_key].cat.categories) == 1
):
print(f"{clus} consists of a single batch or is too small. Skip.")
score = np.nan

This PR extract such checks outside the for loop to do them in a single pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants