sciv 0.0.99__py3-none-any.whl → 0.0.101__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/plot/_bar_.py CHANGED
@@ -76,6 +76,7 @@ def two_bar(
76
76
  bottom: float = 0,
77
77
  rotation: float = 65,
78
78
  text_left_move: float = 0.15,
79
+ y_limit: Tuple[float, float] = (0, 1),
79
80
  title: str = None,
80
81
  output: path = None,
81
82
  show: bool = True,
@@ -91,6 +92,9 @@ def two_bar(
91
92
 
92
93
  ax.legend()
93
94
 
95
+ ax.set_ylim(y_limit)
96
+
97
+ ax.set_xticks(range(len(ax_x)))
94
98
  ax.set_xticklabels(labels=list(ax_x), rotation=rotation)
95
99
 
96
100
  # Draw numerical values
@@ -103,6 +107,13 @@ def two_bar(
103
107
  color=text_color
104
108
  )
105
109
 
110
+ for spine in ["top", "left", "right", "bottom"]:
111
+ ax.spines[spine].set_linewidth(1)
112
+
113
+ ax.spines['bottom'].set_linewidth(1)
114
+ ax.grid(axis='y', ls='--', c='gray')
115
+ ax.set_axisbelow(True)
116
+
106
117
  plot_end(fig, title, x_name, y_name, output, show, close)
107
118
 
108
119
 
@@ -123,6 +134,7 @@ def class_bar(
123
134
  rotation: float = 65,
124
135
  title: str = None,
125
136
  text_left_move: float = 0.15,
137
+ y_limit: Tuple[float, float] = (0, 1),
126
138
  output: path = None,
127
139
  show: bool = True,
128
140
  close: bool = False,
@@ -159,6 +171,7 @@ def class_bar(
159
171
  bottom=bottom,
160
172
  rotation=rotation,
161
173
  text_left_move=text_left_move,
174
+ y_limit=y_limit,
162
175
  title=title,
163
176
  output=output,
164
177
  show=show,
@@ -185,6 +198,7 @@ def bar_trait(
185
198
  rotation: float = 65,
186
199
  title: str = None,
187
200
  text_left_move: float = 0.15,
201
+ y_limit: Tuple[float, float] = (0, 1),
188
202
  output: path = None,
189
203
  show: bool = True,
190
204
  close: bool = False,
@@ -216,6 +230,7 @@ def bar_trait(
216
230
  bottom=bottom,
217
231
  rotation=rotation,
218
232
  text_left_move=text_left_move,
233
+ y_limit=y_limit,
219
234
  text_color=text_color,
220
235
  output=os.path.join(output, f"cell_{trait_}_enrichment_bar.pdf") if output is not None else None,
221
236
  show=show,
@@ -224,6 +239,7 @@ def bar_trait(
224
239
  )
225
240
 
226
241
  trait_list = list(set(trait_df[trait_column_name]))
242
+
227
243
  # judge trait
228
244
  if trait_name != "All" and trait_name not in trait_list:
229
245
  ul.log(__name__).error(
@@ -237,8 +253,10 @@ def bar_trait(
237
253
 
238
254
  # plot
239
255
  if trait_name == "All":
256
+
240
257
  for trait in trait_list:
241
258
  trait_plot(trait_=trait, cell_df_=trait_df)
259
+
242
260
  else:
243
261
  trait_plot(trait_name, trait_df)
244
262
 
@@ -376,10 +394,9 @@ def bar_significance(
376
394
  y=y,
377
395
  hue=legend,
378
396
  hue_order=hue_order,
379
- ci=ci,
397
+ errorbar=('ci', ci),
380
398
  capsize=capsize,
381
- errwidth=line_width,
382
- errcolor=errcolor,
399
+ err_kws={'color': errcolor, 'linewidth': line_width},
383
400
  ax=ax,
384
401
  palette=palette,
385
402
  edgecolor=errcolor,
@@ -437,7 +454,7 @@ def bar_significance(
437
454
  ax.set_axisbelow(True)
438
455
 
439
456
  if x_rotation != 0:
440
- ax.set_xticklabels(labels=ax.get_xticklabels(), rotation=x_rotation)
457
+ ax.tick_params(axis='x', rotation=x_rotation)
441
458
 
442
459
  plt.legend(loc='upper left', bbox_to_anchor=(0.0, legend_gap), ncol=2)
443
460
 
sciv/plot/_box_.py CHANGED
@@ -52,7 +52,6 @@ def box_base(
52
52
 
53
53
  if "color" in df_columns:
54
54
  new_df_color: DataFrame = df.groupby(group_columns, as_index=False)["color"].first()
55
-
56
55
  new_df = new_df.merge(new_df_color, how="left", on=clusters)
57
56
 
58
57
  colors: list = []
@@ -61,22 +60,31 @@ def box_base(
61
60
  if is_sort:
62
61
  new_df.sort_values([value], ascending=False, inplace=True)
63
62
  y_names: Union[list, None] = list(new_df[clusters])
63
+
64
64
  if "color" in df_columns:
65
- colors = new_df["color"]
65
+ colors = list(new_df["color"])
66
+
66
67
  else:
67
68
  new_df.index = new_df[clusters]
69
+
68
70
  if order_names is not None:
69
71
  y_names: list = order_names
72
+
70
73
  if "color" in df_columns:
74
+
71
75
  for i in order_names:
76
+
72
77
  for j, c in zip(new_df[clusters], new_df["color"]):
78
+
73
79
  if i == j:
74
80
  colors.append(c)
75
81
  break
82
+
76
83
  else:
77
84
  y_names = new_df[clusters]
85
+
78
86
  if "color" in df_columns:
79
- colors = new_df["color"]
87
+ colors = list(new_df["color"])
80
88
 
81
89
  # scatter
82
90
  sns.boxplot(
@@ -103,6 +111,7 @@ def box_base(
103
111
  line.set_linewidth(line_width)
104
112
 
105
113
  # set coordinate
114
+ ax.set_xticks(range(len(y_names)))
106
115
  ax.set_xticklabels(labels=y_names, rotation=rotation)
107
116
  ax.spines['top'].set_linewidth(line_width)
108
117
  ax.spines['bottom'].set_linewidth(line_width)
sciv/plot/_core_.py CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: UTF-8 -*-
2
2
 
3
3
  import os
4
- from typing import Tuple, Literal, Optional, Union
4
+ from typing import Tuple, Literal, Optional, Union, Any
5
5
 
6
6
  import pandas as pd
7
7
  from anndata import AnnData
@@ -314,9 +314,11 @@ def rate_bar_plot(
314
314
  rotation: float = 65,
315
315
  title: str = None,
316
316
  text_left_move: float = 0.15,
317
+ y_limit: Tuple[float, float] = (0, 1),
317
318
  plot_output: path = None,
318
319
  show: bool = True,
319
- close: bool = False
320
+ close: bool = False,
321
+ **kwargs: Any
320
322
  ) -> None:
321
323
 
322
324
  if dir_name is not None:
@@ -349,9 +351,11 @@ def rate_bar_plot(
349
351
  bottom=bottom,
350
352
  rotation=rotation,
351
353
  text_left_move=text_left_move,
354
+ y_limit=y_limit,
352
355
  output=new_path if plot_output is not None else None,
353
356
  show=show,
354
- close=close
357
+ close=close,
358
+ **kwargs
355
359
  )
356
360
 
357
361
 
sciv/plot/_graph_.py CHANGED
@@ -143,8 +143,10 @@ def communities_graph(
143
143
  partition: list = [0 for _ in range(g.number_of_nodes())]
144
144
 
145
145
  for c_i, nodes in enumerate(communities):
146
+
146
147
  for i in nodes:
147
148
  partition[i] = type_colors[start_color_index + color_index * color_step_size + c_i]
149
+
148
150
  color_index += 1
149
151
 
150
152
  pos = nx.spring_layout(g)
sciv/plot/_kde_.py CHANGED
@@ -42,7 +42,7 @@ def kde(
42
42
  # Random sampling
43
43
  if axis == -1:
44
44
  matrix = down_sampling_data(data.X, sample_number)
45
- sns.kdeplot(matrix, shade=True, fill=True)
45
+ sns.kdeplot(matrix, fill=True)
46
46
  elif axis == 0:
47
47
  col_number = data.shape[1]
48
48
  if data.shape[0] * data.shape[1] > sample_number:
@@ -50,10 +50,10 @@ def kde(
50
50
 
51
51
  for i in tqdm(range(col_number)):
52
52
  _vector_ = down_sampling_data(data.X[:, i], row_number)
53
- sns.kdeplot(np.array(_vector_).flatten(), shade=True, fill=True, **kwargs)
53
+ sns.kdeplot(np.array(_vector_).flatten(), fill=True, **kwargs)
54
54
  else:
55
55
  for i in tqdm(range(col_number)):
56
- sns.kdeplot(np.array(data.X[:, i]).flatten(), shade=True, fill=True, **kwargs)
56
+ sns.kdeplot(np.array(data.X[:, i]).flatten(), fill=True, **kwargs)
57
57
 
58
58
  if is_legend:
59
59
  ax.legend(list(adata.var.index))
@@ -65,10 +65,10 @@ def kde(
65
65
 
66
66
  for i in tqdm(range(row_number)):
67
67
  _vector_ = down_sampling_data(data.X[i, :], col_number)
68
- sns.kdeplot(np.array(_vector_).flatten(), shade=True, fill=True, **kwargs)
68
+ sns.kdeplot(np.array(_vector_).flatten(), fill=True, **kwargs)
69
69
  else:
70
70
  for i in tqdm(range(row_number)):
71
- sns.kdeplot(np.array(data.X[i, :]).flatten(), shade=True, fill=True, **kwargs)
71
+ sns.kdeplot(np.array(data.X[i, :]).flatten(), fill=True, **kwargs)
72
72
 
73
73
  if is_legend:
74
74
  ax.legend(list(adata.obs.index))
sciv/plot/_line_.py CHANGED
@@ -119,7 +119,7 @@ def stability_line(
119
119
  locator = mdates.DayLocator(interval=1)
120
120
  chart.xaxis.set_major_locator(locator)
121
121
 
122
- ax.set_xticklabels(ax.get_xticklabels(), rotation=x_name_rotation)
122
+ ax.tick_params(axis='x', rotation=x_name_rotation)
123
123
  else:
124
124
  plt.xticks(x_ticks, rotation=x_name_rotation)
125
125
 
sciv/plot/_violin_.py CHANGED
@@ -48,7 +48,8 @@ def violin_base(
48
48
 
49
49
  if hue is not None and hue not in df_columns:
50
50
  ul.log(__name__).error(
51
- f"The `hue` ({hue}) parameter must be in the `df` parameter data column name ({df_columns})")
51
+ f"The `hue` ({hue}) parameter must be in the `df` parameter data column name ({df_columns})"
52
+ )
52
53
  raise ValueError(f"The `hue` ({hue}) parameter must be in the `df` parameter data column name ({df_columns})")
53
54
 
54
55
  fig, ax = plot_start(width, height, bottom, output, show)
@@ -67,20 +68,29 @@ def violin_base(
67
68
  if is_sort:
68
69
  new_df.sort_values([value], ascending=False, inplace=True)
69
70
  y_names: Union[list, None] = list(new_df[clusters])
71
+
70
72
  if "color" in df_columns:
71
73
  colors = list(new_df["color"])
74
+
72
75
  else:
73
76
  new_df.index = new_df[clusters]
77
+
74
78
  if order_names is not None:
75
79
  y_names: list = order_names
80
+
76
81
  if "color" in df_columns:
82
+
77
83
  for i in order_names:
84
+
78
85
  for j, c in zip(new_df[clusters], new_df["color"]):
86
+
79
87
  if i == j:
80
88
  colors.append(c)
81
89
  break
90
+
82
91
  else:
83
92
  y_names = list(new_df[clusters])
93
+
84
94
  if "color" in df_columns:
85
95
  colors = list(new_df["color"])
86
96
 
sciv/tool/_algorithm_.py CHANGED
@@ -455,11 +455,11 @@ def semi_mutual_knn_weight(
455
455
  del data
456
456
  np.fill_diagonal(new_data, 0)
457
457
 
458
- def _knn_k_(_mat: matrix_data, k: int):
458
+ def _knn_k_(_mat: matrix_data, k: int, info: str = "LOG"):
459
459
  n_rows = _mat.shape[0]
460
460
  adj = sparse.lil_matrix((n_rows, n_rows), dtype=np.int8)
461
461
 
462
- ul.log(__name__).info("Calculate the k-nearest neighbors of each node.")
462
+ ul.log(__name__).info(f"Calculate the k-nearest neighbors of each node. ({info})")
463
463
 
464
464
  for i in tqdm(range(n_rows)):
465
465
  row = np.array(_mat[i]).ravel()
@@ -477,7 +477,7 @@ def semi_mutual_knn_weight(
477
477
 
478
478
  return adj.tocsr()
479
479
 
480
- def _knn(_mat: matrix_data, k: int) -> matrix_data:
480
+ def _knn(_mat: matrix_data, k: int, info: str = "LOG") -> matrix_data:
481
481
  """
482
482
  Return k-nearest-neighbor 0/1 adjacency matrix (int8 to save memory).
483
483
  Supports both sparse and dense inputs.
@@ -486,11 +486,11 @@ def semi_mutual_knn_weight(
486
486
  if sparse.issparse(_mat):
487
487
  # Sparse path: sort each row's data to find the k-th largest
488
488
  _mat = _mat.tocsr(copy=False)
489
- return _knn_k_(_mat, k)
489
+ return _knn_k_(_mat, k, info)
490
490
  else:
491
491
 
492
492
  if is_for:
493
- return _knn_k_(_mat, k)
493
+ return _knn_k_(_mat, k, info)
494
494
  else:
495
495
  # Dense path: vectorized thresholding
496
496
  kth_val = np.sort(_mat, axis=1)[:, -(k + 1)]
@@ -499,12 +499,12 @@ def semi_mutual_knn_weight(
499
499
  return adj
500
500
 
501
501
  # Compute adjacency matrices for AND/OR logic
502
- adj_and = _knn(new_data, neighbors)
502
+ adj_and = _knn(new_data, neighbors, "AND")
503
503
 
504
504
  if neighbors == or_neighbors:
505
505
  adj_or = adj_and
506
506
  else:
507
- adj_or = _knn(new_data, or_neighbors)
507
+ adj_or = _knn(new_data, or_neighbors, "OR")
508
508
 
509
509
  # Symmetrize
510
510
  if sparse.issparse(adj_and):
@@ -519,7 +519,12 @@ def semi_mutual_knn_weight(
519
519
 
520
520
  # Ensure full connectivity if required
521
521
  if is_mknn_fully_connected:
522
- adj_1nn = _knn(new_data, 1)
522
+ adj_1nn = _knn(new_data, 1, "ONE")
523
+
524
+ if sparse.issparse(adj_1nn):
525
+ adj_1nn = adj_1nn.maximum(adj_1nn.T)
526
+ else:
527
+ adj_1nn = np.maximum(adj_1nn, adj_1nn.T)
523
528
 
524
529
  if sparse.issparse(adj_and):
525
530
  adj_and = adj_and.maximum(adj_1nn)
@@ -280,7 +280,7 @@ class RandomWalk:
280
280
  to `False`, `is_ablation` will only take effect;
281
281
  :return: Stable distribution score.
282
282
  """
283
- ul.log(__name__).info("Random walk.")
283
+ ul.log(__name__).info("Random walk with weighted seed cells.")
284
284
 
285
285
  start_time = time.time()
286
286
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sciv
3
- Version: 0.0.99
3
+ Version: 0.0.101
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>
@@ -5,20 +5,20 @@ sciv/file/_write_.py,sha256=W3M9CmPi7BuKAffz1fdi-vA5DzAFZ7wmcggp33N9Xtg,7848
5
5
  sciv/model/__init__.py,sha256=k8SO9FpJaGn2ANqJyaz3HXMas7jH9toPVtpw703kOqg,149
6
6
  sciv/model/_core_.py,sha256=K4X1kGCdFW_5zxwMtACfjKeg_X34eYSPcSl5F2hMX_8,33690
7
7
  sciv/plot/__init__.py,sha256=2tRNT6TZNz9r38lnna712RGsH7OJ2QkGa37XKgzejHQ,1865
8
- sciv/plot/_bar_.py,sha256=xWpFbJTHgQMLuUSXa4uE69RGHXSCGinapxL-1imdDcU,14355
8
+ sciv/plot/_bar_.py,sha256=iQoFsFFbPbFj3JX2BgG45dqG-hjOka90LDw0WfdYNY8,14823
9
9
  sciv/plot/_barcode_.py,sha256=RDOedQ8ZtXWFyJ2c772RDfqO4TMIpHMvcMZMAVqky90,5073
10
- sciv/plot/_box_.py,sha256=485YNmSBj2IB7JlRHaKHMVj0yr0Pz02B3-r57SJqtMk,6009
10
+ sciv/plot/_box_.py,sha256=I_F6imlAEZNSM4ztdtFZnq5JSZpsDgITACKJ45R6M9g,6077
11
11
  sciv/plot/_bubble_.py,sha256=vwBs-voOdkBfyMho5w4Rt68b8_Dw1C3NClLdauonC4U,1066
12
- sciv/plot/_core_.py,sha256=kM3Ym0sZYl0AsfndJ6m9hOlvoMYvii-e8ukcF_USXiA,22222
13
- sciv/plot/_graph_.py,sha256=h5sI7p4Y1YKplR9e-bfKrvtaWN_LB0SoIndqH-2qZ7I,12613
12
+ sciv/plot/_core_.py,sha256=9MRGhgcA4x1Gky2LFNFNu7ggBsCgVxt0fHceHPuL-Pw,22336
13
+ sciv/plot/_graph_.py,sha256=-AasDYbFnRbWS4eTPDcZ4fzySqrLihUqiY_EBixrQUs,12617
14
14
  sciv/plot/_heat_map_.py,sha256=pne4DSydBg0sc4KT88N5A_7QkDnvvmGUwyqZ7-WWtcM,14896
15
- sciv/plot/_kde_.py,sha256=9VC6DKHbQAzKenz4DoiL5LgUzEJBtAWXXPCLxOV74kY,2459
16
- sciv/plot/_line_.py,sha256=P944YoGxSocHncjtme4n_iIPK9sghNW3-Xee6Tyy4HE,3850
15
+ sciv/plot/_kde_.py,sha256=A7_NFoSD0ih9h0Hh_1Y8ZOOz06AyANfi3M6sdkz61ZE,2399
16
+ sciv/plot/_line_.py,sha256=qOSf4MJSXCTh8WCcd_dFlTsqMp-MeR2fGqR9lzEVPwo,3834
17
17
  sciv/plot/_pie_.py,sha256=OVPv85MdjkjABh-uP5Y-KVk1VygFIzz87QT3OE1hZjU,6399
18
18
  sciv/plot/_radar_.py,sha256=g_abzmzibJIR6it59TendUI236inbzYl0IzzdoA3Uuc,6304
19
19
  sciv/plot/_scatter_.py,sha256=HPy1eFqDk4vksAiKjn_Qk00fYO4GyqRs1O3ZZh44Ezw,16998
20
20
  sciv/plot/_venn_.py,sha256=TfNTuxog2pT7sicKBEEMtleoHXwnenbl3CMWJu9c2vs,2675
21
- sciv/plot/_violin_.py,sha256=40LYeHFYyNL1XbKHTjmwLT0zzh7o5emqN9Gl2sbl-DA,6458
21
+ sciv/plot/_violin_.py,sha256=IoeAv-ipGkBO0LouI2Y2huPP44u_-6O9CfBkgrPsK6s,6486
22
22
  sciv/preprocessing/__init__.py,sha256=56RgDai5I3sZ4hl3aaV80ogOeUscYsU3nJUWE80jZ-k,742
23
23
  sciv/preprocessing/_anndata_.py,sha256=3d1cHFs1YA9UZkIPE089nZHFi-DjK-c1fRyi2shfSh4,6302
24
24
  sciv/preprocessing/_gencode_.py,sha256=HKhRgK76khGepdv4FaKiOvTys1uJTbvIyrKUta5W0K8,2108
@@ -27,13 +27,13 @@ sciv/preprocessing/_scanpy_.py,sha256=tB8BD2wpLAU8_YxdqrgNtcjpNXNRo-JCdm2lxaKDBL
27
27
  sciv/preprocessing/_scvi_.py,sha256=7QxwPA2kR_g15X28aEak7AFA4kyQ-UbtpiLH-rc5Ksg,10780
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=mYKfSuYGelLd2secwyqGPxBQYd3x2yDKw1z7HK8mqYE,53773
30
+ sciv/tool/_algorithm_.py,sha256=82ATnZ9-6Cxl6UV9n6jzQawTt7s53crl0hLuZiW-JZ0,54012
31
31
  sciv/tool/_matrix_.py,sha256=SnC3sXic_ufuEXStcD_HncvYH6apBdNK6nhG6jFLmjA,24324
32
- sciv/tool/_random_walk_.py,sha256=JOB97XLxlZYHvlIST1wlXgA0mw6fybkWnJGq6X_kbsk,48871
32
+ sciv/tool/_random_walk_.py,sha256=L7bpYDVNwGSpeB5ipDw81Y6KCJoAjTx1Cs9o4JWZej8,48896
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=TUWfBNRJzWuoQ9ffew_DjnlkNydG-Rmujl_RH4Ln9io,14917
36
- sciv-0.0.99.dist-info/METADATA,sha256=mObiKCwRCM2mfoao7bZZF-4D_AfqDbClUAaZ0XEc-DI,3465
37
- sciv-0.0.99.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
38
- sciv-0.0.99.dist-info/licenses/LICENSE,sha256=4UvHVf3qCOZjHLs4LkYz8u96XRpXnZrpTKrkUQPs5_A,1075
39
- sciv-0.0.99.dist-info/RECORD,,
36
+ sciv-0.0.101.dist-info/METADATA,sha256=AHOc-TQXHovRT5hgIsJ0tSRLdd6L5-axMiiKYF3_NGU,3466
37
+ sciv-0.0.101.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
38
+ sciv-0.0.101.dist-info/licenses/LICENSE,sha256=4UvHVf3qCOZjHLs4LkYz8u96XRpXnZrpTKrkUQPs5_A,1075
39
+ sciv-0.0.101.dist-info/RECORD,,
File without changes