sciv 0.0.82__py3-none-any.whl → 0.0.83__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sciv/tool/_random_walk_.py
CHANGED
|
@@ -23,14 +23,16 @@ from ..util import (
|
|
|
23
23
|
collection,
|
|
24
24
|
check_adata_get,
|
|
25
25
|
enrichment_optional,
|
|
26
|
-
check_gpu_availability
|
|
26
|
+
check_gpu_availability,
|
|
27
|
+
dense_data,
|
|
28
|
+
sparse_data
|
|
27
29
|
)
|
|
28
30
|
|
|
29
31
|
__name__: str = "tool_random_walk"
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
def _random_walk_cpu_(
|
|
33
|
-
seed_cell_vector:
|
|
35
|
+
seed_cell_vector: Union[list, np.ndarray, np.matrix],
|
|
34
36
|
weight: matrix_data = None,
|
|
35
37
|
gamma: float = 0.05,
|
|
36
38
|
epsilon: float = 1e-5,
|
|
@@ -46,17 +48,19 @@ def _random_walk_cpu_(
|
|
|
46
48
|
:return: The value after random walk.
|
|
47
49
|
"""
|
|
48
50
|
|
|
49
|
-
w = to_dense(weight)
|
|
50
|
-
|
|
51
51
|
# Random walk
|
|
52
|
-
p0 = seed_cell_vector.
|
|
52
|
+
p0 = np.asarray(seed_cell_vector, dtype=float).ravel()[:, np.newaxis]
|
|
53
53
|
pt: matrix_data = p0.copy()
|
|
54
54
|
k = 0
|
|
55
55
|
delta = 1
|
|
56
56
|
|
|
57
57
|
# iteration
|
|
58
58
|
while delta > epsilon:
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
if hasattr(weight, "dot"):
|
|
61
|
+
p1 = (1 - gamma) * weight.dot(pt) + gamma * p0
|
|
62
|
+
else:
|
|
63
|
+
p1 = (1 - gamma) * np.dot(weight, pt) + gamma * p0
|
|
60
64
|
|
|
61
65
|
# 1 and 2, It would be faster alone
|
|
62
66
|
if p == 1:
|
|
@@ -297,7 +301,6 @@ class RandomWalk:
|
|
|
297
301
|
|
|
298
302
|
init_status.obs["clusters"] = init_status.obs["clusters"].astype(str)
|
|
299
303
|
|
|
300
|
-
self.cc_adata = cc_adata
|
|
301
304
|
self.epsilon = epsilon
|
|
302
305
|
self.gamma = gamma
|
|
303
306
|
self.enrichment_gamma = enrichment_gamma
|
|
@@ -390,10 +393,12 @@ class RandomWalk:
|
|
|
390
393
|
self.random_seed_cell = np.zeros(init_status.shape)
|
|
391
394
|
|
|
392
395
|
# Transition Probability Matrix
|
|
393
|
-
self.weight = self._get_weight_(
|
|
396
|
+
self.weight = self._get_weight_(cc_adata.X)
|
|
394
397
|
|
|
395
398
|
if not is_simple and self.is_ablation:
|
|
396
|
-
self.weight_m_knn = self._get_weight_(
|
|
399
|
+
self.weight_m_knn = self._get_weight_(cc_adata.layers["cell_mutual_knn"])
|
|
400
|
+
|
|
401
|
+
del cc_adata
|
|
397
402
|
|
|
398
403
|
self.cluster_types, self.init_seed_cell_size = self._get_cluster_info_()
|
|
399
404
|
|
|
@@ -419,6 +424,9 @@ class RandomWalk:
|
|
|
419
424
|
self.seed_cell_weight_en_ncw
|
|
420
425
|
) = self._get_seed_cell_(init_data=init_status_no_weight, info="ablation")
|
|
421
426
|
|
|
427
|
+
del self.cell_affinity
|
|
428
|
+
del init_status
|
|
429
|
+
|
|
422
430
|
def _random_walk_(
|
|
423
431
|
self,
|
|
424
432
|
seed_cell_data: matrix_data,
|
|
@@ -461,7 +469,7 @@ class RandomWalk:
|
|
|
461
469
|
return self._random_walk_(seed_cell_data, weight, self.gamma)
|
|
462
470
|
|
|
463
471
|
@staticmethod
|
|
464
|
-
def _get_weight_(cell_cell_matrix: matrix_data) ->
|
|
472
|
+
def _get_weight_(cell_cell_matrix: matrix_data) -> sparse_data:
|
|
465
473
|
"""
|
|
466
474
|
Obtain weights in random walk
|
|
467
475
|
:param cell_cell_matrix: Cell to cell connectivity matrix
|
|
@@ -472,7 +480,7 @@ class RandomWalk:
|
|
|
472
480
|
data_weight = to_dense(cell_cell_matrix, is_array=True)
|
|
473
481
|
cell_sum_weight = data_weight.sum(axis=1)[:, np.newaxis]
|
|
474
482
|
cell_sum_weight[cell_sum_weight == 0] = 1
|
|
475
|
-
return data_weight / cell_sum_weight
|
|
483
|
+
return to_sparse(data_weight / cell_sum_weight)
|
|
476
484
|
|
|
477
485
|
def _get_cell_weight_(self, seed_cell_size: int) -> matrix_data:
|
|
478
486
|
_cell_cell_knn_: matrix_data = self.cell_affinity.copy()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sciv
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.83
|
|
4
4
|
Summary: Unveiling the pivotal cell types involved in variant function regulation at a single-cell resolution
|
|
5
5
|
Project-URL: github, https://github.com/YuZhengM/sciv
|
|
6
6
|
Author-email: Zheng-Min Yu <yuzmbio@163.com>
|
|
@@ -29,11 +29,11 @@ sciv/preprocessing/_snapatac_.py,sha256=Dq8CHF7Psl3CQszaEokQYO56Oe2uzyWOy_cGlaOy
|
|
|
29
29
|
sciv/tool/__init__.py,sha256=WXzHkWt6RgBC3qqD-98nR5wQmt6oC850ox_VpMrapSU,2468
|
|
30
30
|
sciv/tool/_algorithm_.py,sha256=6xLGB1-FRfRiHSCVb_tHvzY_N-RoMZ79p0O2fEio688,48030
|
|
31
31
|
sciv/tool/_matrix_.py,sha256=O1EAhA9wxh06P_eOxEBesK7kO7IExKlhH6uJzGh1HBM,24322
|
|
32
|
-
sciv/tool/_random_walk_.py,sha256=
|
|
32
|
+
sciv/tool/_random_walk_.py,sha256=E6QxZWXc1FY6rr0EiBNzX7TA5h9NFjt9YjpI_M4wN34,47567
|
|
33
33
|
sciv/util/__init__.py,sha256=nOxZ8if27X7AUJ6hZwTwxOJwIBJb0obWlHjqCzjg_Gc,1964
|
|
34
34
|
sciv/util/_constant_.py,sha256=w0wKQd8guLd1ZTW24_5aECrWsIWDiNQmEpLsWlHar1A,3000
|
|
35
35
|
sciv/util/_core_.py,sha256=ZD2uSnEBHVu0i9TmXWzri_3bXZzYKnIZk818gW3zadE,14751
|
|
36
|
-
sciv-0.0.
|
|
37
|
-
sciv-0.0.
|
|
38
|
-
sciv-0.0.
|
|
39
|
-
sciv-0.0.
|
|
36
|
+
sciv-0.0.83.dist-info/METADATA,sha256=M5efcCSMDCUU4-8C8CVEQ2fpJw__3ltHPDU2LyYxj9Q,3465
|
|
37
|
+
sciv-0.0.83.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
38
|
+
sciv-0.0.83.dist-info/licenses/LICENSE,sha256=4UvHVf3qCOZjHLs4LkYz8u96XRpXnZrpTKrkUQPs5_A,1075
|
|
39
|
+
sciv-0.0.83.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|