spacr 0.3.38__py3-none-any.whl → 0.3.42__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/core.py +1 -1
- spacr/io.py +20 -13
- spacr/measure.py +4 -4
- spacr/ml.py +53 -44
- spacr/plot.py +421 -37
- spacr/settings.py +18 -13
- spacr/toxo.py +223 -16
- spacr/utils.py +7 -5
- {spacr-0.3.38.dist-info → spacr-0.3.42.dist-info}/METADATA +1 -1
- {spacr-0.3.38.dist-info → spacr-0.3.42.dist-info}/RECORD +14 -14
- {spacr-0.3.38.dist-info → spacr-0.3.42.dist-info}/LICENSE +0 -0
- {spacr-0.3.38.dist-info → spacr-0.3.42.dist-info}/WHEEL +0 -0
- {spacr-0.3.38.dist-info → spacr-0.3.42.dist-info}/entry_points.txt +0 -0
- {spacr-0.3.38.dist-info → spacr-0.3.42.dist-info}/top_level.txt +0 -0
spacr/settings.py
CHANGED
@@ -261,7 +261,7 @@ def get_measure_crop_settings(settings={}):
|
|
261
261
|
settings.setdefault('nucleus_mask_dim',None)
|
262
262
|
settings.setdefault('pathogen_mask_dim',None)
|
263
263
|
settings.setdefault('cytoplasm',False)
|
264
|
-
settings.setdefault('
|
264
|
+
settings.setdefault('uninfected',True)
|
265
265
|
settings.setdefault('cell_min_size',0)
|
266
266
|
settings.setdefault('nucleus_min_size',0)
|
267
267
|
settings.setdefault('pathogen_min_size',0)
|
@@ -527,26 +527,31 @@ def set_generate_dataset_defaults(settings):
|
|
527
527
|
return settings
|
528
528
|
|
529
529
|
def get_perform_regression_default_settings(settings):
|
530
|
-
settings.setdefault('
|
531
|
-
settings.setdefault('
|
530
|
+
settings.setdefault('count_data','list of paths')
|
531
|
+
settings.setdefault('score_data','list of paths')
|
532
|
+
settings.setdefault('positive_control','239740')
|
533
|
+
settings.setdefault('negative_control','233460')
|
534
|
+
settings.setdefault('controls',['000000_1','000000_10','000000_11','000000_12','000000_13','000000_14','000000_15','000000_16','000000_17','000000_18','000000_19','000000_20','000000_21','000000_22','000000_23','000000_24','000000_25','000000_26','000000_27','000000_28','000000_29','000000_3','000000_30','000000_31','000000_32','000000_4','000000_5','000000_6','000000_8','000000_9'])
|
535
|
+
settings.setdefault('fraction_threshold',0.12)
|
536
|
+
settings.setdefault('dependent_variable','pred')
|
537
|
+
settings.setdefault('threshold_method','std')
|
538
|
+
settings.setdefault('threshold_multiplier',3)
|
532
539
|
settings.setdefault('transform',None)
|
533
540
|
settings.setdefault('agg_type','mean')
|
534
541
|
settings.setdefault('min_cell_count',25)
|
535
542
|
settings.setdefault('regression_type','ols')
|
536
543
|
settings.setdefault('random_row_column_effects',False)
|
544
|
+
settings.setdefault('split_axis_lims','')
|
545
|
+
settings.setdefault('plate','')
|
546
|
+
settings.setdefault('cov_type',None)
|
537
547
|
settings.setdefault('alpha',1)
|
538
|
-
settings.setdefault('
|
539
|
-
settings.setdefault('
|
540
|
-
settings.setdefault('nc','c1')
|
541
|
-
settings.setdefault('pc','c2')
|
542
|
-
settings.setdefault('other','c3')
|
548
|
+
settings.setdefault('filter_value',['c1', 'c2', 'c3'])
|
549
|
+
settings.setdefault('filter_column','column')
|
543
550
|
settings.setdefault('plate','plate1')
|
544
551
|
settings.setdefault('class_1_threshold',None)
|
545
|
-
settings.setdefault('cov_type',None)
|
546
552
|
settings.setdefault('metadata_files',['/home/carruthers/Documents/TGME49_Summary.csv','/home/carruthers/Documents/TGGT1_Summary.csv'])
|
547
553
|
settings.setdefault('toxo', True)
|
548
554
|
|
549
|
-
|
550
555
|
if settings['regression_type'] == 'quantile':
|
551
556
|
print(f"Using alpha as quantile for quantile regression, alpha: {settings['alpha']}")
|
552
557
|
settings['agg_type'] = None
|
@@ -664,7 +669,7 @@ expected_types = {
|
|
664
669
|
"png_dims": list,
|
665
670
|
"normalize_by": str,
|
666
671
|
"save_measurements": bool,
|
667
|
-
"
|
672
|
+
"uninfected": bool,
|
668
673
|
"dialate_pngs": bool,
|
669
674
|
"dialate_png_ratios": list,
|
670
675
|
"n_jobs": int,
|
@@ -893,7 +898,7 @@ expected_types = {
|
|
893
898
|
categories = {"Paths":[ "src", "grna", "barcodes", "custom_model_path", "dataset","model_path","grna_csv","row_csv","column_csv"],
|
894
899
|
"General": ["metadata_type", "custom_regex", "experiment", "channels", "magnification", "channel_dims", "apply_model_to_dataset", "generate_training_dataset", "train_DL_model", "segmentation_mode"],
|
895
900
|
"Cellpose":["from_scratch", "n_epochs", "width_height", "model_name", "custom_model", "resample", "rescale", "CP_prob", "flow_threshold", "percentiles", "circular", "invert", "diameter", "grayscale", "background", "Signal_to_noise", "resize", "target_height", "target_width"],
|
896
|
-
"Cell": ["cell_intensity_range", "cell_size_range", "cell_chann_dim", "cell_channel", "cell_background", "cell_Signal_to_noise", "cell_CP_prob", "cell_FT", "remove_background_cell", "cell_min_size", "cell_mask_dim", "cytoplasm", "cytoplasm_min_size", "
|
901
|
+
"Cell": ["cell_intensity_range", "cell_size_range", "cell_chann_dim", "cell_channel", "cell_background", "cell_Signal_to_noise", "cell_CP_prob", "cell_FT", "remove_background_cell", "cell_min_size", "cell_mask_dim", "cytoplasm", "cytoplasm_min_size", "uninfected", "merge_edge_pathogen_cells", "adjust_cells", "cells", "cell_loc"],
|
897
902
|
"Nucleus": ["nucleus_intensity_range", "nucleus_size_range", "nucleus_chann_dim", "nucleus_channel", "nucleus_background", "nucleus_Signal_to_noise", "nucleus_CP_prob", "nucleus_FT", "remove_background_nucleus", "nucleus_min_size", "nucleus_mask_dim", "nucleus_loc"],
|
898
903
|
"Pathogen": ["pathogen_intensity_range", "pathogen_size_range", "pathogen_chann_dim", "pathogen_channel", "pathogen_background", "pathogen_Signal_to_noise", "pathogen_CP_prob", "pathogen_FT", "pathogen_model", "remove_background_pathogen", "pathogen_min_size", "pathogen_mask_dim", "pathogens", "pathogen_loc", "pathogen_types", "pathogen_plate_metadata", ],
|
899
904
|
"Measurements": ["remove_image_canvas", "remove_highly_correlated", "homogeneity", "homogeneity_distances", "radial_dist", "calculate_correlation", "manders_thresholds", "save_measurements", "tables", "image_nr", "dot_size", "filter_by", "remove_highly_correlated_features", "remove_low_variance_features", "channel_of_interest"],
|
@@ -1083,7 +1088,7 @@ def generate_fields(variables, scrollable_frame):
|
|
1083
1088
|
"nuclei_limit": "(int) - Whether to include multinucleated cells in the analysis.",
|
1084
1089
|
"pathogen_limit": "(int) - Whether to include multi-infected cells in the analysis.",
|
1085
1090
|
"uninfected": "(bool) - Whether to include non-infected cells in the analysis.",
|
1086
|
-
"
|
1091
|
+
"uninfected": "(bool) - Whether to include uninfected cells in the analysis.",
|
1087
1092
|
"init_weights": "(bool) - Whether to initialize weights for the model.",
|
1088
1093
|
"src": "(str) - Path to the folder containing the images.",
|
1089
1094
|
"intermedeate_save": "(bool) - Whether to save intermediate results.",
|
spacr/toxo.py
CHANGED
@@ -4,8 +4,9 @@ import numpy as np
|
|
4
4
|
from adjustText import adjust_text
|
5
5
|
import pandas as pd
|
6
6
|
from scipy.stats import fisher_exact
|
7
|
+
from IPython.display import display
|
7
8
|
|
8
|
-
def
|
9
|
+
def custom_volcano_plot_v1(data_path, metadata_path, metadata_column='tagm_location', point_size=50, figsize=20, threshold=0):
|
9
10
|
"""
|
10
11
|
Create a volcano plot with the ability to control the shape of points based on a categorical column,
|
11
12
|
color points based on a string list, annotate specific points based on p-value and coefficient thresholds,
|
@@ -19,7 +20,8 @@ def custom_volcano_plot(data_path, metadata_path, metadata_column='tagm_location
|
|
19
20
|
- point_size: Fixed value to control the size of points.
|
20
21
|
- figsize: Width of the plot (height is half the width).
|
21
22
|
"""
|
22
|
-
|
23
|
+
|
24
|
+
|
23
25
|
filename = 'volcano_plot.pdf'
|
24
26
|
|
25
27
|
# Load the data
|
@@ -42,46 +44,65 @@ def custom_volcano_plot(data_path, metadata_path, metadata_column='tagm_location
|
|
42
44
|
metadata['gene_nr'] = metadata['gene_nr'].astype(str)
|
43
45
|
data['gene_nr'] = data['gene_nr'].astype(str)
|
44
46
|
|
47
|
+
|
45
48
|
# Merge data and metadata on 'gene_nr'
|
46
49
|
merged_data = pd.merge(data, metadata[['gene_nr', 'tagm_location']], on='gene_nr', how='left')
|
47
|
-
|
48
|
-
# Controls handling
|
49
|
-
controls = ['000000', '000001', '000002', '000003', '000004', '000005', '000006', '000007', '000008', '000009', '000010', '000011']
|
50
|
-
merged_data.loc[merged_data['gene_nr'].isin(controls), metadata_column] = 'control'
|
50
|
+
|
51
51
|
merged_data.loc[merged_data['gene_nr'].str.startswith('4'), metadata_column] = 'GT1_gene'
|
52
52
|
merged_data.loc[merged_data['gene_nr'] == 'Intercept', metadata_column] = 'Intercept'
|
53
53
|
|
54
|
-
# Create a 'highlight_color' column based on the string_list
|
55
|
-
merged_data['highlight_color'] = merged_data['gene_nr'].apply(lambda x: 'red' if any(s in x for s in string_list) else 'blue')
|
56
|
-
|
57
54
|
# Create the volcano plot
|
58
55
|
figsize_2 = figsize / 2
|
59
56
|
plt.figure(figsize=(figsize_2, figsize))
|
57
|
+
|
58
|
+
palette = {
|
59
|
+
'pc': 'red',
|
60
|
+
'nc': 'green',
|
61
|
+
'control': 'black',
|
62
|
+
'other': 'gray'
|
63
|
+
}
|
64
|
+
|
65
|
+
merged_data['condition'] = pd.Categorical(
|
66
|
+
merged_data['condition'],
|
67
|
+
categories=['pc', 'nc', 'control', 'other'],
|
68
|
+
ordered=True
|
69
|
+
)
|
60
70
|
|
71
|
+
display(merged_data)
|
72
|
+
|
61
73
|
# Create the scatter plot with fixed point size
|
62
74
|
sns.scatterplot(
|
63
75
|
data=merged_data,
|
64
76
|
x='coefficient',
|
65
77
|
y='-log10(p_value)',
|
66
|
-
hue='
|
67
|
-
style=metadata_column if metadata_column else None, #
|
78
|
+
hue='condition', # Controls color
|
79
|
+
style=metadata_column if metadata_column else None, # Controls point shape
|
68
80
|
s=point_size, # Fixed size for all points
|
69
|
-
palette=
|
81
|
+
palette=palette, # Color palette
|
82
|
+
alpha=1.0 # Transparency
|
70
83
|
)
|
71
84
|
|
72
85
|
# Set the plot title and labels
|
73
86
|
plt.title('Custom Volcano Plot of Coefficients')
|
74
87
|
plt.xlabel('Coefficient')
|
75
88
|
plt.ylabel('-log10(p-value)')
|
89
|
+
|
90
|
+
if threshold > 0:
|
91
|
+
plt.gca().axvline(x=-abs(threshold), linestyle='--', color='black')
|
92
|
+
plt.gca().axvline(x=abs(threshold), linestyle='--', color='black')
|
76
93
|
|
77
94
|
# Horizontal line at p-value threshold (0.05)
|
78
|
-
plt.axhline(y=-np.log10(0.05), color='
|
95
|
+
plt.axhline(y=-np.log10(0.05), color='black', linestyle='--')
|
79
96
|
|
80
|
-
# Annotate points where p_value <= 0.05 and coefficient >= 0.25
|
81
97
|
texts = []
|
82
98
|
for i, row in merged_data.iterrows():
|
83
|
-
if row['p_value'] <= 0.05 and row['coefficient'] >=
|
84
|
-
texts.append(plt.text(
|
99
|
+
if row['p_value'] <= 0.05 and abs(row['coefficient']) >= abs(threshold):
|
100
|
+
texts.append(plt.text(
|
101
|
+
row['coefficient'],
|
102
|
+
-np.log10(row['p_value']),
|
103
|
+
row['variable'],
|
104
|
+
fontsize=8
|
105
|
+
))
|
85
106
|
|
86
107
|
# Adjust text positions to avoid overlap
|
87
108
|
adjust_text(texts, arrowprops=dict(arrowstyle='-', color='black'))
|
@@ -96,6 +117,192 @@ def custom_volcano_plot(data_path, metadata_path, metadata_column='tagm_location
|
|
96
117
|
# Show the plot
|
97
118
|
plt.show()
|
98
119
|
|
120
|
+
def custom_volcano_plot(data_path, metadata_path, metadata_column='tagm_location', point_size=50, figsize=20, threshold=0, split_axis_lims = [10, None, None, 10]):
|
121
|
+
"""
|
122
|
+
Create a volcano plot with the ability to control the shape of points based on a categorical column,
|
123
|
+
color points based on a condition, annotate specific points based on p-value and coefficient thresholds,
|
124
|
+
and control the size of points.
|
125
|
+
"""
|
126
|
+
|
127
|
+
filename = 'volcano_plot.pdf'
|
128
|
+
|
129
|
+
# Load the data
|
130
|
+
if isinstance(data_path, pd.DataFrame):
|
131
|
+
data = data_path
|
132
|
+
else:
|
133
|
+
data = pd.read_csv(data_path)
|
134
|
+
|
135
|
+
data['variable'] = data['feature'].str.extract(r'\[(.*?)\]')
|
136
|
+
data['variable'].fillna(data['feature'], inplace=True)
|
137
|
+
split_columns = data['variable'].str.split('_', expand=True)
|
138
|
+
data['gene_nr'] = split_columns[0]
|
139
|
+
data = data[data['variable'] != 'Intercept']
|
140
|
+
|
141
|
+
# Load metadata
|
142
|
+
if isinstance(metadata_path, pd.DataFrame):
|
143
|
+
metadata = metadata_path
|
144
|
+
else:
|
145
|
+
metadata = pd.read_csv(metadata_path)
|
146
|
+
|
147
|
+
metadata['gene_nr'] = metadata['gene_nr'].astype(str)
|
148
|
+
data['gene_nr'] = data['gene_nr'].astype(str)
|
149
|
+
|
150
|
+
# Merge data and metadata on 'gene_nr'
|
151
|
+
merged_data = pd.merge(data, metadata[['gene_nr', 'tagm_location']], on='gene_nr', how='left')
|
152
|
+
|
153
|
+
merged_data.loc[merged_data['gene_nr'].str.startswith('4'), metadata_column] = 'GT1_gene'
|
154
|
+
merged_data.loc[merged_data['gene_nr'] == 'Intercept', metadata_column] = 'Intercept'
|
155
|
+
merged_data.loc[merged_data['condition'] == 'control', metadata_column] = 'control'
|
156
|
+
|
157
|
+
# Categorize condition for coloring
|
158
|
+
merged_data['condition'] = pd.Categorical(
|
159
|
+
merged_data['condition'],
|
160
|
+
categories=['other','pc', 'nc', 'control'],
|
161
|
+
ordered=True)
|
162
|
+
|
163
|
+
|
164
|
+
display(merged_data)
|
165
|
+
|
166
|
+
# Create subplots with a broken y-axis
|
167
|
+
figsize_2 = figsize / 2
|
168
|
+
fig, (ax1, ax2) = plt.subplots(
|
169
|
+
2, 1, figsize=(figsize, figsize),
|
170
|
+
sharex=True, gridspec_kw={'height_ratios': [1, 3]}
|
171
|
+
)
|
172
|
+
|
173
|
+
# Define color palette
|
174
|
+
palette = {
|
175
|
+
'pc': 'red',
|
176
|
+
'nc': 'green',
|
177
|
+
'control': 'white',
|
178
|
+
'other': 'gray'}
|
179
|
+
|
180
|
+
# Scatter plot on both axes
|
181
|
+
sns.scatterplot(
|
182
|
+
data=merged_data,
|
183
|
+
x='coefficient',
|
184
|
+
y='-log10(p_value)',
|
185
|
+
hue='condition', # Keep colors but prevent them from showing in the final legend
|
186
|
+
style=metadata_column if metadata_column else None, # Shape-based legend
|
187
|
+
s=point_size,
|
188
|
+
edgecolor='black',
|
189
|
+
palette=palette,
|
190
|
+
legend='brief', # Capture the full legend initially
|
191
|
+
alpha=0.8,
|
192
|
+
ax=ax2 # Lower plot
|
193
|
+
)
|
194
|
+
|
195
|
+
sns.scatterplot(
|
196
|
+
data=merged_data[merged_data['-log10(p_value)'] > 10],
|
197
|
+
x='coefficient',
|
198
|
+
y='-log10(p_value)',
|
199
|
+
hue='condition',
|
200
|
+
style=metadata_column if metadata_column else None,
|
201
|
+
s=point_size,
|
202
|
+
palette=palette,
|
203
|
+
edgecolor='black',
|
204
|
+
legend=False, # Suppress legend for upper plot
|
205
|
+
alpha=0.8,
|
206
|
+
ax=ax1 # Upper plot
|
207
|
+
)
|
208
|
+
|
209
|
+
if isinstance(split_axis_lims, list):
|
210
|
+
if len(split_axis_lims) == 4:
|
211
|
+
ylim_min_ax1 = split_axis_lims[0]
|
212
|
+
if split_axis_lims[1] is None:
|
213
|
+
ylim_max_ax1 = merged_data['-log10(p_value)'].max() + 5
|
214
|
+
else:
|
215
|
+
ylim_max_ax1 = split_axis_lims[1]
|
216
|
+
ylim_min_ax2 = split_axis_lims[2]
|
217
|
+
ylim_max_ax2 = split_axis_lims[3]
|
218
|
+
else:
|
219
|
+
ylim_min_ax1 = None
|
220
|
+
ylim_max_ax1 = merged_data['-log10(p_value)'].max() + 5
|
221
|
+
ylim_min_ax2 = 0
|
222
|
+
ylim_max_ax2 = None
|
223
|
+
|
224
|
+
# Set axis limits and hide unnecessary parts
|
225
|
+
ax1.set_ylim(ylim_min_ax1, ylim_max_ax1)
|
226
|
+
ax2.set_ylim(0, ylim_max_ax2)
|
227
|
+
ax1.spines['bottom'].set_visible(False)
|
228
|
+
ax2.spines['top'].set_visible(False)
|
229
|
+
ax1.tick_params(labelbottom=False)
|
230
|
+
|
231
|
+
if ax1.get_legend() is not None:
|
232
|
+
ax1.legend_.remove()
|
233
|
+
ax1.get_legend().remove() # Extract handles and labels from the legend
|
234
|
+
handles, labels = ax2.get_legend_handles_labels()
|
235
|
+
|
236
|
+
# Identify shape-based legend entries (skip color-based entries)
|
237
|
+
shape_handles = handles[len(set(merged_data['condition'])):]
|
238
|
+
shape_labels = labels[len(set(merged_data['condition'])):]
|
239
|
+
|
240
|
+
# Set the legend with only shape-based entries
|
241
|
+
ax2.legend(
|
242
|
+
shape_handles,
|
243
|
+
shape_labels,
|
244
|
+
bbox_to_anchor=(1.05, 1),
|
245
|
+
loc='upper left',
|
246
|
+
borderaxespad=0.
|
247
|
+
)
|
248
|
+
|
249
|
+
ax1.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
|
250
|
+
|
251
|
+
# Add vertical threshold lines to both plots
|
252
|
+
if threshold > 0:
|
253
|
+
for ax in (ax1, ax2):
|
254
|
+
ax.axvline(x=-abs(threshold), linestyle='--', color='black')
|
255
|
+
ax.axvline(x=abs(threshold), linestyle='--', color='black')
|
256
|
+
|
257
|
+
# Add a horizontal line at p-value threshold (0.05)
|
258
|
+
ax2.axhline(y=-np.log10(0.05), color='black', linestyle='--')
|
259
|
+
|
260
|
+
# Annotate significant points on both axes
|
261
|
+
texts_ax1 = []
|
262
|
+
texts_ax2 = []
|
263
|
+
|
264
|
+
for i, row in merged_data.iterrows():
|
265
|
+
if row['p_value'] <= 0.05 and abs(row['coefficient']) >= abs(threshold):
|
266
|
+
# Select the appropriate axis for the annotation
|
267
|
+
#ax = ax1 if row['-log10(p_value)'] > 10 else ax2
|
268
|
+
|
269
|
+
ax = ax1 if row['-log10(p_value)'] >= ax1.get_ylim()[0] else ax2
|
270
|
+
|
271
|
+
|
272
|
+
# Create the annotation on the selected axis
|
273
|
+
text = ax.text(
|
274
|
+
row['coefficient'],
|
275
|
+
-np.log10(row['p_value']),
|
276
|
+
row['variable'],
|
277
|
+
fontsize=8,
|
278
|
+
ha='center',
|
279
|
+
va='bottom',
|
280
|
+
)
|
281
|
+
|
282
|
+
# Store the text annotation in the correct list
|
283
|
+
if ax == ax1:
|
284
|
+
texts_ax1.append(text)
|
285
|
+
else:
|
286
|
+
texts_ax2.append(text)
|
287
|
+
|
288
|
+
# Adjust text positions to avoid overlap for both axes
|
289
|
+
adjust_text(texts_ax1, arrowprops=dict(arrowstyle='-', color='black'), ax=ax1)
|
290
|
+
adjust_text(texts_ax2, arrowprops=dict(arrowstyle='-', color='black'), ax=ax2)
|
291
|
+
|
292
|
+
# Move the legend outside the lower plot
|
293
|
+
ax2.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.)
|
294
|
+
|
295
|
+
# Adjust the spacing between subplots and move the title
|
296
|
+
plt.subplots_adjust(hspace=0.05)
|
297
|
+
fig.suptitle('Custom Volcano Plot of Coefficients', y=1.02, fontsize=16) # Title above the top plot
|
298
|
+
|
299
|
+
# Save the plot as PDF
|
300
|
+
plt.savefig(filename, format='pdf', bbox_inches='tight')
|
301
|
+
print(f'Saved Volcano plot: {filename}')
|
302
|
+
|
303
|
+
# Show the plot
|
304
|
+
plt.show()
|
305
|
+
|
99
306
|
def go_term_enrichment_by_column(significant_df, metadata_path, go_term_columns=['Computed GO Processes', 'Curated GO Components', 'Curated GO Functions', 'Curated GO Processes']):
|
100
307
|
"""
|
101
308
|
Perform GO term enrichment analysis for each GO term column and generate plots.
|
spacr/utils.py
CHANGED
@@ -326,6 +326,8 @@ def save_settings(settings, name='settings', show=False):
|
|
326
326
|
|
327
327
|
if isinstance(settings['src'], list):
|
328
328
|
src = settings['src'][0]
|
329
|
+
#if os.path.exists(src):
|
330
|
+
|
329
331
|
name = f"{name}_list"
|
330
332
|
else:
|
331
333
|
src = settings['src']
|
@@ -2910,7 +2912,7 @@ def _relabel_parent_with_child_labels(parent_mask, child_mask):
|
|
2910
2912
|
|
2911
2913
|
return parent_mask_new, child_mask
|
2912
2914
|
|
2913
|
-
def _exclude_objects(cell_mask, nucleus_mask, pathogen_mask, cytoplasm_mask,
|
2915
|
+
def _exclude_objects(cell_mask, nucleus_mask, pathogen_mask, cytoplasm_mask, uninfected=True):
|
2914
2916
|
"""
|
2915
2917
|
Exclude objects from the masks based on certain criteria.
|
2916
2918
|
|
@@ -2919,7 +2921,7 @@ def _exclude_objects(cell_mask, nucleus_mask, pathogen_mask, cytoplasm_mask, inc
|
|
2919
2921
|
nucleus_mask (ndarray): Mask representing nucleus.
|
2920
2922
|
pathogen_mask (ndarray): Mask representing pathogens.
|
2921
2923
|
cytoplasm_mask (ndarray): Mask representing cytoplasm.
|
2922
|
-
|
2924
|
+
uninfected (bool, optional): Whether to include uninfected cells. Defaults to True.
|
2923
2925
|
|
2924
2926
|
Returns:
|
2925
2927
|
tuple: A tuple containing the filtered cell mask, nucleus mask, pathogen mask, and cytoplasm mask.
|
@@ -2934,7 +2936,7 @@ def _exclude_objects(cell_mask, nucleus_mask, pathogen_mask, cytoplasm_mask, inc
|
|
2934
2936
|
has_nucleus = np.any(nucleus_mask[cell_region])
|
2935
2937
|
has_cytoplasm = np.any(cytoplasm_mask[cell_region])
|
2936
2938
|
has_pathogen = np.any(pathogen_mask[cell_region])
|
2937
|
-
if
|
2939
|
+
if uninfected:
|
2938
2940
|
if has_nucleus and has_cytoplasm:
|
2939
2941
|
filtered_cells[cell_region] = cell_label
|
2940
2942
|
else:
|
@@ -4712,10 +4714,10 @@ def merge_regression_res_with_metadata(results_file, metadata_file, name='_metad
|
|
4712
4714
|
df_metadata['gene'] = df_metadata['Gene ID'].apply(lambda x: x.split('_')[1] if '_' in x else None)
|
4713
4715
|
|
4714
4716
|
# Drop rows where gene extraction failed
|
4715
|
-
df_results = df_results.dropna(subset=['gene'])
|
4717
|
+
#df_results = df_results.dropna(subset=['gene'])
|
4716
4718
|
|
4717
4719
|
# Merge the two dataframes on the gene column
|
4718
|
-
merged_df = pd.merge(df_results, df_metadata, on='gene')
|
4720
|
+
merged_df = pd.merge(df_results, df_metadata, on='gene', how='left')
|
4719
4721
|
|
4720
4722
|
# Generate the new file name
|
4721
4723
|
base, ext = os.path.splitext(results_file)
|
@@ -8,26 +8,26 @@ spacr/app_measure.py,sha256=_K7APYIeOKpV6e_LcqabBjvEi7mfq9Fch8175x1x0k8,162
|
|
8
8
|
spacr/app_sequencing.py,sha256=DjG26jy4cpddnV8WOOAIiExtOe9MleVMY4MFa5uTo5w,157
|
9
9
|
spacr/app_umap.py,sha256=ZWAmf_OsIKbYvolYuWPMYhdlVe-n2CADoJulAizMiEo,153
|
10
10
|
spacr/cellpose.py,sha256=zv4BzhaP2O-mtQ-pUfYvpOyxgn1ke_bDWgdHD5UWm9I,13942
|
11
|
-
spacr/core.py,sha256=
|
11
|
+
spacr/core.py,sha256=dW9RrAKFLfVsFhX0-kaVMc2T7b47Ky0pTXK-CEVOeWQ,48235
|
12
12
|
spacr/deep_spacr.py,sha256=HdOcNU8cHcE_19nP7_5uTz-ih3E169ffr2Hm--NvMvA,43255
|
13
13
|
spacr/gui.py,sha256=ARyn9Q_g8HoP-cXh1nzMLVFCKqthY4v2u9yORyaQqQE,8230
|
14
14
|
spacr/gui_core.py,sha256=LV_HX5zreu3Bye6sQFDbOuk8Dfj4StMoohy6hsrDEXA,41363
|
15
15
|
spacr/gui_elements.py,sha256=w-S1MZdyxt5O3DsNAHNNXy_WGfwBPg0NhwQtCsJeiao,137071
|
16
16
|
spacr/gui_utils.py,sha256=7e9DsZIuV7-jh97kEf7v1In_cFzlFueV4SGcGYGpTxw,45454
|
17
|
-
spacr/io.py,sha256=
|
17
|
+
spacr/io.py,sha256=LN_gJq_oqjbf8y-lBtLLZtJi8DLbNdyoGEcBYyOjbhQ,143606
|
18
18
|
spacr/logger.py,sha256=lJhTqt-_wfAunCPl93xE65Wr9Y1oIHJWaZMjunHUeIw,1538
|
19
|
-
spacr/measure.py,sha256=
|
19
|
+
spacr/measure.py,sha256=KdboGXoi85BO5-_6er7932FgjFI7G7tuaQDnWSiEuew,54817
|
20
20
|
spacr/mediar.py,sha256=FwLvbLQW5LQzPgvJZG8Lw7GniA2vbZx6Jv6vIKu7I5c,14743
|
21
|
-
spacr/ml.py,sha256=
|
21
|
+
spacr/ml.py,sha256=vzuEnbQd96mn7T8h3GRsEDnpWSSpxd3ApGMXTiG6b2o,50507
|
22
22
|
spacr/openai.py,sha256=5vBZ3Jl2llYcW3oaTEXgdyCB2aJujMUIO5K038z7w_A,1246
|
23
|
-
spacr/plot.py,sha256=
|
23
|
+
spacr/plot.py,sha256=TDGMwiIHjvk6v94WFlIvemU-6JfEik_GmSez51vyvCc,135869
|
24
24
|
spacr/sequencing.py,sha256=t18mgpK6rhWuB1LtFOsPxqgpFXxuUmrD06ecsaVQ0Gw,19655
|
25
|
-
spacr/settings.py,sha256=
|
25
|
+
spacr/settings.py,sha256=x3zcOpVbsxGvq4neW-H08CxzNl8thacy4WOxcIG4TAc,76607
|
26
26
|
spacr/sim.py,sha256=1xKhXimNU3ukzIw-3l9cF3Znc_brW8h20yv8fSTzvss,71173
|
27
27
|
spacr/submodules.py,sha256=AB7s6-cULsaqz-haAaCtXfGEIi8uPZGT4xoCslUJC3Y,18391
|
28
28
|
spacr/timelapse.py,sha256=FSYpUtAVy6xc3lwprRYgyDTT9ysUhfRQ4zrP9_h2mvg,39465
|
29
|
-
spacr/toxo.py,sha256=
|
30
|
-
spacr/utils.py,sha256=
|
29
|
+
spacr/toxo.py,sha256=MVDfkfTl6fhbzg3izLWdtr2arARYIhI1TdScnHtPVqI,16770
|
30
|
+
spacr/utils.py,sha256=Z8lmQJc8sdPvHi0ZmYOahuKtUmDcrYtRYlT4qNZORXU,216396
|
31
31
|
spacr/version.py,sha256=axH5tnGwtgSnJHb5IDhiu4Zjk5GhLyAEDRe-rnaoFOA,409
|
32
32
|
spacr/resources/MEDIAR/.gitignore,sha256=Ff1q9Nme14JUd-4Q3jZ65aeQ5X4uttptssVDgBVHYo8,152
|
33
33
|
spacr/resources/MEDIAR/LICENSE,sha256=yEj_TRDLUfDpHDNM0StALXIt6mLqSgaV2hcCwa6_TcY,1065
|
@@ -150,9 +150,9 @@ spacr/resources/icons/umap.png,sha256=dOLF3DeLYy9k0nkUybiZMe1wzHQwLJFRmgccppw-8b
|
|
150
150
|
spacr/resources/images/plate1_E01_T0001F001L01A01Z01C02.tif,sha256=Tl0ZUfZ_AYAbu0up_nO0tPRtF1BxXhWQ3T3pURBCCRo,7958528
|
151
151
|
spacr/resources/images/plate1_E01_T0001F001L01A02Z01C01.tif,sha256=m8N-V71rA1TT4dFlENNg8s0Q0YEXXs8slIn7yObmZJQ,7958528
|
152
152
|
spacr/resources/images/plate1_E01_T0001F001L01A03Z01C03.tif,sha256=Pbhk7xn-KUP6RSIhJsxQcrHFImBm3GEpLkzx7WOc-5M,7958528
|
153
|
-
spacr-0.3.
|
154
|
-
spacr-0.3.
|
155
|
-
spacr-0.3.
|
156
|
-
spacr-0.3.
|
157
|
-
spacr-0.3.
|
158
|
-
spacr-0.3.
|
153
|
+
spacr-0.3.42.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
|
154
|
+
spacr-0.3.42.dist-info/METADATA,sha256=_nbP3IjQELrampyAYyt6hfrQBukDHuhlS7CApsMPsQ0,5949
|
155
|
+
spacr-0.3.42.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
156
|
+
spacr-0.3.42.dist-info/entry_points.txt,sha256=BMC0ql9aNNpv8lUZ8sgDLQMsqaVnX5L535gEhKUP5ho,296
|
157
|
+
spacr-0.3.42.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
|
158
|
+
spacr-0.3.42.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|