sciv 0.0.84__py3-none-any.whl → 0.0.85__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
|
@@ -620,39 +620,33 @@ class RandomWalk:
|
|
|
620
620
|
|
|
621
621
|
trait_values_all = to_dense(init_data.X, is_array=True)
|
|
622
622
|
|
|
623
|
-
def _process_single_trait(i: int) ->
|
|
623
|
+
def _process_single_trait(i: int) -> None:
|
|
624
624
|
trait_value = trait_values_all[:, i]
|
|
625
625
|
trait_value_max = trait_value.max()
|
|
626
626
|
trait_value_min = trait_value.min()
|
|
627
627
|
|
|
628
628
|
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
|
-
# 直接获取降序索引
|
|
629
|
+
return
|
|
630
|
+
|
|
631
|
+
# Directly obtain descending index
|
|
641
632
|
trait_value_sort_index = np.argpartition(trait_value, -trait_value.size)[::-1]
|
|
642
633
|
|
|
643
|
-
#
|
|
634
|
+
# Calculate the number of cells with>0
|
|
644
635
|
_gt0_cell_size = (trait_value > 0).sum()
|
|
645
636
|
|
|
646
637
|
_seed_cell_size = self._get_seed_cell_size_(_gt0_cell_size)
|
|
647
638
|
|
|
648
|
-
|
|
639
|
+
seed_cell_count[i] = _seed_cell_size
|
|
640
|
+
seed_cell_threshold[i] = trait_value[trait_value_sort_index[_seed_cell_size]]
|
|
641
|
+
|
|
642
|
+
# Set seed cell index and weight
|
|
649
643
|
_seed_cell_index = trait_value_sort_index[:_seed_cell_size]
|
|
650
|
-
|
|
651
|
-
|
|
644
|
+
seed_cell_index[_seed_cell_index, i] = 1
|
|
645
|
+
seed_cell_weight[_seed_cell_index, i] = self._get_seed_cell_weight_(
|
|
652
646
|
seed_cell_index=_seed_cell_index, value=trait_value
|
|
653
647
|
)
|
|
654
648
|
|
|
655
|
-
#
|
|
649
|
+
# Enrichment interval index
|
|
656
650
|
_enrichment_start = _seed_cell_size
|
|
657
651
|
_enrichment_end = min(2 * _seed_cell_size, self.cell_size - 1)
|
|
658
652
|
|
|
@@ -661,56 +655,25 @@ class RandomWalk:
|
|
|
661
655
|
_enrichment_end = _seed_cell_size
|
|
662
656
|
|
|
663
657
|
_seed_cell_en_index = trait_value_sort_index[_enrichment_start:_enrichment_end]
|
|
664
|
-
|
|
665
|
-
_tmp_weight = self._get_seed_cell_weight_(
|
|
658
|
+
seed_cell_weight_en[_seed_cell_en_index, i] = self._get_seed_cell_weight_(
|
|
666
659
|
seed_cell_index=_seed_cell_index if len(_seed_cell_en_index) == len(_seed_cell_index) else _seed_cell_en_index,
|
|
667
660
|
value=trait_value,
|
|
668
661
|
seed_cell_index_enrichment=_seed_cell_en_index
|
|
669
662
|
)
|
|
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
663
|
|
|
676
664
|
if not self.is_simple and self.is_ablation:
|
|
677
665
|
seed_cell_value = np.zeros(n_cells)
|
|
678
666
|
seed_cell_value[_seed_cell_index] = 1
|
|
679
|
-
|
|
667
|
+
seed_cell_matrix[:, i] = seed_cell_value / (1 if seed_cell_value.sum() == 0 else seed_cell_value.sum())
|
|
680
668
|
|
|
681
669
|
seed_cell_en_value = np.zeros(n_cells)
|
|
682
670
|
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)
|
|
671
|
+
seed_cell_matrix_en[:, i] = seed_cell_en_value / (1 if seed_cell_en_value.sum() == 0 else seed_cell_en_value.sum())
|
|
698
672
|
|
|
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"]
|
|
673
|
+
# Parallel processing of all traits and real-time display of progress
|
|
674
|
+
Parallel(n_jobs=-1, backend="threading")(
|
|
675
|
+
delayed(_process_single_trait)(i) for i in tqdm(self.trait_range, desc="Obtain progress of seed cells with weights")
|
|
676
|
+
)
|
|
714
677
|
|
|
715
678
|
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
679
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sciv
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.85
|
|
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=PyVz11dA0rfbYyGYw3WE9BH9KiTUSRHsNDf1J-wfIn0,47156
|
|
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.85.dist-info/METADATA,sha256=wJDwU4Oks-klm0j2Lg0TyoV7gqF_Gn0JwKa7_c3iCGA,3465
|
|
37
|
+
sciv-0.0.85.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
38
|
+
sciv-0.0.85.dist-info/licenses/LICENSE,sha256=4UvHVf3qCOZjHLs4LkYz8u96XRpXnZrpTKrkUQPs5_A,1075
|
|
39
|
+
sciv-0.0.85.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|