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): obs filtering #148

Merged
merged 17 commits into from
Oct 16, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make tests for filtering more sensible
gtca committed Oct 16, 2024
commit 04489bf5f6138038f0c24468b5d6b0e11fc14b2d
9 changes: 5 additions & 4 deletions tests/test_muon_preproc.py
Original file line number Diff line number Diff line change
@@ -83,12 +83,13 @@ def test_filter_obs_adata_view(self, mdata, filepath_h5mu):
mu.pp.filter_obs(view, sub)

def test_filter_obs_with_obsm_obsp(self, pbmc3k_processed):
A = pbmc3k_processed[:, :500].copy()
B = pbmc3k_processed[:, 500:].copy()
A = pbmc3k_processed[:500,].copy()
B = pbmc3k_processed[500:,].copy()
A_subset = A[A.obs["louvain"] == "B cells"].copy()
B_subset = B[B.obs["louvain"] == "B cells"].copy()
mdata = mu.MuData({"A": A, "B": B})
mu.pp.filter_obs(mdata, "A:louvain", lambda x: x == "B cells")
mdata = mu.MuData({"A": A, "B": B}, axis=1)
mdata.pull_obs("louvain")
mu.pp.filter_obs(mdata, "louvain", lambda x: x == "B cells")
assert mdata["B"].n_obs == B_subset.n_obs
assert mdata["A"].obs["louvain"].unique() == "B cells"
assert B.n_obs == B_subset.n_obs