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

Add two distance metrics, three-way comparison and bootstrapping #608

Merged
merged 36 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fd21dc1
add two distance metrics
wxicu May 26, 2024
3af7d89
add obsm_key param to distance test
wxicu May 26, 2024
3fe911b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 26, 2024
6d419c3
add agg fct
wxicu Jun 2, 2024
ca86025
speed up tests
wxicu Jun 3, 2024
0830535
Merge branch 'main' into distance
wxicu Jun 3, 2024
9fd4c2b
add type
wxicu Jun 3, 2024
fc71eae
add description
wxicu Jun 3, 2024
09e5fea
Update pertpy/tools/_distances/_distances.py
wxicu Jun 5, 2024
ad23ca6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
dc74884
Update pertpy/tools/_distances/_distances.py
wxicu Jun 5, 2024
c774cd2
Update pertpy/tools/_distances/_distances.py
wxicu Jun 5, 2024
d413d67
Update pertpy/tools/_distances/_distances.py
wxicu Jun 5, 2024
b7f2cf7
Update pertpy/tools/_distances/_distances.py
wxicu Jun 5, 2024
e71f81c
Update pertpy/tools/_distances/_distances.py
wxicu Jun 5, 2024
edaa6e6
Update pertpy/tools/_distances/_distances.py
wxicu Jun 5, 2024
317cfd5
update code
wxicu Jun 6, 2024
47b4134
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 6, 2024
d261410
fix drug
wxicu Jun 6, 2024
4fd29a0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 6, 2024
30baefe
add bootstrapping and metrics_3g
wxicu Jun 7, 2024
2c8127c
speed up tests,
wxicu Jun 7, 2024
57b14c3
remove test classes
wxicu Jun 10, 2024
78d00fa
drop test classes
wxicu Jun 10, 2024
052fd00
update compare_de
wxicu Jun 12, 2024
3a8eac6
correct the comments
wxicu Jun 12, 2024
63ed17a
speed tests
wxicu Jun 13, 2024
f9e0d36
speed up tests
wxicu Jun 13, 2024
2e65f9d
split metrics_3g
wxicu Jun 18, 2024
2e7acf3
fix pre-commit
wxicu Jun 18, 2024
69163ff
pin numpy <2
wxicu Jun 19, 2024
67c54be
unpin numpy
wxicu Jun 20, 2024
6e32f37
speed up mahalanobis distance
wxicu Jun 20, 2024
620e645
use scipy to calculate mahalanobis distance
wxicu Jun 20, 2024
10d3483
rename DGE to DGEEVAL
wxicu Jun 23, 2024
4a07252
Merge branch 'main' into distance
wxicu Jun 23, 2024
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
13 changes: 9 additions & 4 deletions pertpy/tools/_distances/_distance_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ def __init__(
self.alpha = alpha
self.correction = correction
self.cell_wise_metric = (
cell_wise_metric if cell_wise_metric else Distance(self.metric, self.obsm_key).cell_wise_metric
cell_wise_metric if cell_wise_metric else Distance(self.metric, obsm_key=self.obsm_key).cell_wise_metric
)

self.distance = Distance(
self.metric, layer_key=self.layer_key, obsm_key=self.obsm_key, cell_wise_metric=self.cell_wise_metric
self.metric,
layer_key=self.layer_key,
obsm_key=self.obsm_key,
cell_wise_metric=self.cell_wise_metric,
)

def __call__(
Expand Down Expand Up @@ -176,7 +179,8 @@ def test_xy(self, adata: AnnData, groupby: str, contrast: str, show_progressbar:
# Evaluate the test
# count times shuffling resulted in larger distance
comparison_results = np.array(
pd.concat([r["distance"] - df["distance"] for r in results], axis=1) > 0, dtype=int
pd.concat([r["distance"] - df["distance"] for r in results], axis=1) > 0,
dtype=int,
)
n_failures = pd.Series(np.clip(np.sum(comparison_results, axis=1), 1, np.inf), index=df.index)
pvalues = n_failures / self.n_perms
Expand Down Expand Up @@ -284,7 +288,8 @@ def test_precomputed(self, adata: AnnData, groupby: str, contrast: str, verbose:
# Evaluate the test
# count times shuffling resulted in larger distance
comparison_results = np.array(
pd.concat([r["distance"] - df["distance"] for r in results], axis=1) > 0, dtype=int
pd.concat([r["distance"] - df["distance"] for r in results], axis=1) > 0,
dtype=int,
)
n_failures = pd.Series(np.clip(np.sum(comparison_results, axis=1), 1, np.inf), index=df.index)
pvalues = n_failures / self.n_perms
Expand Down
Loading
Loading