mcDETECT 2.0.10__py3-none-any.whl → 2.0.12__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 mcDETECT might be problematic. Click here for more details.
- mcDETECT/__init__.py +1 -1
- mcDETECT/model.py +31 -15
- {mcdetect-2.0.10.dist-info → mcdetect-2.0.12.dist-info}/METADATA +1 -1
- mcdetect-2.0.12.dist-info/RECORD +8 -0
- mcdetect-2.0.10.dist-info/RECORD +0 -8
- {mcdetect-2.0.10.dist-info → mcdetect-2.0.12.dist-info}/WHEEL +0 -0
- {mcdetect-2.0.10.dist-info → mcdetect-2.0.12.dist-info}/licenses/LICENSE +0 -0
- {mcdetect-2.0.10.dist-info → mcdetect-2.0.12.dist-info}/top_level.txt +0 -0
mcDETECT/__init__.py
CHANGED
mcDETECT/model.py
CHANGED
|
@@ -109,29 +109,45 @@ 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
|
-
|
|
124
|
-
temp_size = coords.shape[0]
|
|
125
|
-
# coords_unique = np.unique(coords, axis=0)
|
|
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
|
|
123
|
+
if coords_unique.shape[0] < self.low_bound:
|
|
124
|
+
print(f"Skipping small cluster for gene {j}, cluster {k} (n = {coords_unique.shape[0]})")
|
|
125
|
+
continue
|
|
126
|
+
|
|
127
|
+
# compute minimum enclosing sphere without singularity issues
|
|
128
|
+
try:
|
|
129
|
+
center, r2 = miniball.get_bounding_ball(coords_unique, epsilon=1e-8)
|
|
130
|
+
except np.linalg.LinAlgError:
|
|
131
|
+
print(f"Warning: singular matrix for gene {j}, cluster {k} —- using fallback sphere.")
|
|
132
|
+
center = coords_unique.mean(axis=0)
|
|
133
|
+
dists = np.linalg.norm(coords_unique - center, axis=1)
|
|
134
|
+
r2 = (dists.max() ** 2)
|
|
135
|
+
|
|
136
|
+
# record closest z-layer
|
|
129
137
|
if self.type != "Xenium":
|
|
130
138
|
closest_z = closest(z_grid, center[2])
|
|
131
139
|
else:
|
|
132
140
|
closest_z = center[2]
|
|
133
141
|
|
|
134
|
-
#
|
|
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]
|
|
135
151
|
other_idx = tree.query_ball_point([center[0], center[1], center[2]], np.sqrt(r2))
|
|
136
152
|
other_trans = others.iloc[other_idx]
|
|
137
153
|
other_in_nucleus = np.sum(other_trans["overlaps_nucleus"])
|
|
@@ -141,7 +157,7 @@ class mcDETECT:
|
|
|
141
157
|
total_comp = 1 + other_comp
|
|
142
158
|
local_score = (temp_in_nucleus + other_in_nucleus) / total_size
|
|
143
159
|
|
|
144
|
-
# record
|
|
160
|
+
# record sphere features
|
|
145
161
|
sphere_x.append(center[0])
|
|
146
162
|
sphere_y.append(center[1])
|
|
147
163
|
sphere_z.append(center[2])
|
|
@@ -398,7 +414,7 @@ class mcDETECT:
|
|
|
398
414
|
adata.var_names = genes
|
|
399
415
|
adata.var_keys = genes
|
|
400
416
|
return adata
|
|
401
|
-
|
|
417
|
+
|
|
402
418
|
|
|
403
419
|
# [MAIN] anndata, spot-level neuron metadata
|
|
404
420
|
def spot_neuron(adata_neuron, spot, grid_len = 50, neuron_loc_key = ["global_x", "global_y"], spot_loc_key = ["global_x", "global_y"]):
|
|
@@ -423,7 +439,7 @@ def spot_neuron(adata_neuron, spot, grid_len = 50, neuron_loc_key = ["global_x",
|
|
|
423
439
|
spot.obs["neuron_count"] = neuron_count
|
|
424
440
|
return spot
|
|
425
441
|
|
|
426
|
-
|
|
442
|
+
|
|
427
443
|
# [MAIN] anndata, spot-level granule metadata
|
|
428
444
|
def spot_granule(granule, spot, grid_len = 50, gnl_loc_key = ["sphere_x", "sphere_y"], spot_loc_key = ["global_x", "global_y"]):
|
|
429
445
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
mcDETECT/__init__.py,sha256=NPIB-KedDsH2LsW1KCs4TjLNpDyMr1qSSuLxJ3-duY8,93
|
|
2
|
+
mcDETECT/model.py,sha256=d679UD8wKpB9ili_4qXgGZ3JT2nxh2VGjlcrSZC65oo,30171
|
|
3
|
+
mcDETECT/utils.py,sha256=0gvqZV7sGi8qvvdC5x9XScyiTXlSfqbUt1zks4t7Xd4,4545
|
|
4
|
+
mcdetect-2.0.12.dist-info/licenses/LICENSE,sha256=uxq-shEWOGTIGVnQLmpElILmfCkuUhFZRAMnZUiKvtg,1070
|
|
5
|
+
mcdetect-2.0.12.dist-info/METADATA,sha256=bdN7HVJsjkhzmFzJdPAAsSGuDIqNiQF6WDVmgC4X5ew,3017
|
|
6
|
+
mcdetect-2.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
+
mcdetect-2.0.12.dist-info/top_level.txt,sha256=WwzBojt5U-T2hZ8llO6XgpM9OFIBkWQQldQKu19O8EY,9
|
|
8
|
+
mcdetect-2.0.12.dist-info/RECORD,,
|
mcdetect-2.0.10.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
mcDETECT/__init__.py,sha256=FoRKnIon2qyKVkAcetKJDkIw8YuDuM1LhpoCZv-AE38,93
|
|
2
|
-
mcDETECT/model.py,sha256=oEkBpFPZWBTRScjsyfwes6oTu6hDsjsI-MCVdVxGiFk,29375
|
|
3
|
-
mcDETECT/utils.py,sha256=0gvqZV7sGi8qvvdC5x9XScyiTXlSfqbUt1zks4t7Xd4,4545
|
|
4
|
-
mcdetect-2.0.10.dist-info/licenses/LICENSE,sha256=uxq-shEWOGTIGVnQLmpElILmfCkuUhFZRAMnZUiKvtg,1070
|
|
5
|
-
mcdetect-2.0.10.dist-info/METADATA,sha256=N8RO2SHnwLe-LZ1wEu1xFTumQ_u4mTfMEdF8exePRYM,3017
|
|
6
|
-
mcdetect-2.0.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
-
mcdetect-2.0.10.dist-info/top_level.txt,sha256=WwzBojt5U-T2hZ8llO6XgpM9OFIBkWQQldQKu19O8EY,9
|
|
8
|
-
mcdetect-2.0.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|