mcDETECT 2.0.11__tar.gz → 2.0.12__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 mcDETECT might be problematic. Click here for more details.
- {mcdetect-2.0.11 → mcdetect-2.0.12}/PKG-INFO +1 -1
- mcdetect-2.0.12/mcDETECT/__init__.py +6 -0
- {mcdetect-2.0.11 → mcdetect-2.0.12}/mcDETECT/model.py +19 -14
- {mcdetect-2.0.11 → mcdetect-2.0.12}/mcDETECT.egg-info/PKG-INFO +1 -1
- {mcdetect-2.0.11 → mcdetect-2.0.12}/setup.py +1 -1
- mcdetect-2.0.11/mcDETECT/__init__.py +0 -6
- {mcdetect-2.0.11 → mcdetect-2.0.12}/LICENSE +0 -0
- {mcdetect-2.0.11 → mcdetect-2.0.12}/README.md +0 -0
- {mcdetect-2.0.11 → mcdetect-2.0.12}/mcDETECT/utils.py +0 -0
- {mcdetect-2.0.11 → mcdetect-2.0.12}/mcDETECT.egg-info/SOURCES.txt +0 -0
- {mcdetect-2.0.11 → mcdetect-2.0.12}/mcDETECT.egg-info/dependency_links.txt +0 -0
- {mcdetect-2.0.11 → mcdetect-2.0.12}/mcDETECT.egg-info/requires.txt +0 -0
- {mcdetect-2.0.11 → mcdetect-2.0.12}/mcDETECT.egg-info/top_level.txt +0 -0
- {mcdetect-2.0.11 → mcdetect-2.0.12}/setup.cfg +0 -0
|
@@ -109,26 +109,22 @@ class mcDETECT:
|
|
|
109
109
|
|
|
110
110
|
for k in range(n_clusters):
|
|
111
111
|
|
|
112
|
-
#
|
|
113
|
-
if record_cell_id:
|
|
114
|
-
temp = target[labels == k]
|
|
115
|
-
temp_cell_id_mode = temp["cell_id"].mode()[0]
|
|
116
|
-
cell_id.append(temp_cell_id_mode)
|
|
117
|
-
|
|
118
|
-
# find minimum enclosing spheres
|
|
112
|
+
# ---------- find minimum enclosing spheres ---------- #
|
|
119
113
|
mask = (labels == k)
|
|
120
114
|
coords = X[mask]
|
|
121
115
|
if coords.shape[0] == 0:
|
|
122
116
|
continue
|
|
123
|
-
temp_in_nucleus = np.sum(target["overlaps_nucleus"].values[mask])
|
|
124
|
-
temp_size = coords.shape[0]
|
|
125
117
|
|
|
126
118
|
temp = pd.DataFrame(coords, columns=["global_x", "global_y", "global_z"])
|
|
127
119
|
temp = temp.drop_duplicates()
|
|
128
120
|
coords_unique = temp.to_numpy()
|
|
121
|
+
|
|
122
|
+
# skip clusters with too few unique points
|
|
129
123
|
if coords_unique.shape[0] < self.low_bound:
|
|
130
124
|
print(f"Skipping small cluster for gene {j}, cluster {k} (n = {coords_unique.shape[0]})")
|
|
131
125
|
continue
|
|
126
|
+
|
|
127
|
+
# compute minimum enclosing sphere without singularity issues
|
|
132
128
|
try:
|
|
133
129
|
center, r2 = miniball.get_bounding_ball(coords_unique, epsilon=1e-8)
|
|
134
130
|
except np.linalg.LinAlgError:
|
|
@@ -136,13 +132,22 @@ class mcDETECT:
|
|
|
136
132
|
center = coords_unique.mean(axis=0)
|
|
137
133
|
dists = np.linalg.norm(coords_unique - center, axis=1)
|
|
138
134
|
r2 = (dists.max() ** 2)
|
|
139
|
-
|
|
135
|
+
|
|
136
|
+
# record closest z-layer
|
|
140
137
|
if self.type != "Xenium":
|
|
141
138
|
closest_z = closest(z_grid, center[2])
|
|
142
139
|
else:
|
|
143
140
|
closest_z = center[2]
|
|
144
141
|
|
|
145
|
-
#
|
|
142
|
+
# record cell id after filtering
|
|
143
|
+
if record_cell_id:
|
|
144
|
+
temp_target = target[labels == k]
|
|
145
|
+
temp_cell_id_mode = temp_target["cell_id"].mode()[0]
|
|
146
|
+
cell_id.append(temp_cell_id_mode)
|
|
147
|
+
|
|
148
|
+
# ---------- compute sphere features (size, composition, and in-nucleus ratio) ---------- #
|
|
149
|
+
temp_in_nucleus = np.sum(target["overlaps_nucleus"].values[mask])
|
|
150
|
+
temp_size = coords.shape[0]
|
|
146
151
|
other_idx = tree.query_ball_point([center[0], center[1], center[2]], np.sqrt(r2))
|
|
147
152
|
other_trans = others.iloc[other_idx]
|
|
148
153
|
other_in_nucleus = np.sum(other_trans["overlaps_nucleus"])
|
|
@@ -152,7 +157,7 @@ class mcDETECT:
|
|
|
152
157
|
total_comp = 1 + other_comp
|
|
153
158
|
local_score = (temp_in_nucleus + other_in_nucleus) / total_size
|
|
154
159
|
|
|
155
|
-
# record
|
|
160
|
+
# record sphere features
|
|
156
161
|
sphere_x.append(center[0])
|
|
157
162
|
sphere_y.append(center[1])
|
|
158
163
|
sphere_z.append(center[2])
|
|
@@ -409,7 +414,7 @@ class mcDETECT:
|
|
|
409
414
|
adata.var_names = genes
|
|
410
415
|
adata.var_keys = genes
|
|
411
416
|
return adata
|
|
412
|
-
|
|
417
|
+
|
|
413
418
|
|
|
414
419
|
# [MAIN] anndata, spot-level neuron metadata
|
|
415
420
|
def spot_neuron(adata_neuron, spot, grid_len = 50, neuron_loc_key = ["global_x", "global_y"], spot_loc_key = ["global_x", "global_y"]):
|
|
@@ -434,7 +439,7 @@ def spot_neuron(adata_neuron, spot, grid_len = 50, neuron_loc_key = ["global_x",
|
|
|
434
439
|
spot.obs["neuron_count"] = neuron_count
|
|
435
440
|
return spot
|
|
436
441
|
|
|
437
|
-
|
|
442
|
+
|
|
438
443
|
# [MAIN] anndata, spot-level granule metadata
|
|
439
444
|
def spot_granule(granule, spot, grid_len = 50, gnl_loc_key = ["sphere_x", "sphere_y"], spot_loc_key = ["global_x", "global_y"]):
|
|
440
445
|
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name = "mcDETECT",
|
|
5
|
-
version = "2.0.
|
|
5
|
+
version = "2.0.12",
|
|
6
6
|
packages = find_packages(),
|
|
7
7
|
install_requires = ["anndata", "miniball", "numpy", "pandas", "rtree", "scanpy", "scikit-learn", "scipy", "shapely"],
|
|
8
8
|
author = "Chenyang Yuan",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|