|
12 | 12 | import numpy.typing as npt |
13 | 13 | import pandas as pd |
14 | 14 | import polars as pl |
15 | | -import ray |
16 | | -import scipy |
17 | 15 | import scipy.sparse as sparse |
18 | | -import sklearn |
19 | | -from scipy.stats import ranksums |
20 | 16 |
|
21 | 17 | if TYPE_CHECKING: |
22 | 18 | from pycisTopic.cistopic_class import CistopicObject |
@@ -1487,67 +1483,6 @@ def find_diff_accessible_regions( |
1487 | 1483 | return markers_dict |
1488 | 1484 |
|
1489 | 1485 |
|
1490 | | -def get_wilcoxon_test_pvalues(fg_mat, bg_mat): |
1491 | | - """ |
1492 | | - Calculate wilcoxon test p-values between foreground and background matrix. |
1493 | | -
|
1494 | | - Parameters |
1495 | | - ---------- |
1496 | | - fg_mat |
1497 | | - 2D-numpy foreground matrix. |
1498 | | - bg_mat |
1499 | | - 2D-numpy background matrix. |
1500 | | -
|
1501 | | - """ |
1502 | | - if fg_mat.shape[0] != bg_mat.shape[0]: |
1503 | | - raise ValueError( |
1504 | | - "Foreground matrix and background matrix have a different first dimension:" |
1505 | | - f" {fg_mat.shape[0]} vs {bg_mat.shape[0]}" |
1506 | | - ) |
1507 | | - |
1508 | | - wilcoxon_test_pvalues = [ |
1509 | | - wilcoxon_test.pvalue |
1510 | | - for wilcoxon_test in [ |
1511 | | - ranksums(fg_mat[i], y=bg_mat[i]) for i in range(fg_mat.shape[0]) |
1512 | | - ] |
1513 | | - ] |
1514 | | - |
1515 | | - return wilcoxon_test_pvalues |
1516 | | - |
1517 | | - |
1518 | | -@ray.remote |
1519 | | -def get_wilcoxon_test_pvalues_ray(fg_mat, bg_mat, start, end): |
1520 | | - """ |
1521 | | - Calculate wilcoxon test p-values with ray between a subset of foreground and background matrix. |
1522 | | -
|
1523 | | - Parameters |
1524 | | - ---------- |
1525 | | - fg_mat |
1526 | | - 2D-numpy foreground matrix. |
1527 | | - bg_mat |
1528 | | - 2D-numpy background matrix. |
1529 | | - start |
1530 | | - Starting row index (included). |
1531 | | - end |
1532 | | - Ending row index (excluded). |
1533 | | -
|
1534 | | - """ |
1535 | | - if fg_mat.shape[0] != bg_mat.shape[0]: |
1536 | | - raise ValueError( |
1537 | | - "Foreground matrix and background matrix have a different first dimension:" |
1538 | | - f" {fg_mat.shape[0]} vs {bg_mat.shape[0]}" |
1539 | | - ) |
1540 | | - |
1541 | | - wilcoxon_test_pvalues_part = [ |
1542 | | - wilcoxon_test.pvalue |
1543 | | - for wilcoxon_test in [ |
1544 | | - ranksums(fg_mat[i], y=bg_mat[i]) for i in range(start, end) |
1545 | | - ] |
1546 | | - ] |
1547 | | - |
1548 | | - return wilcoxon_test_pvalues_part |
1549 | | - |
1550 | | - |
1551 | 1486 | # TODO: Add these generic functions to another package |
1552 | 1487 | def p_adjust_bh(p: npt.NDArray): |
1553 | 1488 | """Benjamini-Hochberg p-value correction for multiple hypothesis testing.""" |
|
0 commit comments