SURE-tools 2.1.1__tar.gz → 2.1.2__tar.gz

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.

Files changed (29) hide show
  1. {sure_tools-2.1.1 → sure_tools-2.1.2}/PKG-INFO +1 -1
  2. sure_tools-2.1.2/SURE/flow/__init__.py +2 -0
  3. sure_tools-2.1.2/SURE/flow/flow_stats.py +78 -0
  4. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE_tools.egg-info/PKG-INFO +1 -1
  5. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE_tools.egg-info/SOURCES.txt +1 -0
  6. {sure_tools-2.1.1 → sure_tools-2.1.2}/setup.py +1 -1
  7. sure_tools-2.1.1/SURE/flow/__init__.py +0 -1
  8. {sure_tools-2.1.1 → sure_tools-2.1.2}/LICENSE +0 -0
  9. {sure_tools-2.1.1 → sure_tools-2.1.2}/README.md +0 -0
  10. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/PerturbFlow.py +0 -0
  11. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/SURE.py +0 -0
  12. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/__init__.py +0 -0
  13. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/assembly/__init__.py +0 -0
  14. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/assembly/assembly.py +0 -0
  15. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/assembly/atlas.py +0 -0
  16. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/atac/__init__.py +0 -0
  17. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/atac/utils.py +0 -0
  18. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/codebook/__init__.py +0 -0
  19. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/codebook/codebook.py +0 -0
  20. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/flow/plot_quiver.py +0 -0
  21. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/utils/__init__.py +0 -0
  22. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/utils/custom_mlp.py +0 -0
  23. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/utils/queue.py +0 -0
  24. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE/utils/utils.py +0 -0
  25. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE_tools.egg-info/dependency_links.txt +0 -0
  26. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE_tools.egg-info/entry_points.txt +0 -0
  27. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE_tools.egg-info/requires.txt +0 -0
  28. {sure_tools-2.1.1 → sure_tools-2.1.2}/SURE_tools.egg-info/top_level.txt +0 -0
  29. {sure_tools-2.1.1 → sure_tools-2.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SURE-tools
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: Succinct Representation of Single Cells
5
5
  Home-page: https://github.com/ZengFLab/SURE
6
6
  Author: Feng Zeng
@@ -0,0 +1,2 @@
1
+ from .plot_quiver import plot_quiver
2
+ from .flow_stats import calculate_direction_stats,calculate_movement_stats,calculate_movement_energy,calculate_movement_divergence
@@ -0,0 +1,78 @@
1
+ import numpy as np
2
+ from scipy.spatial.distance import pdist, squareform
3
+
4
+ def calculate_movement_stats(vectors):
5
+ """
6
+ 计算移动矢量的基本统计量
7
+ """
8
+ # 计算每个矢量的模长(移动距离)
9
+ distances = np.linalg.norm(vectors, axis=1)
10
+
11
+ stats = {
12
+ 'total_movement': np.sum(distances),
13
+ 'mean_distance': np.mean(distances),
14
+ 'median_distance': np.median(distances),
15
+ 'std_distance': np.std(distances),
16
+ 'max_distance': np.max(distances),
17
+ 'min_distance': np.min(distances),
18
+ 'total_points': len(vectors)
19
+ }
20
+
21
+ return stats, distances
22
+
23
+ def calculate_direction_stats(vectors):
24
+ """
25
+ 计算移动方向的一致性
26
+ """
27
+ # 单位向量
28
+ unit_vectors = vectors / np.linalg.norm(vectors, axis=1, keepdims=True)
29
+
30
+ # 平均方向向量
31
+ mean_direction = np.mean(unit_vectors, axis=0)
32
+ mean_direction_norm = np.linalg.norm(mean_direction)
33
+
34
+ # 方向一致性(0-1,1表示完全一致)
35
+ direction_consistency = mean_direction_norm
36
+
37
+ return {
38
+ 'direction_consistency': direction_consistency,
39
+ 'mean_direction': mean_direction,
40
+ 'direction_variance': 1 - direction_consistency # 方向分散度
41
+ }
42
+
43
+ def calculate_movement_energy(vectors, masses=None):
44
+ """
45
+ 计算移动的能量(假设每个点有质量)
46
+ """
47
+ if masses is None:
48
+ masses = np.ones(len(vectors)) # 默认单位质量
49
+
50
+ # 动能 = 0.5 * mass * velocity^2
51
+ speeds_squared = np.sum(vectors**2, axis=1)
52
+ kinetic_energy = 0.5 * masses * speeds_squared
53
+
54
+ return {
55
+ 'total_energy': np.sum(kinetic_energy),
56
+ 'mean_energy': np.mean(kinetic_energy),
57
+ 'energy_std': np.std(kinetic_energy)
58
+ }
59
+
60
+ def calculate_movement_divergence(positions, vectors):
61
+ """
62
+ 计算移动的散度(衡量扩张/收缩)
63
+ """
64
+
65
+ # 计算移动前后的位置
66
+ new_positions = positions + vectors
67
+
68
+ # 计算位置变化的协方差
69
+ orig_cov = np.cov(positions.T)
70
+ new_cov = np.cov(new_positions.T)
71
+
72
+ # 体积变化(行列式比值)
73
+ volume_ratio = np.linalg.det(new_cov) / np.linalg.det(orig_cov)
74
+
75
+ return {
76
+ 'volume_expansion': volume_ratio, # >1扩张, <1收缩
77
+ 'expansion_factor': volume_ratio**(1/positions.shape[1])
78
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SURE-tools
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: Succinct Representation of Single Cells
5
5
  Home-page: https://github.com/ZengFLab/SURE
6
6
  Author: Feng Zeng
@@ -12,6 +12,7 @@ SURE/atac/utils.py
12
12
  SURE/codebook/__init__.py
13
13
  SURE/codebook/codebook.py
14
14
  SURE/flow/__init__.py
15
+ SURE/flow/flow_stats.py
15
16
  SURE/flow/plot_quiver.py
16
17
  SURE/utils/__init__.py
17
18
  SURE/utils/custom_mlp.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name='SURE-tools',
8
- version='2.1.1',
8
+ version='2.1.2',
9
9
  description='Succinct Representation of Single Cells',
10
10
  long_description=long_description,
11
11
  long_description_content_type="text/markdown",
@@ -1 +0,0 @@
1
- from .plot_quiver import plot_quiver
File without changes
File without changes
File without changes
File without changes
File without changes