Skip to content
Merged
Show file tree
Hide file tree
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: 2 additions & 9 deletions scxmatch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ._match import _kNN, _calculate_distances, _extract_matching, _construct_graph_via_kNN, _construct_graph_from_distances, _match, _add_partners_to_adata
from ._count import _cross_match_count, _get_p_value, _get_z_score, _get_relative_support, _rosenbaum_test

def test(adata, group_by, test_group, reference=None, metric="sqeuclidean", rank=False, k=100, total_RAM_available_gb=None):
def test(adata, group_by, test_group, reference=None, metric="sqeuclidean", rank=False, k=100):
"""
Perform Rosenbaum's matching-based test for checking the association between two groups
using a distance-based matching approach.
Expand Down Expand Up @@ -100,14 +100,7 @@ def test(adata, group_by, test_group, reference=None, metric="sqeuclidean", rank
if not isinstance(k, int):
if k is not None:
raise ValueError("k must be an integer or None.")

if k == "auto" and total_RAM_available_gb is None:
raise ValueError("If k is set to 'auto', total_RAM_available_gb must be provided.")

if k != "auto" and (total_RAM_available_gb is not None):
warnings.warn("total_RAM_available_gb will be ignored, as k is not \"auto\".")



subset.obs["XMatch_group"] = np.where(subset.obs[group_by].isin(test_group), "test", "reference")

if isinstance(k, int):
Expand Down
11 changes: 9 additions & 2 deletions tests/test_mwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def test_rank_parameter(adata, rank):

@pytest.mark.parametrize("k", [10, None])
def test_k_parameter(adata, k):
test(adata, group_by="Group", test_group="test", reference="control",
k=k, total_RAM_available_gb=15)
test(adata, group_by="Group", test_group="test", reference="control", k=k)


def test_invalid_k_type(adata):
Expand All @@ -68,6 +67,14 @@ def test_invalid_k_negative(adata):
test(adata, group_by="Group", test_group="test", reference="control", k=-1.5)


# ── warnings ─────────────────────────────────────────────────────────────────

def test_view_input_warns(adata):
view = adata[adata.obs["Group"].isin(["test", "control"])]
with pytest.warns(UserWarning, match="view"):
test(view, group_by="Group", test_group="test", reference="control", k=10)


# ── output structure ──────────────────────────────────────────────────────────

def test_partner_column_added(adata):
Expand Down
Loading