mcDETECT 2.0.11__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 CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "2.0.11"
1
+ __version__ = "2.0.12"
2
2
 
3
3
  from . import model
4
4
  from . import utils
mcDETECT/model.py CHANGED
@@ -109,26 +109,22 @@ class mcDETECT:
109
109
 
110
110
  for k in range(n_clusters):
111
111
 
112
- # record cell ids
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
- # calculate size, composition, and in-nucleus score
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 coordinate, radius, size, composition, and in-nucleus score
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcDETECT
3
- Version: 2.0.11
3
+ Version: 2.0.12
4
4
  Summary: Uncovering the dark transcriptome in polarized neuronal compartments with mcDETECT
5
5
  Home-page: https://github.com/chen-yang-yuan/mcDETECT
6
6
  Author: Chenyang Yuan
@@ -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,,
@@ -1,8 +0,0 @@
1
- mcDETECT/__init__.py,sha256=8ZH_Aljm3rgizWtNHOlZMSrmaALRJwLuiyygwrgEWAk,93
2
- mcDETECT/model.py,sha256=VskA4YKQ9-16AB-Le6HdWNEwyNoQiFxIckCZ8xR8HiY,29950
3
- mcDETECT/utils.py,sha256=0gvqZV7sGi8qvvdC5x9XScyiTXlSfqbUt1zks4t7Xd4,4545
4
- mcdetect-2.0.11.dist-info/licenses/LICENSE,sha256=uxq-shEWOGTIGVnQLmpElILmfCkuUhFZRAMnZUiKvtg,1070
5
- mcdetect-2.0.11.dist-info/METADATA,sha256=BCb4S7JuBZCUq3wpyHbW4rhjRGKjmLi-lhLkLzAoTgE,3017
6
- mcdetect-2.0.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- mcdetect-2.0.11.dist-info/top_level.txt,sha256=WwzBojt5U-T2hZ8llO6XgpM9OFIBkWQQldQKu19O8EY,9
8
- mcdetect-2.0.11.dist-info/RECORD,,