mcDETECT 1.0.0__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 -0
- mcDETECT/model.py +351 -0
- mcDETECT-1.0.0.dist-info/LICENSE +21 -0
- mcDETECT-1.0.0.dist-info/METADATA +23 -0
- mcDETECT-1.0.0.dist-info/RECORD +7 -0
- mcDETECT-1.0.0.dist-info/WHEEL +5 -0
- mcDETECT-1.0.0.dist-info/top_level.txt +1 -0
mcDETECT/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .model import mcDETECT
|
mcDETECT/model.py
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import anndata
|
|
2
|
+
import math
|
|
3
|
+
import miniball
|
|
4
|
+
import numpy as np
|
|
5
|
+
import pandas as pd
|
|
6
|
+
import scanpy as sc
|
|
7
|
+
from rtree import index
|
|
8
|
+
from scipy.spatial import cKDTree
|
|
9
|
+
from scipy.stats import poisson
|
|
10
|
+
from shapely.geometry import Point
|
|
11
|
+
from sklearn.cluster import DBSCAN
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def closest(lst, K):
|
|
15
|
+
return lst[min(range(len(lst)), key = lambda i: abs(lst[i] - K))]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def make_tree(d1 = None, d2 = None, d3 = None):
|
|
19
|
+
active_dimensions = [dimension for dimension in [d1, d2, d3] if dimension is not None]
|
|
20
|
+
if len(active_dimensions) == 1:
|
|
21
|
+
points = np.c_[active_dimensions[0].ravel()]
|
|
22
|
+
elif len(active_dimensions) == 2:
|
|
23
|
+
points = np.c_[active_dimensions[0].ravel(), active_dimensions[1].ravel()]
|
|
24
|
+
elif len(active_dimensions) == 3:
|
|
25
|
+
points = np.c_[active_dimensions[0].ravel(), active_dimensions[1].ravel(), active_dimensions[2].ravel()]
|
|
26
|
+
return cKDTree(points)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def make_rtree(spheres):
|
|
30
|
+
p = index.Property()
|
|
31
|
+
idx = index.Index(properties = p)
|
|
32
|
+
for i, sphere in enumerate(spheres.itertuples()):
|
|
33
|
+
center = Point(sphere.sphere_x, sphere.sphere_y)
|
|
34
|
+
bounds = (center.x - sphere.sphere_r,
|
|
35
|
+
center.y - sphere.sphere_r,
|
|
36
|
+
center.x + sphere.sphere_r,
|
|
37
|
+
center.y + sphere.sphere_r)
|
|
38
|
+
idx.insert(i, bounds)
|
|
39
|
+
return idx
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class mcDETECT:
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def __init__(self, type, transcripts, syn_genes, nc_genes = None, eps = 1.5, minspl = None, grid_len = 1.0, cutoff_prob = 0.95, alpha = 5.0, low_bound = 3,
|
|
46
|
+
size_thr = 4.0, in_nucleus_thr = (0.5, 0.5), l = 1.0, rho = 0.2, s = 1.0, nc_top = 20, nc_thr = 0.1):
|
|
47
|
+
|
|
48
|
+
self.type = type # string, iST platform, now support MERSCOPE, Xenium, and CosMx
|
|
49
|
+
self.transcripts = transcripts # dataframe, transcripts file
|
|
50
|
+
self.syn_genes = syn_genes # list, string, all synaptic markers
|
|
51
|
+
self.nc_genes = nc_genes # list, string, all negative controls
|
|
52
|
+
self.eps = eps # numeric, searching radius epsilon
|
|
53
|
+
self.minspl = minspl # integer, manually select min_samples, i.e., no automatic parameter selection
|
|
54
|
+
self.grid_len = grid_len # numeric, length of grids for computing the tissue area
|
|
55
|
+
self.cutoff_prob = cutoff_prob # numeric, cutoff probability in parameter selection for min_samples
|
|
56
|
+
self.alpha = alpha # numeric, scaling factor in parameter selection for min_samples
|
|
57
|
+
self.low_bound = low_bound # integer, lower bound in parameter selection for min_samples
|
|
58
|
+
self.size_thr = size_thr # numeric, threshold for maximum radius of an aggregation
|
|
59
|
+
self.in_nucleus_thr = in_nucleus_thr # 2-d tuple, threshold for low- and high-in-nucleus ratio
|
|
60
|
+
self.l = l # numeric, scaling factor for seaching overlapped spheres
|
|
61
|
+
self.rho = rho # numeric, threshold for determining overlaps
|
|
62
|
+
self.s = s # numeric, scaling factor for merging overlapped spheres
|
|
63
|
+
self.nc_top = nc_top # integer, number of negative controls retained for filtering
|
|
64
|
+
self.nc_thr = nc_thr # numeric, threshold for negative control filtering
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# [INNER] construct grids, input for tissue_area()
|
|
68
|
+
def construct_grid(self, grid_len = None):
|
|
69
|
+
if grid_len is None:
|
|
70
|
+
grid_len = self.grid_len
|
|
71
|
+
x_min, x_max = np.min(self.transcripts['global_x']), np.max(self.transcripts['global_x'])
|
|
72
|
+
y_min, y_max = np.min(self.transcripts['global_y']), np.max(self.transcripts['global_y'])
|
|
73
|
+
x_min = np.floor(x_min / grid_len) * grid_len
|
|
74
|
+
x_max = np.ceil(x_max / grid_len) * grid_len
|
|
75
|
+
y_min = np.floor(y_min / grid_len) * grid_len
|
|
76
|
+
y_max = np.ceil(y_max / grid_len) * grid_len
|
|
77
|
+
x_bins = np.arange(x_min, x_max + grid_len, grid_len)
|
|
78
|
+
y_bins = np.arange(y_min, y_max + grid_len, grid_len)
|
|
79
|
+
return x_bins, y_bins
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# [INNER] calculate tissue area, input for poisson_select()
|
|
83
|
+
def tissue_area(self):
|
|
84
|
+
x_bins, y_bins = self.construct_grid(grid_len = None)
|
|
85
|
+
hist, _, _ = np.histogram2d(self.transcripts['global_x'], self.transcripts['global_y'], bins = [x_bins, y_bins])
|
|
86
|
+
area = np.count_nonzero(hist) * (self.grid_len ** 2)
|
|
87
|
+
return area
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# [INNER] calculate optimal min_samples, input for dbscan()
|
|
91
|
+
def poisson_select(self, gene_name):
|
|
92
|
+
num_trans = np.sum(self.transcripts['target'] == gene_name)
|
|
93
|
+
bg_density = num_trans / self.tissue_area()
|
|
94
|
+
cutoff_density = poisson.ppf(self.cutoff_prob, mu = self.alpha * bg_density * (np.pi * self.eps ** 2))
|
|
95
|
+
optimal_m = int(max(cutoff_density, self.low_bound))
|
|
96
|
+
return optimal_m
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# [INTERMEDIATE] dictionary, low- and high-in-nucleus spheres for each synaptic marker
|
|
100
|
+
def dbscan(self, target_names = None, write_csv = False, write_path = './'):
|
|
101
|
+
|
|
102
|
+
if self.type != 'Xenium':
|
|
103
|
+
z_grid = list(np.unique(self.transcripts['global_z']))
|
|
104
|
+
z_grid.sort()
|
|
105
|
+
|
|
106
|
+
if target_names is None:
|
|
107
|
+
target_names = self.syn_genes
|
|
108
|
+
transcripts = self.transcripts[self.transcripts['target'].isin(target_names)]
|
|
109
|
+
|
|
110
|
+
num_individual, data_low, data_high = [], {}, {}
|
|
111
|
+
|
|
112
|
+
for j in target_names:
|
|
113
|
+
|
|
114
|
+
# split transcripts
|
|
115
|
+
target = transcripts[transcripts['target'] == j]
|
|
116
|
+
others = transcripts[transcripts['target'] != j]
|
|
117
|
+
tree = make_tree(d1 = np.array(others['global_x']), d2 = np.array(others['global_y']), d3 = np.array(others['global_z']))
|
|
118
|
+
|
|
119
|
+
# 3D DBSCAN
|
|
120
|
+
if self.minspl is None:
|
|
121
|
+
min_spl = self.poisson_select(j)
|
|
122
|
+
else:
|
|
123
|
+
min_spl = self.minspl
|
|
124
|
+
X = np.array(target[['global_x', 'global_y', 'global_z']])
|
|
125
|
+
db = DBSCAN(eps = self.eps, min_samples = min_spl, algorithm = 'kd_tree').fit(X)
|
|
126
|
+
labels = db.labels_
|
|
127
|
+
n_clusters = len(set(labels)) - (1 if -1 in labels else 0)
|
|
128
|
+
|
|
129
|
+
# iterate over all aggregations
|
|
130
|
+
sphere_x, sphere_y, sphere_z, layer_z, sphere_r, sphere_size, sphere_comp, sphere_score = [], [], [], [], [], [], [], []
|
|
131
|
+
|
|
132
|
+
for k in range(n_clusters):
|
|
133
|
+
|
|
134
|
+
# find minimum enclosing spheres
|
|
135
|
+
temp = target[labels == k]
|
|
136
|
+
temp_in_nucleus = np.sum(temp['overlaps_nucleus'])
|
|
137
|
+
temp_size = temp.shape[0]
|
|
138
|
+
temp = temp[['global_x', 'global_y', 'global_z']]
|
|
139
|
+
temp = temp.drop_duplicates()
|
|
140
|
+
center, r2 = miniball.get_bounding_ball(np.array(temp), epsilon=1e-8)
|
|
141
|
+
if self.type != 'Xenium':
|
|
142
|
+
closest_z = closest(z_grid, center[2])
|
|
143
|
+
else:
|
|
144
|
+
closest_z = center[2]
|
|
145
|
+
|
|
146
|
+
# calculate size, composition, and in-nucleus score
|
|
147
|
+
other_idx = tree.query_ball_point([center[0], center[1], center[2]], np.sqrt(r2))
|
|
148
|
+
other_trans = others.iloc[other_idx]
|
|
149
|
+
other_in_nucleus = np.sum(other_trans['overlaps_nucleus'])
|
|
150
|
+
other_size = other_trans.shape[0]
|
|
151
|
+
other_comp = len(np.unique(other_trans['target']))
|
|
152
|
+
total_size = temp_size + other_size
|
|
153
|
+
total_comp = 1 + other_comp
|
|
154
|
+
local_score = (temp_in_nucleus + other_in_nucleus) / total_size
|
|
155
|
+
|
|
156
|
+
# record coordinate, radius, size, composition, and in-nucleus score
|
|
157
|
+
sphere_x.append(center[0])
|
|
158
|
+
sphere_y.append(center[1])
|
|
159
|
+
sphere_z.append(center[2])
|
|
160
|
+
layer_z.append(closest_z)
|
|
161
|
+
sphere_r.append(np.sqrt(r2))
|
|
162
|
+
sphere_size.append(total_size)
|
|
163
|
+
sphere_comp.append(total_comp)
|
|
164
|
+
sphere_score.append(local_score)
|
|
165
|
+
|
|
166
|
+
# basic features for all spheres from each synaptic marker
|
|
167
|
+
sphere = pd.DataFrame(list(zip(sphere_x, sphere_y, sphere_z, layer_z, sphere_r, sphere_size, sphere_comp, sphere_score)),
|
|
168
|
+
columns = ['sphere_x', 'sphere_y', 'sphere_z', 'layer_z', 'sphere_r', 'size', 'comp', 'in_nucleus'])
|
|
169
|
+
sphere['gene'] = [j] * sphere.shape[0]
|
|
170
|
+
|
|
171
|
+
# split low- and high-in-nucleus spheres
|
|
172
|
+
sphere_low = sphere[(sphere['sphere_r'] < self.size_thr) & (sphere['in_nucleus'] < self.in_nucleus_thr[0])]
|
|
173
|
+
sphere_high = sphere[(sphere['sphere_r'] < self.size_thr) & (sphere['in_nucleus'] > self.in_nucleus_thr[1])]
|
|
174
|
+
|
|
175
|
+
if write_csv:
|
|
176
|
+
sphere_low.to_csv(write_path + j + ' sphere.csv', index=0)
|
|
177
|
+
sphere_high.to_csv(write_path + j + ' sphere_high.csv', index=0)
|
|
178
|
+
|
|
179
|
+
num_individual.append(sphere_low.shape[0])
|
|
180
|
+
data_low[target_names.index(j)] = sphere_low
|
|
181
|
+
data_high[target_names.index(j)] = sphere_high
|
|
182
|
+
print("{} out of {} genes processed!".format(target_names.index(j) + 1, len(target_names)))
|
|
183
|
+
|
|
184
|
+
return np.sum(num_individual), data_low, data_high
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# [INNER] merge points from two overlapped spheres, input for remove_overlaps()
|
|
188
|
+
def find_points(self, sphere_a, sphere_b):
|
|
189
|
+
transcripts = self.transcripts[self.transcripts['target'].isin(self.syn_genes)]
|
|
190
|
+
tree_temp = make_tree(d1 = np.array(transcripts['global_x']), d2 = np.array(transcripts['global_y']), d3 = np.array(transcripts['global_z']))
|
|
191
|
+
idx_a = tree_temp.query_ball_point([sphere_a['sphere_x'], sphere_a['sphere_y'], sphere_a['sphere_z']], sphere_a['sphere_r'])
|
|
192
|
+
points_a = transcripts.iloc[idx_a]
|
|
193
|
+
points_a = points_a[points_a['target'] == sphere_a['gene']]
|
|
194
|
+
idx_b = tree_temp.query_ball_point([sphere_b['sphere_x'], sphere_b['sphere_y'], sphere_b['sphere_z']], sphere_b['sphere_r'])
|
|
195
|
+
points_b = transcripts.iloc[idx_b]
|
|
196
|
+
points_b = points_b[points_b['target'] == sphere_b['gene']]
|
|
197
|
+
points = pd.concat([points_a, points_b])
|
|
198
|
+
points = points[['global_x', 'global_y', 'global_z']]
|
|
199
|
+
return points
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def remove_overlaps(self, set_a, set_b):
|
|
203
|
+
|
|
204
|
+
set_a = set_a.copy()
|
|
205
|
+
set_b = set_b.copy()
|
|
206
|
+
|
|
207
|
+
# find possible overlaps on 2D by r-tree
|
|
208
|
+
idx_b = make_rtree(set_b)
|
|
209
|
+
for i, sphere_a in set_a.iterrows():
|
|
210
|
+
center_a_3D = (sphere_a.sphere_x, sphere_a.sphere_y, sphere_a.sphere_z)
|
|
211
|
+
bounds_a = (sphere_a.sphere_x - sphere_a.sphere_r,
|
|
212
|
+
sphere_a.sphere_y - sphere_a.sphere_r,
|
|
213
|
+
sphere_a.sphere_x + sphere_a.sphere_r,
|
|
214
|
+
sphere_a.sphere_y + sphere_a.sphere_r)
|
|
215
|
+
possible_overlaps = idx_b.intersection(bounds_a)
|
|
216
|
+
|
|
217
|
+
# search 3D overlaps within possible overlaps
|
|
218
|
+
for j in possible_overlaps:
|
|
219
|
+
if j in set_b.index:
|
|
220
|
+
sphere_b = set_b.loc[j]
|
|
221
|
+
center_b_3D = (sphere_b.sphere_x, sphere_b.sphere_y, sphere_b.sphere_z)
|
|
222
|
+
dist = math.dist(center_a_3D, center_b_3D)
|
|
223
|
+
radius_sum = sphere_a.sphere_r + sphere_b.sphere_r
|
|
224
|
+
radius_diff = sphere_a.sphere_r - sphere_b.sphere_r
|
|
225
|
+
|
|
226
|
+
# relative positions (0: internal & intersect, 1: internal, 2: intersect)
|
|
227
|
+
c0 = (dist < self.l * radius_sum)
|
|
228
|
+
c1 = (dist <= self.l * np.abs(radius_diff))
|
|
229
|
+
c1_1 = (radius_diff > 0)
|
|
230
|
+
c2_1 = (dist < self.rho * self.l * radius_sum)
|
|
231
|
+
|
|
232
|
+
# operations on dataframes
|
|
233
|
+
if c0:
|
|
234
|
+
if c1 and c1_1: # keep A and remove B
|
|
235
|
+
set_b.drop(index = j, inplace = True)
|
|
236
|
+
elif c1 and not c1_1: # replace A with B and remove B
|
|
237
|
+
set_a.loc[i] = set_b.loc[j]
|
|
238
|
+
set_b.drop(index = j, inplace = True)
|
|
239
|
+
elif not c1 and c2_1: # replace A with new sphere and remove B
|
|
240
|
+
points_union = np.array(self.find_points(sphere_a, sphere_b))
|
|
241
|
+
new_center, new_radius = miniball.get_bounding_ball(points_union, epsilon=1e-8)
|
|
242
|
+
set_a.loc[i, 'sphere_x'] = new_center[0]
|
|
243
|
+
set_a.loc[i, 'sphere_y'] = new_center[1]
|
|
244
|
+
set_a.loc[i, 'sphere_z'] = new_center[2]
|
|
245
|
+
set_a.loc[i, 'sphere_r'] = self.s * new_radius
|
|
246
|
+
set_b.drop(index = j, inplace = True)
|
|
247
|
+
|
|
248
|
+
set_a = set_a.reset_index(drop = True)
|
|
249
|
+
set_b = set_b.reset_index(drop = True)
|
|
250
|
+
return set_a, set_b
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
# [INNER] merge spheres from different synaptic markers, input for detect()
|
|
254
|
+
def merge_sphere(self, sphere_dict):
|
|
255
|
+
sphere = sphere_dict[0].copy()
|
|
256
|
+
for j in range(1, len(self.syn_genes)):
|
|
257
|
+
target_sphere = sphere_dict[j]
|
|
258
|
+
sphere, target_sphere_new = self.remove_overlaps(sphere, target_sphere)
|
|
259
|
+
sphere = pd.concat([sphere, target_sphere_new])
|
|
260
|
+
sphere = sphere.reset_index(drop = True)
|
|
261
|
+
return sphere
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
# [INNER] negative control filtering, input for detect()
|
|
265
|
+
def nc_filter(self, sphere_low, sphere_high):
|
|
266
|
+
|
|
267
|
+
# negative control gene profiling
|
|
268
|
+
adata_low = self.profile(sphere_low, self.nc_genes)
|
|
269
|
+
adata_high = self.profile(sphere_high, self.nc_genes)
|
|
270
|
+
adata = anndata.concat([adata_low, adata_high], axis = 0, merge = "same")
|
|
271
|
+
adata.var['genes'] = adata.var.index
|
|
272
|
+
adata.obs_keys = list(np.arange(adata.shape[0]))
|
|
273
|
+
adata.obs['type'] = ['low'] * adata_low.shape[0] + ['high'] * adata_high.shape[0]
|
|
274
|
+
adata.obs['type'] = pd.Categorical(adata.obs['type'], categories = ["low", "high"], ordered = True)
|
|
275
|
+
|
|
276
|
+
# DE analysis of negative control genes
|
|
277
|
+
sc.tl.rank_genes_groups(adata, 'type', method = 't-test')
|
|
278
|
+
names = adata.uns['rank_genes_groups']['names']
|
|
279
|
+
names = pd.DataFrame(names)
|
|
280
|
+
logfc = adata.uns['rank_genes_groups']['logfoldchanges']
|
|
281
|
+
logfc = pd.DataFrame(logfc)
|
|
282
|
+
pvals = adata.uns['rank_genes_groups']['pvals']
|
|
283
|
+
pvals = pd.DataFrame(pvals)
|
|
284
|
+
|
|
285
|
+
# select top upregulated negative control genes
|
|
286
|
+
df = pd.DataFrame({'names': names["high"], 'logfc': logfc["high"], 'pvals': pvals["high"]})
|
|
287
|
+
df = df[df['logfc'] >= 0]
|
|
288
|
+
df = df.sort_values(by = ['pvals'], ascending = True)
|
|
289
|
+
nc_genes_final = list(df['names'].head(self.nc_top))
|
|
290
|
+
|
|
291
|
+
# negative control filtering
|
|
292
|
+
nc_transcripts_final = self.transcripts[self.transcripts['target'].isin(nc_genes_final)]
|
|
293
|
+
tree = make_tree(d1 = np.array(nc_transcripts_final['global_x']), d2 = np.array(nc_transcripts_final['global_y']), d3 = np.array(nc_transcripts_final['global_z']))
|
|
294
|
+
pass_idx = [0] * sphere_low.shape[0]
|
|
295
|
+
for i in range(sphere_low.shape[0]):
|
|
296
|
+
temp = sphere_low.iloc[i]
|
|
297
|
+
nc_idx = tree.query_ball_point([temp['sphere_x'], temp['sphere_y'], temp['sphere_z']], temp['sphere_r'])
|
|
298
|
+
if len(nc_idx) == 0:
|
|
299
|
+
pass_idx[i] = 1
|
|
300
|
+
elif len(nc_idx) / temp['size'] < self.nc_thr:
|
|
301
|
+
pass_idx[i] = 2
|
|
302
|
+
sphere = sphere_low[np.array(pass_idx) != 0]
|
|
303
|
+
sphere = sphere.reset_index(drop = True)
|
|
304
|
+
return sphere
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
# [MAIN] dataframe, metadata of identified synapses
|
|
308
|
+
def detect(self):
|
|
309
|
+
|
|
310
|
+
_, data_low, data_high = self.dbscan()
|
|
311
|
+
|
|
312
|
+
print("Merging spheres...")
|
|
313
|
+
sphere_low, sphere_high = self.merge_sphere(data_low), self.merge_sphere(data_high)
|
|
314
|
+
|
|
315
|
+
if self.nc_genes is None:
|
|
316
|
+
return sphere_low
|
|
317
|
+
else:
|
|
318
|
+
print("Negative control filtering...")
|
|
319
|
+
return self.nc_filter(sphere_low, sphere_high)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
# [MAIN] anndata, spatial transcriptome profile of identified synapses
|
|
323
|
+
def profile(self, synapse, genes = None, print_itr = False):
|
|
324
|
+
|
|
325
|
+
if genes is None:
|
|
326
|
+
genes = list(np.unique(self.transcripts['target']))
|
|
327
|
+
transcripts = self.transcripts
|
|
328
|
+
else:
|
|
329
|
+
transcripts = self.transcripts[self.transcripts['target'].isin(genes)]
|
|
330
|
+
tree = make_tree(d1 = np.array(transcripts['global_x']), d2 = np.array(transcripts['global_y']), d3 = np.array(transcripts['global_z']))
|
|
331
|
+
|
|
332
|
+
# construct gene count matrix
|
|
333
|
+
X = np.zeros((len(genes), synapse.shape[0]))
|
|
334
|
+
for i in range(synapse.shape[0]):
|
|
335
|
+
temp = synapse.iloc[i]
|
|
336
|
+
target_idx = tree.query_ball_point([temp['sphere_x'], temp['sphere_y'], temp['layer_z']], temp['sphere_r'])
|
|
337
|
+
target_trans = transcripts.iloc[target_idx]
|
|
338
|
+
target_gene = list(target_trans['target'])
|
|
339
|
+
for j in np.unique(target_gene):
|
|
340
|
+
X[genes.index(j), i] = target_gene.count(j)
|
|
341
|
+
if (print_itr) & (i % 5000 == 0):
|
|
342
|
+
print('{} out of {} synapses profiled!'.format(i, synapse.shape[0]))
|
|
343
|
+
|
|
344
|
+
# construct spatial transcriptome profile
|
|
345
|
+
adata = anndata.AnnData(X = np.transpose(X), obs = synapse)
|
|
346
|
+
adata.obs['synapse_id'] = ['syn_{}'.format(i) for i in range(synapse.shape[0])]
|
|
347
|
+
adata.obs.rename(columns = {'sphere_x': 'global_x', 'sphere_y': 'global_y', 'sphere_z': 'global_z'}, inplace = True)
|
|
348
|
+
adata.var['genes'] = genes
|
|
349
|
+
adata.var_names = genes
|
|
350
|
+
adata.var_keys = genes
|
|
351
|
+
return adata
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chenyang Yuan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mcDETECT
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: mcDETECT: Decoding 3D Spatial Synaptic Transcriptomes with Subcellular-Resolution Spatial Transcriptomics
|
|
5
|
+
Home-page: https://github.com/chen-yang-yuan/mcDETECT
|
|
6
|
+
Author: Chenyang Yuan
|
|
7
|
+
Author-email: chenyang.yuan@emory.edu
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: anndata
|
|
15
|
+
Requires-Dist: miniball
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Requires-Dist: pandas
|
|
18
|
+
Requires-Dist: rtree
|
|
19
|
+
Requires-Dist: scanpy
|
|
20
|
+
Requires-Dist: scipy
|
|
21
|
+
Requires-Dist: shapely
|
|
22
|
+
Requires-Dist: sklearn
|
|
23
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
mcDETECT/__init__.py,sha256=smjxcWMgqIGgbQ47Hx0TRXtiJLHcuXizBk9DTfAZp3s,27
|
|
2
|
+
mcDETECT/model.py,sha256=d10VQzt2nycqMlfhC5tvGThDSYAbzKdZR_kmtXBo_MM,17926
|
|
3
|
+
mcDETECT-1.0.0.dist-info/LICENSE,sha256=uxq-shEWOGTIGVnQLmpElILmfCkuUhFZRAMnZUiKvtg,1070
|
|
4
|
+
mcDETECT-1.0.0.dist-info/METADATA,sha256=ni4id23Cffvaz6Vq3XSnxi6JWexF7HJu_fnJoRg81ig,713
|
|
5
|
+
mcDETECT-1.0.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
6
|
+
mcDETECT-1.0.0.dist-info/top_level.txt,sha256=WwzBojt5U-T2hZ8llO6XgpM9OFIBkWQQldQKu19O8EY,9
|
|
7
|
+
mcDETECT-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mcDETECT
|