SURE-tools 2.1.37__tar.gz → 2.1.39__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 (31) hide show
  1. {sure_tools-2.1.37 → sure_tools-2.1.39}/PKG-INFO +1 -1
  2. sure_tools-2.1.39/SURE/perturb/__init__.py +1 -0
  3. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/perturb/perturb.py +57 -0
  4. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE_tools.egg-info/PKG-INFO +1 -1
  5. {sure_tools-2.1.37 → sure_tools-2.1.39}/setup.py +1 -1
  6. sure_tools-2.1.37/SURE/perturb/__init__.py +0 -1
  7. {sure_tools-2.1.37 → sure_tools-2.1.39}/LICENSE +0 -0
  8. {sure_tools-2.1.37 → sure_tools-2.1.39}/README.md +0 -0
  9. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/PerturbFlow.py +0 -0
  10. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/SURE.py +0 -0
  11. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/__init__.py +0 -0
  12. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/assembly/__init__.py +0 -0
  13. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/assembly/assembly.py +0 -0
  14. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/assembly/atlas.py +0 -0
  15. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/atac/__init__.py +0 -0
  16. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/atac/utils.py +0 -0
  17. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/codebook/__init__.py +0 -0
  18. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/codebook/codebook.py +0 -0
  19. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/flow/__init__.py +0 -0
  20. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/flow/flow_stats.py +0 -0
  21. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/flow/plot_quiver.py +0 -0
  22. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/utils/__init__.py +0 -0
  23. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/utils/custom_mlp.py +0 -0
  24. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/utils/queue.py +0 -0
  25. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE/utils/utils.py +0 -0
  26. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE_tools.egg-info/SOURCES.txt +0 -0
  27. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE_tools.egg-info/dependency_links.txt +0 -0
  28. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE_tools.egg-info/entry_points.txt +0 -0
  29. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE_tools.egg-info/requires.txt +0 -0
  30. {sure_tools-2.1.37 → sure_tools-2.1.39}/SURE_tools.egg-info/top_level.txt +0 -0
  31. {sure_tools-2.1.37 → sure_tools-2.1.39}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SURE-tools
3
- Version: 2.1.37
3
+ Version: 2.1.39
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 @@
1
+ from .perturb import LabelMatrix,DoseMatrix
@@ -1,5 +1,6 @@
1
1
  import re
2
2
  import numpy as np
3
+ from numba import njit
3
4
  from itertools import chain
4
5
  from joblib import Parallel, delayed
5
6
  from typing import Literal
@@ -27,6 +28,20 @@ class LabelMatrix:
27
28
 
28
29
  def inverse_transform(self, matrix):
29
30
  return matrix_to_labels(matrix=matrix, unique_labels=self.labels_)
31
+
32
+ class DoseMatrix:
33
+ def __init__(self):
34
+ self.labels_ = None
35
+
36
+ def fit_transform(self, labels, label_dose, control_label=None):
37
+ mat, self.labels_ = dose_to_matrix(labels, label_dose)
38
+
39
+ if control_label is not None:
40
+ idx = np.where(self.labels_==control_label)[0]
41
+ mat = np.delete(mat, idx, axis=1)
42
+ self.labels_ = np.delete(self.labels_, idx)
43
+
44
+ return mat
30
45
 
31
46
  def label_to_matrix(labels, sep_pattern=r'[;_\-\s]'):
32
47
  """
@@ -91,3 +106,45 @@ def parallel_label_to_matrix(labels, sep_pattern=r'[;_\-\s]', n_jobs=4):
91
106
  def matrix_to_labels(matrix, unique_labels):
92
107
  return [';'.join([unique_labels[i] for i in np.where(row)[0]])
93
108
  for row in matrix]
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+ @njit(parallel=True)
117
+ def _numba_fill_matrix(dose_matrix, label_indices, label_doses):
118
+ """Numba 加速的矩阵填充函数"""
119
+ for i in range(len(label_indices)):
120
+ for j, dose in zip(label_indices[i], label_doses[i]):
121
+ dose_matrix[i, j] = dose
122
+
123
+ def dose_to_matrix(labels, label_dose, all_labels=None):
124
+ """
125
+ 使用 Numba 的终极加速版本(需预先安装 numba)
126
+ """
127
+ if all_labels is None:
128
+ all_labels = sorted(set().union(*labels))
129
+
130
+ label_to_idx = {label: idx for idx, label in enumerate(all_labels)}
131
+ n_samples = len(labels)
132
+ n_labels = len(all_labels)
133
+ dose_matrix = np.zeros((n_samples, n_labels), dtype=np.float64)
134
+
135
+ # 预处理为 Numba 兼容格式
136
+ label_indices = []
137
+ label_doses = []
138
+ for sample_labels in labels:
139
+ indices = []
140
+ doses = []
141
+ if sample_labels:
142
+ for label in sample_labels:
143
+ indices.append(label_to_idx[label])
144
+ doses.append(label_dose[label])
145
+ label_indices.append(np.array(indices, dtype=np.int64))
146
+ label_doses.append(np.array(doses, dtype=np.float64))
147
+
148
+ # 调用 Numba 加速函数
149
+ _numba_fill_matrix(dose_matrix, label_indices, label_doses)
150
+ return dose_matrix,all_labels
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SURE-tools
3
- Version: 2.1.37
3
+ Version: 2.1.39
4
4
  Summary: Succinct Representation of Single Cells
5
5
  Home-page: https://github.com/ZengFLab/SURE
6
6
  Author: Feng Zeng
@@ -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.37',
8
+ version='2.1.39',
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 .perturb import LabelMatrix
File without changes
File without changes
File without changes
File without changes