SURE-tools 2.0.3__py3-none-any.whl → 2.0.5__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.

Potentially problematic release.


This version of SURE-tools might be problematic. Click here for more details.

SURE/SURE.py CHANGED
@@ -237,7 +237,7 @@ class SURE(nn.Module):
237
237
  self.cell_factor_effect = nn.ModuleList()
238
238
  for i in np.arange(self.cell_factor_size):
239
239
  self.cell_factor_effect.append(MLP(
240
- [self.z_dim+1] + hidden_sizes + [self.z_dim],
240
+ [self.latent_dim+1] + hidden_sizes + [self.latent_dim],
241
241
  activation=activate_fct,
242
242
  output_activation=None,
243
243
  post_layer_fct=post_layer_fct,
SURE/flow/__init__.py CHANGED
@@ -1 +1 @@
1
- from .quiver import plot_quiver
1
+ from .plot_quiver import plot_quiver
@@ -0,0 +1,52 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ from sklearn.decomposition import PCA
4
+ import scanpy as sc
5
+
6
+ def plot_quiver(z_points, delta_z, method='umap', figsize=(6,4), dpi=200):
7
+ """
8
+ 从高维潜在空间选择2个维度进行quiver可视化
9
+ """
10
+ if method == 'variance':
11
+ # 方法1: 选择方差最大的2个维度
12
+ variances = np.var(z_points, axis=0)
13
+ dims = np.argsort(variances)[-2:] # 选择方差最大的两个维度
14
+ dim_names = [f'z[{d}]' for d in dims]
15
+
16
+ elif method == 'pca':
17
+ # 方法2: 使用PCA的前两个主成分
18
+ pca = PCA(n_components=2)
19
+ z_2d = pca.fit_transform(z_points)
20
+ delta_z_2d = pca.transform(z_points + delta_z) - z_2d
21
+ dim_names = ['PC1', 'PC2']
22
+
23
+ elif method == 'manual':
24
+ # 方法3: 手动选择感兴趣的维度
25
+ dims = [0, 1] # 选择前两个维度
26
+ z_2d = z_points[:, dims]
27
+ delta_z_2d = delta_z[:, dims]
28
+ dim_names = [f'z[{d}]' for d in dims]
29
+
30
+ elif method == 'umap':
31
+ ad = sc.AnnData(np.vstack([z_points, z_points+delta_z]))
32
+ sc.pp.neighbors(ad)
33
+ sc.tl.umap(ad)
34
+ z_2d = ad[:z_points.shape[0]].obsm['X_umap']
35
+ delta_z_2d = ad[z_points.shape[0]:] - z_2d
36
+ dim_names = ['UMAP1', 'UMAP2']
37
+
38
+ # 绘制quiver图
39
+ plt.figure(figsize=figsize, dpi=dpi)
40
+ plt.quiver(z_2d[:, 0], z_2d[:, 1],
41
+ delta_z_2d[:, 0], delta_z_2d[:, 1],
42
+ angles='xy', scale_units='xy', scale=1,
43
+ color='blue', alpha=0.6, width=0.005)
44
+
45
+ plt.scatter(z_2d[:, 0], z_2d[:, 1], c='gray', alpha=0.5, s=10)
46
+ plt.xlabel(dim_names[0])
47
+ plt.ylabel(dim_names[1])
48
+ plt.title(f"Latent Space Movement ({method} projection)")
49
+ plt.grid(alpha=0.3)
50
+ plt.show()
51
+
52
+ return z_2d, delta_z_2d
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SURE-tools
3
- Version: 2.0.3
3
+ Version: 2.0.5
4
4
  Summary: Succinct Representation of Single Cells
5
5
  Home-page: https://github.com/ZengFLab/SURE
6
6
  Author: Feng Zeng
@@ -1,4 +1,4 @@
1
- SURE/SURE.py,sha256=-k8CDneh7Ube3ECdpbHCfj4r4HViVyWoW0OMqvtWdgQ,50517
1
+ SURE/SURE.py,sha256=0brySH3zXtYAW8eff5BzL1vYq_nmR82wpEPeH-FcLE8,50527
2
2
  SURE/SURE2.py,sha256=8wlnMwb1xuf9QUksNkWdWx5ZWq-xIy9NLx8RdUnE82o,48501
3
3
  SURE/__init__.py,sha256=mxdLoWa2fPEM4-WkJetMfcecpzqJ8YsM4lOoKHSLTrU,207
4
4
  SURE/assembly/__init__.py,sha256=jxZLURXKPzXe21LhrZ09LgZr33iqdjlQy4oSEj5gR2Q,172
@@ -8,15 +8,16 @@ SURE/atac/__init__.py,sha256=3smP8IKHfwNCd1G_sZH3pKHXuLkLpFuLtjUTUSy7_As,34
8
8
  SURE/atac/utils.py,sha256=m4NYwpy9O5T1pXTzgCOCcmlwrC6GTi-cQ5sm2wZu2O8,4354
9
9
  SURE/codebook/__init__.py,sha256=2T5gjp8JIaBayrXAnOJYSebQHsWprOs87difpR1OPNw,243
10
10
  SURE/codebook/codebook.py,sha256=ZlN6gRX9Gj2D2u3P5KeOsbZri0MoMAiJo9lNeL-MK-I,17117
11
- SURE/flow/__init__.py,sha256=sizOyGqsjF2nfeBdwaiqXYkk8VP489F1z3Le5UF36qI,31
11
+ SURE/flow/__init__.py,sha256=uiF9eyo6sz5qw7fRFiKipaXHboAakeIqVWo8yjkq0B0,36
12
+ SURE/flow/plot_quiver.py,sha256=XRH1POyn2H7qJ_gSqo39YmjOR_Dn8a_9M_s-dnHJLlo,1850
12
13
  SURE/flow/quiver.py,sha256=_euFqSaRrDoZ_oOabOx20LOoUTJ__XPhLW-vzLNQfAo,1859
13
14
  SURE/utils/__init__.py,sha256=Htqv4KqVKcRiaaTBsR-6yZ4LSlbhbzutjNKXGD9-uds,660
14
15
  SURE/utils/custom_mlp.py,sha256=07TYX1HgxfEjb_3i5MpiZfNhOhx3dKntuwGkrpteWiM,7036
15
16
  SURE/utils/queue.py,sha256=E_5PA5EWcBoGAZj8BkKQnkCK0p4C-4-xcTPqdIXaPXU,1892
16
17
  SURE/utils/utils.py,sha256=IUHjDDtYaAYllCWsZyIzqQwaLul6fJRvHRH4vIYcR-c,8462
17
- sure_tools-2.0.3.dist-info/licenses/LICENSE,sha256=TFHKwmrAViXQbSX5W-NDItkWFjm45HWOeUniDrqmnu0,1065
18
- sure_tools-2.0.3.dist-info/METADATA,sha256=hALj9H3TDK0LM5acM-pBsLgffddHuzI36AiVQssh1mc,2650
19
- sure_tools-2.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- sure_tools-2.0.3.dist-info/entry_points.txt,sha256=u12payZYgCBy5FCwRHP6AlSQhKCiWSEDwj68r1DVdn8,40
21
- sure_tools-2.0.3.dist-info/top_level.txt,sha256=BtFTebdiJeqra4r6mm-uEtwVRFLZ_IjYsQ7OnalrOvY,5
22
- sure_tools-2.0.3.dist-info/RECORD,,
18
+ sure_tools-2.0.5.dist-info/licenses/LICENSE,sha256=TFHKwmrAViXQbSX5W-NDItkWFjm45HWOeUniDrqmnu0,1065
19
+ sure_tools-2.0.5.dist-info/METADATA,sha256=DSDQeffAyyRgBfKxdWTsk7DBd71C3zGdnMlKY4bz1_g,2650
20
+ sure_tools-2.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
+ sure_tools-2.0.5.dist-info/entry_points.txt,sha256=u12payZYgCBy5FCwRHP6AlSQhKCiWSEDwj68r1DVdn8,40
22
+ sure_tools-2.0.5.dist-info/top_level.txt,sha256=BtFTebdiJeqra4r6mm-uEtwVRFLZ_IjYsQ7OnalrOvY,5
23
+ sure_tools-2.0.5.dist-info/RECORD,,