spacr 0.3.66__py3-none-any.whl → 0.3.70__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.
- spacr/io.py +2 -1
- spacr/ml.py +25 -20
- spacr/plot.py +1 -1
- {spacr-0.3.66.dist-info → spacr-0.3.70.dist-info}/METADATA +1 -1
- {spacr-0.3.66.dist-info → spacr-0.3.70.dist-info}/RECORD +9 -9
- {spacr-0.3.66.dist-info → spacr-0.3.70.dist-info}/LICENSE +0 -0
- {spacr-0.3.66.dist-info → spacr-0.3.70.dist-info}/WHEEL +0 -0
- {spacr-0.3.66.dist-info → spacr-0.3.70.dist-info}/entry_points.txt +0 -0
- {spacr-0.3.66.dist-info → spacr-0.3.70.dist-info}/top_level.txt +0 -0
spacr/io.py
CHANGED
@@ -2456,7 +2456,8 @@ def _read_and_merge_data(locs, tables, verbose=False, nuclei_limit=10, pathogen_
|
|
2456
2456
|
for idx, loc in enumerate(locs):
|
2457
2457
|
db_dfs = _read_db(loc, tables)
|
2458
2458
|
if change_plate:
|
2459
|
-
db_dfs['plate'] = f'plate{idx}'
|
2459
|
+
db_dfs['plate'] = f'plate{idx+1}'
|
2460
|
+
db_dfs['prc'] = db_dfs['plate'].astype(str) + '_' + db_dfs['row_name'].astype(str) + '_' + db_dfs['column_name'].astype(str)
|
2460
2461
|
for table, df in zip(tables, db_dfs):
|
2461
2462
|
data_dict[table].append(df)
|
2462
2463
|
|
spacr/ml.py
CHANGED
@@ -1493,27 +1493,32 @@ def _calculate_similarity(df, features, col_to_compare, val1, val2):
|
|
1493
1493
|
# Add a small value to the diagonal elements for regularization
|
1494
1494
|
epsilon = 1e-5
|
1495
1495
|
inv_cov_matrix = np.linalg.inv(cov_matrix + np.eye(cov_matrix.shape[0]) * epsilon)
|
1496
|
-
|
1496
|
+
|
1497
1497
|
# Calculate similarity scores
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1498
|
+
def safe_similarity(func, row, control):
|
1499
|
+
try:
|
1500
|
+
return func(row, control)
|
1501
|
+
except Exception:
|
1502
|
+
return np.nan
|
1503
|
+
|
1504
|
+
# Calculate similarity scores
|
1505
|
+
try:
|
1506
|
+
df['similarity_to_pos_euclidean'] = df[features].apply(lambda row: safe_similarity(euclidean, row, pos_control), axis=1)
|
1507
|
+
df['similarity_to_neg_euclidean'] = df[features].apply(lambda row: safe_similarity(euclidean, row, neg_control), axis=1)
|
1508
|
+
df['similarity_to_pos_cosine'] = df[features].apply(lambda row: safe_similarity(cosine, row, pos_control), axis=1)
|
1509
|
+
df['similarity_to_neg_cosine'] = df[features].apply(lambda row: safe_similarity(cosine, row, neg_control), axis=1)
|
1510
|
+
df['similarity_to_pos_mahalanobis'] = df[features].apply(lambda row: safe_similarity(mahalanobis, row, pos_control, inv_cov_matrix), axis=1)
|
1511
|
+
df['similarity_to_neg_mahalanobis'] = df[features].apply(lambda row: safe_similarity(mahalanobis, row, neg_control, inv_cov_matrix), axis=1)
|
1512
|
+
df['similarity_to_pos_manhattan'] = df[features].apply(lambda row: safe_similarity(cityblock, row, pos_control), axis=1)
|
1513
|
+
df['similarity_to_neg_manhattan'] = df[features].apply(lambda row: safe_similarity(cityblock, row, neg_control), axis=1)
|
1514
|
+
df['similarity_to_pos_minkowski'] = df[features].apply(lambda row: safe_similarity(minkowski, row, pos_control, p=3), axis=1)
|
1515
|
+
df['similarity_to_neg_minkowski'] = df[features].apply(lambda row: safe_similarity(minkowski, row, neg_control, p=3), axis=1)
|
1516
|
+
df['similarity_to_pos_chebyshev'] = df[features].apply(lambda row: safe_similarity(chebyshev, row, pos_control), axis=1)
|
1517
|
+
df['similarity_to_neg_chebyshev'] = df[features].apply(lambda row: safe_similarity(chebyshev, row, neg_control), axis=1)
|
1518
|
+
df['similarity_to_pos_braycurtis'] = df[features].apply(lambda row: safe_similarity(braycurtis, row, pos_control), axis=1)
|
1519
|
+
df['similarity_to_neg_braycurtis'] = df[features].apply(lambda row: safe_similarity(braycurtis, row, neg_control), axis=1)
|
1520
|
+
except Exception as e:
|
1521
|
+
print(f"Error calculating similarity scores: {e}")
|
1517
1522
|
return df
|
1518
1523
|
|
1519
1524
|
def interperate_vision_model(settings={}):
|
spacr/plot.py
CHANGED
@@ -3771,7 +3771,7 @@ def plot_proportion_stacked_bars(settings, df, group_column, bin_column, prc_col
|
|
3771
3771
|
pairwise_results = chi_pairwise(raw_counts, verbose=settings.get('verbose', False))
|
3772
3772
|
|
3773
3773
|
# Plot based on level setting
|
3774
|
-
if level
|
3774
|
+
if level in ['well', 'plate']:
|
3775
3775
|
# Aggregate by well for mean ± SD visualization
|
3776
3776
|
well_proportions = (
|
3777
3777
|
df.groupby([group_column, prc_column, bin_column])
|
@@ -15,13 +15,13 @@ spacr/gui.py,sha256=ARyn9Q_g8HoP-cXh1nzMLVFCKqthY4v2u9yORyaQqQE,8230
|
|
15
15
|
spacr/gui_core.py,sha256=N7R7yvfK_dJhOReM_kW3Ci8Bokhi1OzsxeKqvSGdvV4,41460
|
16
16
|
spacr/gui_elements.py,sha256=EKlvEg_4_je7jciEdR3NTgPrcTraowa2e2RUt-xqd6M,138254
|
17
17
|
spacr/gui_utils.py,sha256=u9RoIOWpAXFEOnUlLpMQZrc1pWSg6omZsJMIhJdRv_g,41211
|
18
|
-
spacr/io.py,sha256=
|
18
|
+
spacr/io.py,sha256=ActzerMS0NC1-MIffGTFBdKcqL1T72d3VjfieTta3O4,143101
|
19
19
|
spacr/logger.py,sha256=lJhTqt-_wfAunCPl93xE65Wr9Y1oIHJWaZMjunHUeIw,1538
|
20
20
|
spacr/measure.py,sha256=2lK-ZcTxLM-MpXV1oZnucRD9iz5aprwahRKw9IEqshg,55085
|
21
21
|
spacr/mediar.py,sha256=FwLvbLQW5LQzPgvJZG8Lw7GniA2vbZx6Jv6vIKu7I5c,14743
|
22
|
-
spacr/ml.py,sha256=
|
22
|
+
spacr/ml.py,sha256=h0IrXoNnyNzZLPYbtZPFI6c4Qeu1gH8R3iUz_O7-ar0,78114
|
23
23
|
spacr/openai.py,sha256=5vBZ3Jl2llYcW3oaTEXgdyCB2aJujMUIO5K038z7w_A,1246
|
24
|
-
spacr/plot.py,sha256=
|
24
|
+
spacr/plot.py,sha256=gXC7y3uT4sx8KRODeSFWQG_A1CylsuJ5B7HYe_un6so,165177
|
25
25
|
spacr/sequencing.py,sha256=ClUfwPPK6rNUbUuiEkzcwakzVyDKKUMv9ricrxT8qQY,25227
|
26
26
|
spacr/settings.py,sha256=wZcqdTWaRus27wn9P0EGyftcJn_i0IwlM9pyeCVqxr8,80173
|
27
27
|
spacr/sim.py,sha256=1xKhXimNU3ukzIw-3l9cF3Znc_brW8h20yv8fSTzvss,71173
|
@@ -152,9 +152,9 @@ spacr/resources/icons/umap.png,sha256=dOLF3DeLYy9k0nkUybiZMe1wzHQwLJFRmgccppw-8b
|
|
152
152
|
spacr/resources/images/plate1_E01_T0001F001L01A01Z01C02.tif,sha256=Tl0ZUfZ_AYAbu0up_nO0tPRtF1BxXhWQ3T3pURBCCRo,7958528
|
153
153
|
spacr/resources/images/plate1_E01_T0001F001L01A02Z01C01.tif,sha256=m8N-V71rA1TT4dFlENNg8s0Q0YEXXs8slIn7yObmZJQ,7958528
|
154
154
|
spacr/resources/images/plate1_E01_T0001F001L01A03Z01C03.tif,sha256=Pbhk7xn-KUP6RSIhJsxQcrHFImBm3GEpLkzx7WOc-5M,7958528
|
155
|
-
spacr-0.3.
|
156
|
-
spacr-0.3.
|
157
|
-
spacr-0.3.
|
158
|
-
spacr-0.3.
|
159
|
-
spacr-0.3.
|
160
|
-
spacr-0.3.
|
155
|
+
spacr-0.3.70.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
|
156
|
+
spacr-0.3.70.dist-info/METADATA,sha256=152VlHisIA_E2F9NYFd_pqDqVxqpGZ07qUDzb7BTnPc,6032
|
157
|
+
spacr-0.3.70.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
158
|
+
spacr-0.3.70.dist-info/entry_points.txt,sha256=BMC0ql9aNNpv8lUZ8sgDLQMsqaVnX5L535gEhKUP5ho,296
|
159
|
+
spacr-0.3.70.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
|
160
|
+
spacr-0.3.70.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|