SURE-tools 2.0.1__py3-none-any.whl → 2.0.3__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/__init__.py CHANGED
@@ -4,7 +4,7 @@ from .SURE2 import SURE2
4
4
  from . import utils
5
5
  from . import codebook
6
6
  from . import SURE
7
- from . import SURE2
8
7
  from . import atac
8
+ from . import flow
9
9
 
10
- __all__ = ['SURE','SURE2', 'atac', 'utils', 'codebook']
10
+ __all__ = ['SURE', 'flow', 'atac', 'utils', 'codebook']
SURE/flow/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .quiver import plot_quiver
SURE/flow/quiver.py ADDED
@@ -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_high_dim(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.1
3
+ Version: 2.0.3
4
4
  Summary: Succinct Representation of Single Cells
5
5
  Home-page: https://github.com/ZengFLab/SURE
6
6
  Author: Feng Zeng
@@ -1,6 +1,6 @@
1
1
  SURE/SURE.py,sha256=-k8CDneh7Ube3ECdpbHCfj4r4HViVyWoW0OMqvtWdgQ,50517
2
2
  SURE/SURE2.py,sha256=8wlnMwb1xuf9QUksNkWdWx5ZWq-xIy9NLx8RdUnE82o,48501
3
- SURE/__init__.py,sha256=koEpBjG-Q6EaDAfs6qENhAdCuwk4RQMqYahPKTvbBf8,207
3
+ SURE/__init__.py,sha256=mxdLoWa2fPEM4-WkJetMfcecpzqJ8YsM4lOoKHSLTrU,207
4
4
  SURE/assembly/__init__.py,sha256=jxZLURXKPzXe21LhrZ09LgZr33iqdjlQy4oSEj5gR2Q,172
5
5
  SURE/assembly/assembly.py,sha256=6IMdelPOiRO4mUb4dC7gVCoF1Uvfw86-Map8P_jnUag,21477
6
6
  SURE/assembly/atlas.py,sha256=ALjmVWutm_tOHTcT1aqOxmuCEQw-XzrtDoMCV_8oXLk,21794
@@ -8,13 +8,15 @@ 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
12
+ SURE/flow/quiver.py,sha256=_euFqSaRrDoZ_oOabOx20LOoUTJ__XPhLW-vzLNQfAo,1859
11
13
  SURE/utils/__init__.py,sha256=Htqv4KqVKcRiaaTBsR-6yZ4LSlbhbzutjNKXGD9-uds,660
12
14
  SURE/utils/custom_mlp.py,sha256=07TYX1HgxfEjb_3i5MpiZfNhOhx3dKntuwGkrpteWiM,7036
13
15
  SURE/utils/queue.py,sha256=E_5PA5EWcBoGAZj8BkKQnkCK0p4C-4-xcTPqdIXaPXU,1892
14
16
  SURE/utils/utils.py,sha256=IUHjDDtYaAYllCWsZyIzqQwaLul6fJRvHRH4vIYcR-c,8462
15
- sure_tools-2.0.1.dist-info/licenses/LICENSE,sha256=TFHKwmrAViXQbSX5W-NDItkWFjm45HWOeUniDrqmnu0,1065
16
- sure_tools-2.0.1.dist-info/METADATA,sha256=sof2UfdK8bT5YxySj9jZPSSQN5aAlLXeK954dYNnVtM,2650
17
- sure_tools-2.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- sure_tools-2.0.1.dist-info/entry_points.txt,sha256=u12payZYgCBy5FCwRHP6AlSQhKCiWSEDwj68r1DVdn8,40
19
- sure_tools-2.0.1.dist-info/top_level.txt,sha256=BtFTebdiJeqra4r6mm-uEtwVRFLZ_IjYsQ7OnalrOvY,5
20
- sure_tools-2.0.1.dist-info/RECORD,,
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,,