sciv 0.0.84__py3-none-any.whl → 0.0.86__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
|
@@ -477,6 +477,7 @@ class RandomWalk:
|
|
|
477
477
|
1. The weights used in the iteration of random walk.
|
|
478
478
|
2. Assign different weight matrices to seed cells.
|
|
479
479
|
"""
|
|
480
|
+
ul.log(__name__).info("Obtain transition probability matrix.")
|
|
480
481
|
data_weight = to_dense(cell_cell_matrix, is_array=True)
|
|
481
482
|
cell_sum_weight = data_weight.sum(axis=1)[:, np.newaxis]
|
|
482
483
|
cell_sum_weight[cell_sum_weight == 0] = 1
|
|
@@ -620,39 +621,33 @@ class RandomWalk:
|
|
|
620
621
|
|
|
621
622
|
trait_values_all = to_dense(init_data.X, is_array=True)
|
|
622
623
|
|
|
623
|
-
def _process_single_trait(i: int) ->
|
|
624
|
+
def _process_single_trait(i: int) -> None:
|
|
624
625
|
trait_value = trait_values_all[:, i]
|
|
625
626
|
trait_value_max = trait_value.max()
|
|
626
627
|
trait_value_min = trait_value.min()
|
|
627
628
|
|
|
628
629
|
if trait_value_min == trait_value_max:
|
|
629
|
-
return
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
seed_cell_index=None,
|
|
633
|
-
seed_cell_weight=None,
|
|
634
|
-
seed_cell_en_index=None,
|
|
635
|
-
seed_cell_en_weight=None,
|
|
636
|
-
seed_cell_matrix=None,
|
|
637
|
-
seed_cell_matrix_en=None
|
|
638
|
-
)
|
|
639
|
-
|
|
640
|
-
# 直接获取降序索引
|
|
630
|
+
return
|
|
631
|
+
|
|
632
|
+
# Directly obtain descending index
|
|
641
633
|
trait_value_sort_index = np.argpartition(trait_value, -trait_value.size)[::-1]
|
|
642
634
|
|
|
643
|
-
#
|
|
635
|
+
# Calculate the number of cells with>0
|
|
644
636
|
_gt0_cell_size = (trait_value > 0).sum()
|
|
645
637
|
|
|
646
638
|
_seed_cell_size = self._get_seed_cell_size_(_gt0_cell_size)
|
|
647
639
|
|
|
648
|
-
|
|
640
|
+
seed_cell_count[i] = _seed_cell_size
|
|
641
|
+
seed_cell_threshold[i] = trait_value[trait_value_sort_index[_seed_cell_size]]
|
|
642
|
+
|
|
643
|
+
# Set seed cell index and weight
|
|
649
644
|
_seed_cell_index = trait_value_sort_index[:_seed_cell_size]
|
|
650
|
-
|
|
651
|
-
|
|
645
|
+
seed_cell_index[_seed_cell_index, i] = 1
|
|
646
|
+
seed_cell_weight[_seed_cell_index, i] = self._get_seed_cell_weight_(
|
|
652
647
|
seed_cell_index=_seed_cell_index, value=trait_value
|
|
653
648
|
)
|
|
654
649
|
|
|
655
|
-
#
|
|
650
|
+
# Enrichment interval index
|
|
656
651
|
_enrichment_start = _seed_cell_size
|
|
657
652
|
_enrichment_end = min(2 * _seed_cell_size, self.cell_size - 1)
|
|
658
653
|
|
|
@@ -661,56 +656,25 @@ class RandomWalk:
|
|
|
661
656
|
_enrichment_end = _seed_cell_size
|
|
662
657
|
|
|
663
658
|
_seed_cell_en_index = trait_value_sort_index[_enrichment_start:_enrichment_end]
|
|
664
|
-
|
|
665
|
-
_tmp_weight = self._get_seed_cell_weight_(
|
|
659
|
+
seed_cell_weight_en[_seed_cell_en_index, i] = self._get_seed_cell_weight_(
|
|
666
660
|
seed_cell_index=_seed_cell_index if len(_seed_cell_en_index) == len(_seed_cell_index) else _seed_cell_en_index,
|
|
667
661
|
value=trait_value,
|
|
668
662
|
seed_cell_index_enrichment=_seed_cell_en_index
|
|
669
663
|
)
|
|
670
|
-
_seed_cell_en_weight[_seed_cell_en_index] = _tmp_weight
|
|
671
|
-
|
|
672
|
-
# 无权重版本(仅在需要时计算)
|
|
673
|
-
_seed_cell_matrix = None
|
|
674
|
-
_seed_cell_matrix_en = None
|
|
675
664
|
|
|
676
665
|
if not self.is_simple and self.is_ablation:
|
|
677
666
|
seed_cell_value = np.zeros(n_cells)
|
|
678
667
|
seed_cell_value[_seed_cell_index] = 1
|
|
679
|
-
|
|
668
|
+
seed_cell_matrix[:, i] = seed_cell_value / (1 if seed_cell_value.sum() == 0 else seed_cell_value.sum())
|
|
680
669
|
|
|
681
670
|
seed_cell_en_value = np.zeros(n_cells)
|
|
682
671
|
seed_cell_en_value[_seed_cell_en_index] = 1
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
return dict(
|
|
686
|
-
seed_cell_count=_seed_cell_size,
|
|
687
|
-
seed_cell_threshold=trait_value[trait_value_sort_index[_seed_cell_size]],
|
|
688
|
-
seed_cell_index=_seed_cell_index,
|
|
689
|
-
seed_cell_weight=_seed_cell_weight,
|
|
690
|
-
seed_cell_en_index=_seed_cell_en_index,
|
|
691
|
-
seed_cell_en_weight=_seed_cell_en_weight,
|
|
692
|
-
seed_cell_matrix=_seed_cell_matrix,
|
|
693
|
-
seed_cell_matrix_en=_seed_cell_matrix_en
|
|
694
|
-
)
|
|
695
|
-
|
|
696
|
-
# 并行处理所有 trait
|
|
697
|
-
results = Parallel(n_jobs=-1, backend="threading")(delayed(_process_single_trait)(i) for i in self.trait_range)
|
|
672
|
+
seed_cell_matrix_en[:, i] = seed_cell_en_value / (1 if seed_cell_en_value.sum() == 0 else seed_cell_en_value.sum())
|
|
698
673
|
|
|
699
|
-
#
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
continue
|
|
704
|
-
|
|
705
|
-
seed_cell_count[i] = res["seed_cell_count"]
|
|
706
|
-
seed_cell_threshold[i] = res["seed_cell_threshold"]
|
|
707
|
-
seed_cell_index[res["seed_cell_index"], i] = 1
|
|
708
|
-
seed_cell_weight[:, i] = res["seed_cell_weight"]
|
|
709
|
-
seed_cell_weight_en[res["seed_cell_en_index"], i] = res["seed_cell_en_weight"]
|
|
710
|
-
|
|
711
|
-
if not self.is_simple and self.is_ablation:
|
|
712
|
-
seed_cell_matrix[:, i] = res["seed_cell_matrix"]
|
|
713
|
-
seed_cell_matrix_en[:, i] = res["seed_cell_matrix_en"]
|
|
674
|
+
# Parallel processing of all traits and real-time display of progress
|
|
675
|
+
Parallel(n_jobs=-1, backend="threading")(
|
|
676
|
+
delayed(_process_single_trait)(i) for i in tqdm(self.trait_range, desc="Obtain progress of seed cells with weights")
|
|
677
|
+
)
|
|
714
678
|
|
|
715
679
|
return seed_cell_count, seed_cell_threshold, seed_cell_matrix, seed_cell_weight, seed_cell_index, seed_cell_matrix_en, seed_cell_weight_en
|
|
716
680
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sciv
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.86
|
|
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=okGpH2OrBTO59LkyznT4gRi5S45oAcnO10Kxo5Xzy4I,47991
|
|
31
31
|
sciv/tool/_matrix_.py,sha256=O1EAhA9wxh06P_eOxEBesK7kO7IExKlhH6uJzGh1HBM,24322
|
|
32
|
-
sciv/tool/_random_walk_.py,sha256=
|
|
32
|
+
sciv/tool/_random_walk_.py,sha256=FFX_yip5WPjGAYGQTJAsTDBQlU82qewMopj_wwK2V08,47228
|
|
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.86.dist-info/METADATA,sha256=UWWKX6mHOyG66pESQiONa1g89ITE8RKe5vZvN8oSTAQ,3465
|
|
37
|
+
sciv-0.0.86.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
38
|
+
sciv-0.0.86.dist-info/licenses/LICENSE,sha256=4UvHVf3qCOZjHLs4LkYz8u96XRpXnZrpTKrkUQPs5_A,1075
|
|
39
|
+
sciv-0.0.86.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|