sciv 0.0.105__py3-none-any.whl → 0.0.107__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.
@@ -13,7 +13,7 @@ from torch.cuda import OutOfMemoryError
13
13
 
14
14
  from .. import util as ul
15
15
  from ..tool import umap, tsne
16
- from ..util import path
16
+ from ..util import path, check_gpu_availability
17
17
 
18
18
  __name__: str = "preprocessing_scvi"
19
19
 
@@ -77,53 +77,70 @@ def poisson_vi(
77
77
  scvi.external.POISSONVI.setup_anndata(adata, layer="fragments", batch_key=batch_key)
78
78
  _model_ = scvi.external.POISSONVI(adata)
79
79
 
80
- try:
81
- data_splitter_kwargs = {"drop_dataset_tail": True, "drop_last": False}
82
- with warnings.catch_warnings():
83
- warnings.simplefilter("ignore")
84
- _model_.train(
85
- max_epochs=int(max_epochs),
86
- check_val_every_n_epoch=1,
87
- accelerator="gpu",
88
- devices=-1,
89
- datasplitter_kwargs=data_splitter_kwargs,
90
- strategy="ddp_notebook_find_unused_parameters_true",
91
- lr=lr,
92
- batch_size=int(batch_size),
93
- eps=eps,
94
- early_stopping=early_stopping,
95
- early_stopping_patience=int(early_stopping_patience)
96
- )
97
- except Exception as ex:
80
+ if check_gpu_availability():
98
81
 
99
82
  try:
100
- ul.log(__name__).warning(f"Multiple GPU failed to run, attempting to run on one card.\n {ex}")
101
- with warnings.catch_warnings():
102
- warnings.simplefilter("ignore")
103
- _model_.train(
104
- max_epochs=int(max_epochs),
105
- check_val_every_n_epoch=1,
106
- lr=lr,
107
- batch_size=int(batch_size),
108
- eps=eps,
109
- early_stopping=early_stopping,
110
- early_stopping_patience=int(early_stopping_patience)
111
- )
112
- except Exception as exc:
113
- ul.log(__name__).warning(f"GPU failed to run, try to switch to CPU running.\n {exc}")
83
+ data_splitter_kwargs = {"drop_dataset_tail": True, "drop_last": False}
114
84
  with warnings.catch_warnings():
115
85
  warnings.simplefilter("ignore")
116
- _model_.to_device('cpu')
117
86
  _model_.train(
118
- max_epochs=int(max_epochs),
87
+ max_epochs=max_epochs,
119
88
  check_val_every_n_epoch=1,
89
+ accelerator="gpu",
90
+ devices=-1,
91
+ datasplitter_kwargs=data_splitter_kwargs,
92
+ strategy="ddp_notebook_find_unused_parameters_true",
120
93
  lr=lr,
121
- batch_size=int(batch_size),
94
+ batch_size=batch_size,
122
95
  eps=eps,
123
96
  early_stopping=early_stopping,
124
- early_stopping_patience=int(early_stopping_patience),
125
- accelerator="cpu"
97
+ early_stopping_patience=early_stopping_patience
126
98
  )
99
+ except Exception as ex:
100
+
101
+ try:
102
+ ul.log(__name__).warning(f"Multiple GPU failed to run, attempting to run on one card.\n {ex}")
103
+ with warnings.catch_warnings():
104
+ warnings.simplefilter("ignore")
105
+ _model_.train(
106
+ max_epochs=max_epochs,
107
+ check_val_every_n_epoch=1,
108
+ lr=lr,
109
+ batch_size=batch_size,
110
+ eps=eps,
111
+ early_stopping=early_stopping,
112
+ early_stopping_patience=early_stopping_patience
113
+ )
114
+ except Exception as exc:
115
+ ul.log(__name__).warning(f"GPU failed to run, try to switch to CPU running.\n {exc}")
116
+ with warnings.catch_warnings():
117
+ warnings.simplefilter("ignore")
118
+ _model_.to_device('cpu')
119
+ _model_.train(
120
+ max_epochs=max_epochs,
121
+ check_val_every_n_epoch=1,
122
+ lr=lr,
123
+ batch_size=batch_size,
124
+ eps=eps,
125
+ early_stopping=early_stopping,
126
+ early_stopping_patience=early_stopping_patience,
127
+ accelerator="cpu"
128
+ )
129
+ else:
130
+
131
+ with warnings.catch_warnings():
132
+ warnings.simplefilter("ignore")
133
+ _model_.to_device('cpu')
134
+ _model_.train(
135
+ max_epochs=max_epochs,
136
+ check_val_every_n_epoch=1,
137
+ lr=lr,
138
+ batch_size=batch_size,
139
+ eps=eps,
140
+ early_stopping=early_stopping,
141
+ early_stopping_patience=early_stopping_patience,
142
+ accelerator="cpu"
143
+ )
127
144
 
128
145
  return _model_
129
146
 
sciv/tool/_algorithm_.py CHANGED
@@ -982,12 +982,16 @@ def overlap_sum(regions: AnnData, variants: dict, trait_info: DataFrame, n_jobs:
982
982
  # Collect non-zero values
983
983
  if matrix_sum.size == 1:
984
984
  val = float(matrix_sum)
985
+
985
986
  if val != 0:
986
987
  local_row_indices.append(row_idx)
987
988
  local_col_indices.append(col_idx)
988
989
  local_data_vals.append(val)
990
+
989
991
  else:
992
+
990
993
  for t_idx, v in enumerate(matrix_sum):
994
+
991
995
  if v != 0:
992
996
  local_row_indices.append(row_idx)
993
997
  local_col_indices.append(col_idx + t_idx)
@@ -86,7 +86,7 @@ class RandomWalkModel(nn.Module):
86
86
  self.p = p
87
87
  self.pbar = pbar
88
88
 
89
- is_gpu_available = check_gpu_availability(verbose=False)
89
+ is_gpu_available = check_gpu_availability()
90
90
 
91
91
  self.device = 'cuda' if (device == 'gpu' or (device == 'auto' and is_gpu_available)) else 'cpu'
92
92
 
@@ -197,7 +197,7 @@ def random_walk(
197
197
  device: str = 'auto'
198
198
  ) -> matrix_data:
199
199
 
200
- availability = check_gpu_availability(False)
200
+ availability = check_gpu_availability()
201
201
 
202
202
  if device == 'cpu' or (device == 'auto' and not availability):
203
203
  sample_count = seed_cell_weight.shape[1]
@@ -339,7 +339,7 @@ class RandomWalk:
339
339
  self.benchmark_count = benchmark_count
340
340
  self._enrichment_seed_cell_min_count_ = 3
341
341
 
342
- self.is_gpu_available = check_gpu_availability(False)
342
+ self.is_gpu_available = check_gpu_availability()
343
343
 
344
344
  if not is_simple and self.is_ablation:
345
345
  if "cell_mutual_knn" not in cc_adata.layers:
sciv/util/_core_.py CHANGED
@@ -466,7 +466,7 @@ def add_cluster_info(data: DataFrame, data_ref: DataFrame, cluster: str) -> Data
466
466
  return new_data
467
467
 
468
468
 
469
- def check_gpu_availability(verbose: bool = True) -> bool:
469
+ def check_gpu_availability(verbose: bool = False) -> bool:
470
470
  available = torch.cuda.is_available()
471
471
 
472
472
  if verbose:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sciv
3
- Version: 0.0.105
3
+ Version: 0.0.107
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>
@@ -24,16 +24,16 @@ sciv/preprocessing/_anndata_.py,sha256=3d1cHFs1YA9UZkIPE089nZHFi-DjK-c1fRyi2shfS
24
24
  sciv/preprocessing/_gencode_.py,sha256=HKhRgK76khGepdv4FaKiOvTys1uJTbvIyrKUta5W0K8,2108
25
25
  sciv/preprocessing/_gsea_.py,sha256=AH_PpUNfMN7WkF0pqAuUhEC6qZwKrtQm6VaaYu6JLfI,3803
26
26
  sciv/preprocessing/_scanpy_.py,sha256=95kt6ylfqKmjLr8GZ1XH1khP9Q3uBYy4vqc4_2Zf1J4,11629
27
- sciv/preprocessing/_scvi_.py,sha256=vtMzaAuy3LZXPmg92MNJfFw5jIZv71_tZdpeEyl3JHc,10782
27
+ sciv/preprocessing/_scvi_.py,sha256=RfphdljTzA0sNuae44rKuP8YCOv5Cl23e6txCIXK_mI,11544
28
28
  sciv/preprocessing/_snapatac_.py,sha256=Dq8CHF7Psl3CQszaEokQYO56Oe2uzyWOy_cGlaOywfc,27798
29
29
  sciv/tool/__init__.py,sha256=WgyiWuCvBadTZfNEB70VurbN1YfpNodnVCIcAABTYEA,2512
30
- sciv/tool/_algorithm_.py,sha256=5H_LHGyRfx0ng9wm8pux0_dEXuJJJVdnGLM9MjD12Fo,53682
30
+ sciv/tool/_algorithm_.py,sha256=pQuCI7Jxdnd6KxenFNIx6iVHR2_UK04oyDleP5aOuPU,53690
31
31
  sciv/tool/_matrix_.py,sha256=SnC3sXic_ufuEXStcD_HncvYH6apBdNK6nhG6jFLmjA,24324
32
- sciv/tool/_random_walk_.py,sha256=2DPBRtd4A2MadfYDhkTw33WOATriiCULozNsUPE6lsY,48912
32
+ sciv/tool/_random_walk_.py,sha256=M73RmnP-CZAiIxMl5YfkP6wkH2xQ10dCkjfwsJTKrBQ,48889
33
33
  sciv/util/__init__.py,sha256=nER-hRRaBGl3CGgl2rLZAUOQ3uY6-m9wQ9VNrjO5EFE,2014
34
34
  sciv/util/_constant_.py,sha256=w0wKQd8guLd1ZTW24_5aECrWsIWDiNQmEpLsWlHar1A,3000
35
- sciv/util/_core_.py,sha256=3sWLYFdGln-HQzM3BY4iYHjVjuiZaR4P4jOvZlXXrAY,16766
36
- sciv-0.0.105.dist-info/METADATA,sha256=I_-ayhIMfZyJxrBvwk9zLtYR5OsXXYLvWCJjJ3luBDU,3495
37
- sciv-0.0.105.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
38
- sciv-0.0.105.dist-info/licenses/LICENSE,sha256=4UvHVf3qCOZjHLs4LkYz8u96XRpXnZrpTKrkUQPs5_A,1075
39
- sciv-0.0.105.dist-info/RECORD,,
35
+ sciv/util/_core_.py,sha256=00v5MrSqZxLnJvbfijD7DuR7innW_R0J6CAwivAsNNs,16767
36
+ sciv-0.0.107.dist-info/METADATA,sha256=COiUTIK3Dd14FAZBJWZDwnDQPQ0JSsXZ5I_3k9x2fC8,3495
37
+ sciv-0.0.107.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
38
+ sciv-0.0.107.dist-info/licenses/LICENSE,sha256=4UvHVf3qCOZjHLs4LkYz8u96XRpXnZrpTKrkUQPs5_A,1075
39
+ sciv-0.0.107.dist-info/RECORD,,
File without changes