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

Extend test coverage to new PCA-CS function #85

Merged
merged 2 commits into from
Nov 11, 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
28 changes: 28 additions & 0 deletions tests/test_efaar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import pandas as pd
import pytest
from anndata import AnnData

from efaar_benchmarking import efaar
Expand Down Expand Up @@ -63,3 +64,30 @@ def test_filter_cell_profiler_features():
filtered_features, _ = efaar.filter_cell_profiler_features(features, metadata)
assert not filtered_features.empty
assert "Image_Granularity_12_ER" not in filtered_features.columns


@pytest.mark.parametrize(
"metadata, expected_shape, expect_error",
[
(
pd.DataFrame({"perturbation": ["control", "control", "treatment", "treatment"], "batch": [1, 1, 1, 1]}),
(4, 2),
False,
),
(
pd.DataFrame({"perturbation": ["treatment", "treatment", "treatment", "treatment"], "batch": [1, 1, 1, 1]}),
None,
True,
),
],
)
def test_pca_centerscale_on_controls(metadata, expected_shape, expect_error):
embeddings = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
pert_col = "perturbation"
control_key = "control"
if expect_error:
with pytest.raises(ValueError, match=f"No control samples found for {control_key}"):
efaar.pca_centerscale_on_controls(embeddings, metadata, pert_col, control_key, None)
else:
result = efaar.pca_centerscale_on_controls(embeddings, metadata, pert_col, control_key, None)
assert result.shape == expected_shape
Loading