sciv 0.0.83__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/_algorithm_.py +0 -1
- sciv/tool/_random_walk_.py +70 -62
- {sciv-0.0.83.dist-info → sciv-0.0.85.dist-info}/METADATA +1 -1
- {sciv-0.0.83.dist-info → sciv-0.0.85.dist-info}/RECORD +6 -6
- {sciv-0.0.83.dist-info → sciv-0.0.85.dist-info}/WHEEL +0 -0
- {sciv-0.0.83.dist-info → sciv-0.0.85.dist-info}/licenses/LICENSE +0 -0
sciv/tool/_algorithm_.py
CHANGED
sciv/tool/_random_walk_.py
CHANGED
|
@@ -8,6 +8,7 @@ import torch.nn as nn
|
|
|
8
8
|
|
|
9
9
|
from torch import Tensor
|
|
10
10
|
from tqdm import tqdm
|
|
11
|
+
from joblib import Parallel, delayed
|
|
11
12
|
|
|
12
13
|
import numpy as np
|
|
13
14
|
from anndata import AnnData
|
|
@@ -24,7 +25,6 @@ from ..util import (
|
|
|
24
25
|
check_adata_get,
|
|
25
26
|
enrichment_optional,
|
|
26
27
|
check_gpu_availability,
|
|
27
|
-
dense_data,
|
|
28
28
|
sparse_data
|
|
29
29
|
)
|
|
30
30
|
|
|
@@ -600,72 +600,80 @@ class RandomWalk:
|
|
|
600
600
|
if init_data is None:
|
|
601
601
|
init_data = self.init_status
|
|
602
602
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
603
|
+
n_traits = len(self.trait_list)
|
|
604
|
+
n_cells = self.cell_size
|
|
605
|
+
|
|
606
|
+
seed_cell_count = np.zeros(n_traits, dtype=int)
|
|
607
|
+
seed_cell_threshold = np.zeros(n_traits)
|
|
608
|
+
seed_cell_weight = np.zeros((n_cells, n_traits))
|
|
609
|
+
seed_cell_index = np.zeros((n_cells, n_traits), dtype=int)
|
|
610
|
+
seed_cell_weight_en = np.zeros((n_cells, n_traits))
|
|
609
611
|
|
|
610
612
|
if not self.is_simple:
|
|
611
|
-
seed_cell_matrix
|
|
612
|
-
seed_cell_matrix_en
|
|
613
|
+
seed_cell_matrix = np.zeros((n_cells, n_traits))
|
|
614
|
+
seed_cell_matrix_en = np.zeros((n_cells, n_traits))
|
|
613
615
|
else:
|
|
614
|
-
seed_cell_matrix
|
|
615
|
-
seed_cell_matrix_en
|
|
616
|
+
seed_cell_matrix = np.zeros((1, 1))
|
|
617
|
+
seed_cell_matrix_en = np.zeros((1, 1))
|
|
616
618
|
|
|
617
|
-
ul.log(__name__).info(f"Calculate {
|
|
618
|
-
|
|
619
|
+
ul.log(__name__).info(f"Calculate {n_traits} traits/diseases for seed cells information.{f' ({info})' if info else ''}")
|
|
620
|
+
|
|
621
|
+
trait_values_all = to_dense(init_data.X, is_array=True)
|
|
622
|
+
|
|
623
|
+
def _process_single_trait(i: int) -> None:
|
|
624
|
+
trait_value = trait_values_all[:, i]
|
|
625
|
+
trait_value_max = trait_value.max()
|
|
626
|
+
trait_value_min = trait_value.min()
|
|
627
|
+
|
|
628
|
+
if trait_value_min == trait_value_max:
|
|
629
|
+
return
|
|
630
|
+
|
|
631
|
+
# Directly obtain descending index
|
|
632
|
+
trait_value_sort_index = np.argpartition(trait_value, -trait_value.size)[::-1]
|
|
633
|
+
|
|
634
|
+
# Calculate the number of cells with>0
|
|
635
|
+
_gt0_cell_size = (trait_value > 0).sum()
|
|
636
|
+
|
|
637
|
+
_seed_cell_size = self._get_seed_cell_size_(_gt0_cell_size)
|
|
638
|
+
|
|
639
|
+
seed_cell_count[i] = _seed_cell_size
|
|
640
|
+
seed_cell_threshold[i] = trait_value[trait_value_sort_index[_seed_cell_size]]
|
|
619
641
|
|
|
620
|
-
#
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
if
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
_seed_cell_en_weight_ = self._get_seed_cell_weight_(
|
|
656
|
-
seed_cell_index=_seed_cell_index_ if len(_seed_cell_en_index_) == len(_seed_cell_index_) else _seed_cell_en_index_, value=trait_value,
|
|
657
|
-
seed_cell_index_enrichment=_seed_cell_en_index_
|
|
658
|
-
)
|
|
659
|
-
seed_cell_weight_en[:, i][_seed_cell_en_index_] = _seed_cell_en_weight_
|
|
660
|
-
|
|
661
|
-
if not self.is_simple and self.is_ablation:
|
|
662
|
-
# Without weight
|
|
663
|
-
seed_cell_value = np.zeros(self.cell_size)
|
|
664
|
-
seed_cell_value[_seed_cell_index_] = 1
|
|
665
|
-
seed_cell_matrix[:, i] = seed_cell_value / (1 if seed_cell_value.sum() == 0 else seed_cell_value.sum())
|
|
666
|
-
seed_cell_en_value = np.zeros(self.cell_size)
|
|
667
|
-
seed_cell_en_value[_seed_cell_en_index_] = 1
|
|
668
|
-
seed_cell_matrix_en[:, i] = seed_cell_en_value / (1 if seed_cell_en_value.sum() == 0 else seed_cell_en_value.sum())
|
|
642
|
+
# Set seed cell index and weight
|
|
643
|
+
_seed_cell_index = trait_value_sort_index[:_seed_cell_size]
|
|
644
|
+
seed_cell_index[_seed_cell_index, i] = 1
|
|
645
|
+
seed_cell_weight[_seed_cell_index, i] = self._get_seed_cell_weight_(
|
|
646
|
+
seed_cell_index=_seed_cell_index, value=trait_value
|
|
647
|
+
)
|
|
648
|
+
|
|
649
|
+
# Enrichment interval index
|
|
650
|
+
_enrichment_start = _seed_cell_size
|
|
651
|
+
_enrichment_end = min(2 * _seed_cell_size, self.cell_size - 1)
|
|
652
|
+
|
|
653
|
+
if _gt0_cell_size == _seed_cell_size:
|
|
654
|
+
_enrichment_start = max(_seed_cell_size - self._enrichment_seed_cell_min_count_, 0)
|
|
655
|
+
_enrichment_end = _seed_cell_size
|
|
656
|
+
|
|
657
|
+
_seed_cell_en_index = trait_value_sort_index[_enrichment_start:_enrichment_end]
|
|
658
|
+
seed_cell_weight_en[_seed_cell_en_index, i] = self._get_seed_cell_weight_(
|
|
659
|
+
seed_cell_index=_seed_cell_index if len(_seed_cell_en_index) == len(_seed_cell_index) else _seed_cell_en_index,
|
|
660
|
+
value=trait_value,
|
|
661
|
+
seed_cell_index_enrichment=_seed_cell_en_index
|
|
662
|
+
)
|
|
663
|
+
|
|
664
|
+
if not self.is_simple and self.is_ablation:
|
|
665
|
+
seed_cell_value = np.zeros(n_cells)
|
|
666
|
+
seed_cell_value[_seed_cell_index] = 1
|
|
667
|
+
seed_cell_matrix[:, i] = seed_cell_value / (1 if seed_cell_value.sum() == 0 else seed_cell_value.sum())
|
|
668
|
+
|
|
669
|
+
seed_cell_en_value = np.zeros(n_cells)
|
|
670
|
+
seed_cell_en_value[_seed_cell_en_index] = 1
|
|
671
|
+
seed_cell_matrix_en[:, i] = seed_cell_en_value / (1 if seed_cell_en_value.sum() == 0 else seed_cell_en_value.sum())
|
|
672
|
+
|
|
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
|
+
)
|
|
669
677
|
|
|
670
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
|
|
671
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>
|
|
@@ -27,13 +27,13 @@ sciv/preprocessing/_scanpy_.py,sha256=mmkk4cMCzJCziF49RnOuXBiF4frS6aSiwZdUmfDAg4
|
|
|
27
27
|
sciv/preprocessing/_scvi_.py,sha256=ZIDkQ_4deYmzSMiAbu5C3j_jMMl7hBTFLCBXHCNj3B4,10332
|
|
28
28
|
sciv/preprocessing/_snapatac_.py,sha256=Dq8CHF7Psl3CQszaEokQYO56Oe2uzyWOy_cGlaOywfc,27798
|
|
29
29
|
sciv/tool/__init__.py,sha256=WXzHkWt6RgBC3qqD-98nR5wQmt6oC850ox_VpMrapSU,2468
|
|
30
|
-
sciv/tool/_algorithm_.py,sha256=
|
|
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
|